- Question 1 — Create a default local StorageClass
- Question 2 — Deployment with sidecar log agent (shared volume)
- Question 3 — Create Ingress to route to service
- Question 4 — Create deployment and perform rolling image update
- Question 5 — Create user John via CSR and grant Role permissions
- Question 6 — Create nginx pod, ClusterIP service and test DNS resolution
- Question 7 — Create a static pod on cluster1-node01
- Question 8 — Create Horizontal Pod Autoscaler (HPA)
- Question 9 — Troubleshoot cluster where kubectl fails (kubelet inactive)
- Question 10 — Modify existing Gateway to use TLS (HTTPS)
- Question 11 — Find and uninstall Helm release using vulnerable image
- Question 12 — Apply most restrictive NetworkPolicy to allow only front-end -> back-end
- Question 13 — Fix a failing Deployment due to ResourceQuota
- Question 14 — Install Calico and configure CIDR 172.17.0.0/16, verify pod communication
- Kubernetes StorageClass: https://kubernetes.io/docs/concepts/storage/storage-classes/
- Kubernetes Ingress: https://kubernetes.io/docs/concepts/services-networking/ingress/
- Kubernetes RBAC: https://kubernetes.io/docs/reference/access-authn-authz/rbac/
- Kubernetes HPA: https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale/
- Gateway API: https://gateway-api.sigs.k8s.io/
- Calico installation: https://docs.projectcalico.org/getting-started/kubernetes/
This document preserves the applied manifests and order of operations so you can copy/paste the shown YAML or commands. Replace placeholders such as
<pod-name> or file names with your values as needed.Summary of resources by question
Question 1 — Create a default local StorageClass
Requirements:- StorageClass name:
local-sc. - Default StorageClass.
- Static/local provisioner (
kubernetes.io/no-provisioner). - Enable
allowVolumeExpansion: true. volumeBindingMode: WaitForFirstConsumer.
cluster1-controlplane):
kubernetes.io/no-provisioner indicates manual (static) provisioning. Marking the StorageClass as default uses the storageclass.kubernetes.io/is-default-class: "true" annotation.Question 2 — Deployment with sidecar log agent (shared volume)
Requirements:- Deployment
logging-deploymentin namespacelogging-ns. - 1 replica.
- Main container
app-container(busybox:1.28) writes to/var/log/app/app.log. - Sidecar
log-agenttails the same log file. - Shared volume:
emptyDir.
question2.yaml):
app-container appends lines; log-agent tails and outputs them to its stdout.
Question 3 — Create Ingress to route to service
Requirements:- Deployment
webapp-deployiningress-nsexists. - Service:
webapp-svc. - Ingress:
webapp-ingressiningress-ns. - IngressClass:
nginx. - Host:
kodekloud-ingress.app. - Path
/withpathType: Prefix. - Backend service
webapp-svcport80.
question3.yaml):
/etc/hosts resolves kodekloud-ingress.app to the ingress controller external IP.
Question 4 — Create deployment and do a rolling image update
Requirements:- Create deployment
nginx-deploywithnginx:1.16. - Update to
nginx:1.17using rolling update.
RollingUpdate, so no additional configuration is required.
Question 5 — Create user John via CSR and grant Role permissions
Goal:- Create CSR
john-developerfromjohn.csr, approve it, extract certificate. - Create Role
developerindevelopmentnamespace granting pod CRUD verbs. - Bind the user
johnvia RoleBinding.
- Generate CSR object
- Base64-encode the CSR (single line) and substitute into the manifest
request:field.
question5-csr.yaml):
Keep the private key secure. The CSR alone does not include the private key. Use the signed certificate
john.crt with the private key to configure kubectl contexts for user john.- Role and RoleBinding (save as
question5-rbac.yaml):
Question 6 — Create nginx pod, ClusterIP service and test DNS resolution
Requirements:- Pod
nginx-resolverusingnginximage. - Service
nginx-resolver-serviceof type ClusterIP. - From an ephemeral busybox pod, nslookup the service and pod DNS names and save outputs.
- Service DNS:
nginx-resolver-service.default.svc.cluster.local. - Pod DNS:
<ip-with-dashes>.<namespace>.pod.cluster.local.
Question 7 — Create a static pod on cluster1-node01
Requirements:- Static pod named
nginx-criticaloncluster1-node01. - Kubelet monitors
/etc/kubernetes/manifests.
- Generate static pod manifest locally:
- SSH into
cluster1-node01and place manifest:
- Kubelet creates static pods locally and registers them with the API server. Names may include the node suffix in the control plane view.
Question 8 — Create Horizontal Pod Autoscaler (HPA)
Requirements:- HPA
backend-hpafor Deploymentbackend-deploymentin namespacebackend. - minReplicas: 3, maxReplicas: 15.
- Scale on average memory utilization 65%.
- Use
autoscaling/v2.
webapp-hpa.yaml):
Question 9 — Troubleshoot cluster where kubectl fails (kubelet inactive)
Scenario:kubectlreports connection refused to API server (e.g.,dial tcp <api-server-ip>:6443: connect: connection refused).
- Confirm the API server is unreachable:
- Check kubelet status and system containers:
- Verify control plane static pods are created by kubelet:
Question 10 — Modify existing Gateway to use TLS (HTTPS)
Requirements:- On
cluster1-node1, edit Gatewayweb-gatewayin namespacecka5673. - Listener should use port
443, protocolHTTPS, hostnamekodekloud.com. - TLS certificate from Secret
kodekloud-tls.
gateway.networking.k8s.io/v1 style):
The exact TLS field might vary by Gateway implementation/version (
tls.certificateRefs vs tls.secretRef or similar). Always inspect the cluster’s Gateway API documentation or the CRD to confirm the correct field.Question 11 — Find and uninstall Helm release using vulnerable image
Goal:- Detect Helm release that deployed image
kodekloud/webapp-color:v1and uninstall it.
- Use
helm get manifestandgrepto search across releases for specific images or resources. Uninstalling the Helm release removes associated resources.
Question 12 — Apply most restrictive NetworkPolicy to allow only front-end -> back-end
Requirement:- Allow ingress to backend pods only from the
frontendnamespace; deny database namespace traffic. - Do not delete existing policies; apply the one that is most restrictive while meeting the requirements.
net-pol-3 in backend namespace:
name: frontend, effectively denying traffic from other namespaces (including database).
Question 13 — Fix a failing Deployment due to ResourceQuota
Scenario:- Deployment
backend-apidesired 3 replicas but pods fail due to ResourceQuota (exceeded quota: cpu-mem-quota).
- Inspect the deployment, ReplicaSet, and ResourceQuota:
requests.memory exceeded the quota (e.g., used 256Mi, hard 300Mi).
- Adjust pod resource
requests.memory(reduce) in the deployment spec:
- Optionally delete the failing ReplicaSet so a new one is created from the updated template:
- If you cannot change pod requests, request an increase to the ResourceQuota (if permitted).
- The root cause was exceeding namespace resource quotas; lowering requests allows scheduling within the quota limit.
Question 14 — Install Calico and configure CIDR 172.17.0.0/16, verify pod communication
Requirements:- Deploy Calico CNI and set Pod CIDR to
172.17.0.0/16. - Verify pod-to-pod communication via pod IPs.
- Download upstream Calico manifests and modify IPPool CIDR:
- Apply Calico manifests:
- Deploy a test nginx pod and verify connectivity:
- Ensure the Calico IPPool is configured before pods are assigned IPs if you require a specific Pod CIDR.
- After successful CNI installation and IPPool configuration, pods should be reachable by pod IP across the cluster.
This completes the step-by-step solutions for Mock Exam 2. Refer to the linked Kubernetes docs and respective project pages for additional details and implementation nuances.