KA
Free KA practice questions
10 questions from our KA practice tests, each with the correct answer and a written explanation. Read them with the answers shown, or switch to quiz mode and answer first.
Question 1 of 10, Workloads and Application Lifecycle
A sidecar that ships logs must start before the main container and keep running for the whole Pod lifetime, and in Jobs it must not block completion. How is this declared in current Kubernetes?
- AAs a regular container listed before the main one
- BAs an ephemeral container added after Pod start
- CAs an init container with restartPolicy: Always Correct answer
- DAs an init container with restartPolicy: OnFailure
Answer and explanation: Native sidecars are init containers with restartPolicy Always: they start in init order, keep running alongside app containers and are stopped after the main containers finish, so Jobs can complete. Regular containers start without ordering guarantees and keep Jobs running, ephemeral containers are for debugging, and OnFailure is not a valid init container restart policy for this.
Question 2 of 10, Workloads and Application Lifecycle
An API Pod must not start its main container until the database Service name db.payments.svc.cluster.local resolves in DNS. The application itself cannot be changed. Which approach meets this requirement?
- AAdd a postStart lifecycle hook to the main container that waits until the Service name resolves
- BAdd a sidecar container that polls DNS and writes a marker file the main container checks first
- CAdd a readiness probe to the main container that runs nslookup against the database Service
- DAdd an init container that loops on nslookup for the Service name and exits once it resolves Correct answer
Answer and explanation: Init containers run to completion before any app container starts, so a DNS wait loop there blocks the main container exactly as required. A readiness probe only gates traffic after the container has started, a postStart hook runs alongside the already started entrypoint, and a sidecar would require the unchangeable application to look for the marker file.
Question 3 of 10, Configuration and Secrets
Pods in the namespace shop fail with ErrImagePull and an unauthorized error from a private registry. An administrator already created a docker-registry Secret named regcred in the namespace kube-system. What must be done?
- AReference kube-system/regcred in the Pod imagePullSecrets list using the namespace/name syntax
- BMount regcred as a volume at /root/.docker/config.json inside the application container
- CCreate the regcred Secret in shop and reference it in imagePullSecrets of the Pod or its ServiceAccount Correct answer
- DSet imagePullPolicy: Always so the kubelet retries the pull with the cluster default credentials
Answer and explanation: imagePullSecrets can only reference Secrets in the Pod's own namespace, so the credential must exist in shop and be referenced by the Pod or the ServiceAccount it uses. There is no cross-namespace syntax, mounting the file into the container does not affect the kubelet's pull, and imagePullPolicy controls when pulls happen, not which credentials are used.
Question 4 of 10, Configuration and Secrets
A Pod is rejected with violates PodSecurity restricted:latest: allowPrivilegeEscalation != false. The namespace enforces the restricted level. Which container securityContext change resolves this specific violation?
- Aprivileged: false with runAsUser: 0
- BallowPrivilegeEscalation: false Correct answer
- Ccapabilities.add: ["SYS_ADMIN"]
- DreadOnlyRootFilesystem: false
Answer and explanation: The restricted profile requires containers to set allowPrivilegeEscalation to false explicitly. privileged false does not set that field and running as UID 0 violates another check, adding capabilities beyond NET_BIND_SERVICE is forbidden, and readOnlyRootFilesystem is not part of the restricted checks.
Question 5 of 10, Services, Ingress and Gateway API
An HTTPRoute in the namespace web forwards to a Service in the namespace billing. The route is accepted, but its ResolvedRefs condition is False with reason RefNotPermitted. Which resource fixes this?
- AA ReferenceGrant in billing allowing HTTPRoute from web to reference Services Correct answer
- BA NetworkPolicy in billing that allows ingress from Pods in the web namespace
- CAn ExternalName Service in web that points to the billing Service DNS name
- DA ReferenceGrant in web allowing the HTTPRoute to send traffic into billing
Answer and explanation: Cross-namespace backendRefs must be permitted by the owner of the target, so the ReferenceGrant lives in billing and names HTTPRoute from web as the source and Service as the target. A grant in web has no authority over billing, ExternalName backends are not a supported way around the check, and NetworkPolicy controls packets, not Gateway API references.
Question 6 of 10, Services, Ingress and Gateway API. Choose 2.
An app team inherited a corporate requirement that names under corp.internal resolve through the company DNS servers at 10.0.0.53, while everything else uses cluster DNS. Which two approaches meet this? (Choose two.)
- AUse dnsPolicy None with dnsConfig nameservers 10.0.0.53 only on affected Pods Correct answer
- BAdd a forward block for corp.internal to 10.0.0.53 in the CoreDNS Corefile Correct answer
- CSet dnsPolicy Default on every Pod so the node resolver handles corp.internal
- DAdd hostAliases for corp.internal mapping to 10.0.0.53 in each Pod spec
- ECreate an ExternalName Service named corp.internal pointing at 10.0.0.53
Answer and explanation: A CoreDNS server block forwarding corp.internal to the corporate resolver is cluster-wide, while dnsPolicy None with custom dnsConfig per Pod also works for the Pods that need it, at the cost of cluster names unless listed. dnsPolicy Default drops cluster DNS entirely, ExternalName expects a host name and is not a zone forwarder, and hostAliases map names to IPs rather than choosing a resolver.
Question 7 of 10, Persistent Storage and Stateful Apps
A StatefulSet is regularly scaled from 5 to 3 replicas and back. The team wants the PVCs of removed ordinals to be deleted on scale-down but kept when the whole StatefulSet is deleted. Which setting achieves this?
- ApersistentVolumeReclaimPolicy: Delete on the StorageClass used by the claim templates
- BpersistentVolumeClaimRetentionPolicy with whenScaled: Delete and whenDeleted: Retain Correct answer
- CpodManagementPolicy: Parallel so surplus Pods and their claims are removed together
- DpersistentVolumeClaimRetentionPolicy with whenScaled: Retain and whenDeleted: Delete
Answer and explanation: The StatefulSet persistentVolumeClaimRetentionPolicy has separate whenScaled and whenDeleted fields, so Delete on scale and Retain on deletion matches the requirement. The StorageClass reclaim policy only acts after a PVC is deleted, the reversed combination does the opposite, and podManagementPolicy changes Pod ordering, not PVC handling.
Question 8 of 10, Packaging and Delivery with Helm and Kustomize
A CI pipeline runs helm upgrade --reuse-values for a release after bumping the chart to a version that adds a new required value with a default in its values.yaml. The template fails with a nil pointer on that value. Why?
- A--reuse-values forces Helm to load values only from the files passed with -f
- BHelm caches the old chart, so the new values.yaml is skipped until a repo update
- CThe new default needs --reset-values plus --atomic so Helm can roll it back
- D--reuse-values merges with the last release values and ignores the new chart defaults Correct answer
Answer and explanation: With --reuse-values Helm reuses the previous release values instead of the new chart defaults, so the newly added key is missing; --reset-then-reuse-values or explicit values avoid this. -f files are still merged, rollback options do not affect rendering, and the chart in use is the one passed on the command line.
Question 9 of 10, Observability and Troubleshooting
A team adopts OpenTelemetry. They want Java Pods instrumented automatically without changing images, configured by namespace annotation. Which approach fits?
- Akube-state-metrics with a flag that exports Java spans for annotated Pods
- BOpenTelemetry Collector DaemonSet scraping Pod logs to generate trace spans
- COpenTelemetry Operator with an Instrumentation resource and inject annotations Correct answer
- DPrometheus Operator with a PodMonitor that adds a Java tracing agent to Pods
Answer and explanation: The OpenTelemetry Operator injects language agents into Pods carrying an inject annotation, configured by an Instrumentation resource. A Collector receives and processes telemetry but does not instrument code, PodMonitors configure scraping only, and kube-state-metrics exports object state.
Question 10 of 10, Observability and Troubleshooting
A new Deployment's Pods stay Pending with the event 0/3 nodes are available: 3 Insufficient cpu, while kubectl top nodes shows low actual CPU usage. What explains this?
- AThe scheduler places Pods by CPU requests, and existing requests leave too little room Correct answer
- BThe Pods have no CPU requests, so the scheduler treats them as needing a whole node each
- Ckubectl top lags behind, so the nodes are really busy and the scheduler is right to wait
- DThe CPU limits of the Pods exceed node capacity, and limits are what the scheduler checks
Answer and explanation: Scheduling uses the sum of requests on each node, not real usage, so reserved but idle requests can block new Pods. Limits are not considered for placement, metrics lag would not create this pattern, and Pods without requests are treated as requesting nothing rather than a whole node.