Practice Questions: Cluster Setup and Hardening
About These Questions
These 20 questions cover all topics in Domain 1 and are designed for practice on a Kind cluster. They are performance-based, meaning you must perform actual tasks -- not just answer multiple choice. The difficulty levels are:
- Easy: Straightforward single-step tasks (2-3 minutes)
- Medium: Multi-step tasks requiring knowledge of configuration (5-8 minutes)
- Hard: Complex tasks combining multiple concepts (8-12 minutes)
Question 1 -- Default Deny Network Policy
Difficulty: Easy
Scenario: The payments namespace contains several pods that process sensitive financial data. Currently, there are no network policies applied, meaning all pods can communicate freely.
Task: Create a NetworkPolicy called default-deny-all in the payments namespace that denies all ingress and egress traffic to all pods by default.
Question 2 -- Allow Specific Pod Communication
Difficulty: Medium
Scenario: In the webapp namespace, there are pods labeled role=frontend and pods labeled role=api. The frontend pods need to communicate with the API pods on port 8080, but no other communication should be allowed.
Task:
- Ensure a default deny all ingress policy exists in the
webappnamespace - Create a NetworkPolicy called
allow-frontend-to-apithat allows ingress traffic to pods labeledrole=apifrom pods labeledrole=frontendon TCP port 8080 only
Question 3 -- Cross-Namespace Network Policy
Difficulty: Medium
Scenario: The monitoring namespace contains Prometheus pods labeled app=prometheus. These pods need to scrape metrics from all pods in the production namespace on port 9090. The production namespace already has a default deny ingress policy.
Task: Create a NetworkPolicy called allow-prometheus-scrape in the production namespace that allows ingress traffic on port 9090 from any pod in the monitoring namespace. Use the automatic namespace label kubernetes.io/metadata.name.
Question 4 -- Egress Network Policy with DNS
Difficulty: Medium
Scenario: Pods in the restricted namespace should only be allowed to communicate with pods in the same namespace and must be able to resolve DNS. All other egress traffic must be blocked.
Task:
- Create a default deny egress NetworkPolicy called
default-deny-egressin therestrictednamespace - Create a NetworkPolicy called
allow-dns-and-internalthat allows all pods in therestrictednamespace to send DNS traffic (UDP and TCP on port 53) and communicate with any pod within the same namespace
Question 5 -- Fix CIS Benchmark Failures (API Server)
Difficulty: Hard
Scenario: A security audit has found the following issues with the API server configuration:
- Anonymous authentication is enabled
- Profiling is enabled
- The
AlwaysAdmitadmission plugin is enabled - The
NodeRestrictionadmission controller is not enabled
Task: Fix all four issues by editing the API server static pod manifest at /etc/kubernetes/manifests/kube-apiserver.yaml. Ensure the API server restarts successfully after your changes.
Question 6 -- Fix Kubelet Security Configuration
Difficulty: Medium
Scenario: The kubelet on the worker node has the following security issues:
- Anonymous authentication is enabled
- Authorization mode is set to
AlwaysAllow - The read-only port (10255) is enabled
Task: Fix the kubelet configuration at /var/lib/kubelet/config.yaml to:
- Disable anonymous authentication
- Set authorization mode to
Webhook - Disable the read-only port
- Restart the kubelet service
Question 7 -- Configure Encryption at Rest
Difficulty: Hard
Scenario: Secrets stored in etcd are currently not encrypted. The security team requires all secrets to be encrypted at rest using AES-CBC encryption.
Task:
- Generate a 32-byte encryption key
- Create an EncryptionConfiguration at
/etc/kubernetes/enc/encryption-config.yamlthat encrypts secrets usingaescbc - Configure the API server to use this encryption configuration
- Create a test secret called
test-secretin thedefaultnamespace to verify encryption is working - Verify that the secret is encrypted in etcd
Question 8 -- Check and Rotate Certificates
Difficulty: Medium
Scenario: You need to audit the TLS certificates on the control plane and identify any that will expire within 30 days.
Task:
- Check the expiration dates of all Kubernetes certificates using
kubeadm - Use
opensslto inspect the API server certificate and identify its Subject Alternative Names (SANs) - Renew the API server certificate using
kubeadm
Question 9 -- Create RBAC for Developer User
Difficulty: Medium
Scenario: A new developer named sarah needs access to the development namespace. She should be able to:
- Get, list, and watch pods, services, and deployments
- Create and delete pods
- View pod logs
- She should NOT be able to access secrets or exec into pods
Task:
- Create a Role called
developerin thedevelopmentnamespace with the appropriate permissions - Create a RoleBinding called
sarah-developerbinding the role to usersarah
Question 10 -- Audit Dangerous RBAC Permissions
Difficulty: Hard
Scenario: A security audit has flagged several RBAC configurations as potentially dangerous. You need to investigate and remediate.
Task:
- Find all ClusterRoleBindings that reference the
cluster-adminClusterRole - Check if any user named
internhas been grantedcluster-adminaccess - If found, remove the ClusterRoleBinding granting
interncluster-admin access - Create a new ClusterRole called
read-only-allthat grants onlyget,list,watchon all resources (excluding secrets) - Bind this new role to user
internwith a ClusterRoleBinding calledintern-readonly
Question 11 -- Secure Service Account
Difficulty: Medium
Scenario: The web-app deployment in the production namespace uses the default service account. The pods do not need to communicate with the Kubernetes API.
Task:
- Create a new ServiceAccount called
web-app-sain theproductionnamespace withautomountServiceAccountToken: false - Update the
web-appdeployment to use this new service account - Verify that no service account token is mounted in the pods
Question 12 -- Configure Audit Logging
Difficulty: Hard
Scenario: The security team requires audit logging on the API server with the following policy:
- Log nothing for requests to endpoints and services
- Log at
Metadatalevel for secrets and configmaps - Log at
RequestResponselevel for pods - Log everything else at
Requestlevel
Task:
- Create an audit policy file at
/etc/kubernetes/audit/audit-policy.yaml - Configure the API server to use this audit policy and write logs to
/var/log/kubernetes/audit/audit.log - Set maximum log age to 30 days, max backup to 10, and max size to 100 MB
- Ensure proper volume mounts are added to the API server manifest
Question 13 -- Create TLS Ingress
Difficulty: Medium
Scenario: The webapp-service in the production namespace needs to be exposed externally via an Ingress with TLS.
Task:
- Generate a self-signed TLS certificate for the hostname
webapp.example.com - Create a TLS secret called
webapp-tlsin theproductionnamespace - Create an Ingress resource called
webapp-ingressthat:- Uses the
nginxingress class - Terminates TLS using the
webapp-tlssecret - Routes traffic for
webapp.example.comtowebapp-serviceon port 80 - Forces HTTPS redirect
- Uses the
Question 14 -- Fix etcd TLS Configuration
Difficulty: Medium
Scenario: The etcd configuration has been tampered with and --client-cert-auth has been set to false, meaning etcd is not requiring client certificate authentication.
Task:
- Inspect the current etcd manifest at
/etc/kubernetes/manifests/etcd.yaml - Ensure
--client-cert-auth=trueis set - Ensure
--peer-client-cert-auth=trueis set - Verify etcd health after the changes
Question 15 -- Combined Network Policy Challenge
Difficulty: Hard
Scenario: In the microservices namespace, you have three tiers:
- Frontend pods (
tier=frontend) that receive external traffic on port 443 - Backend pods (
tier=backend) that listen on port 8080 - Database pods (
tier=database) that listen on port 5432
The rules are:
- Frontend can receive traffic from anywhere and can communicate with backend
- Backend can only receive from frontend and can communicate with database
- Database can only receive from backend and cannot initiate any outbound connections
- All pods need DNS access
Task: Create the complete set of NetworkPolicies to implement this architecture. You will need at minimum 4 policies (default deny + one per tier).
Question 16 -- Secure API Server Authorization
Difficulty: Easy
Scenario: The API server is currently configured with --authorization-mode=AlwaysAllow. This is a critical security vulnerability.
Task: Change the API server authorization mode to Node,RBAC by editing the static pod manifest. Verify the API server restarts successfully.
Question 17 -- Backup etcd Securely
Difficulty: Medium
Scenario: You need to create a secure backup of the etcd database.
Task:
- Take an etcd snapshot and save it to
/tmp/etcd-backup-$(date +%Y%m%d).db - Verify the snapshot integrity
- Set file permissions to
600and ownership toroot:rooton the backup file
Question 18 -- Certificate Signing Request
Difficulty: Medium
Scenario: A new team member alex needs kubectl access to the cluster. You need to create a certificate for them and approve it through the Kubernetes CSR API.
Task:
- Generate a private key for user
alex - Create a CSR with subject
/CN=alex/O=development - Submit the CSR to Kubernetes
- Approve the CSR
- Retrieve the signed certificate
Question 19 -- Comprehensive Cluster Hardening
Difficulty: Hard
Scenario: You have been asked to perform a comprehensive security hardening of the cluster. Multiple issues need to be addressed.
Task:
- Ensure the API server has
--anonymous-auth=false - Ensure
--authorization-mode=Node,RBAC - Ensure
--enable-admission-pluginsincludesNodeRestriction - Ensure
--profiling=false - Ensure encryption at rest is configured for secrets
- Create a default deny NetworkPolicy in the
kube-systemnamespace for ingress - Ensure the default service account in
kube-systemhasautomountServiceAccountToken: false
Question 20 -- Investigate and Fix Security Issues
Difficulty: Hard
Scenario: A penetration test has revealed several security issues in your cluster. You have a report that identifies:
- A ClusterRoleBinding
legacy-bindinggives the service accountdefault:defaultcluster-admin access - The
stagingnamespace has no network policies - A Role in the
stagingnamespace calledtoo-permissivegrants*verbs on all resources - The API server insecure port is not explicitly disabled
Task: Remediate all four issues:
- Delete the dangerous ClusterRoleBinding
- Create a default deny ingress and egress NetworkPolicy in
staging - Modify the
too-permissiverole to only allowget,list,watchonpods,services, anddeployments - Ensure
--insecure-port=0is set in the API server manifest (for Kubernetes versions where this flag exists)