Exam CKAD Topic 4 Question 161 Discussion

Actual exam question for Linux Foundation's CKAD exam
Question #: 161
Topic #: 4
You have a Kubernetes cluster with a Deployment named 'my-app' that runs a web application. You want to restrict access to this application to only specific users within your organization. How would you use Service Accounts and RBAC to implement this?

Suggested Answer:

See the solution below with Step by Step Explanation.
Explanation:
Solution (Step by Step) :
1 . Create a Service Account:
- Create a new Service Account specifically for your application:

- Apply this YAML file using 'kubectl apply -f my-app-sa.yaml'. 2. Create a Role: - Define a Role that grants specific permissions to the Service Account. For example, you might want to grant read access to the Deployment's secrets:

- Apply this YAML file using 'kubectl apply -f my-app-reader.yaml' 3. Bind the Role to the Service Account: - Create a RoleBinding that associates the 'my-app-reader' Role with the 'my-app-sa' Service Account:

- Apply this YAML file using 'kubectl apply -f my-app-sa-binding.yaml' 4. Update the Deployment: - Update the 'my-app' Deployment to use the new Service Account:

- Apply the updated Deployment configuration using 'kubectl apply -f my-app.yaml'. 5. Verify: - Ensure that pods within the 'my-app' Deployment are running with the correct Service Account. You can use 'kubectl get pods -l app=my-app -o wide' to inspect the pod details. 6. Restricting Access to Specific Users: - To restrict access to the application to specific users within your organization, you would need to: - Configure a more granular Role to grant specific access levels (e.g., read-only, edit, etc.). - Use a Kubernetes authentication provider (such as OAuth2 or OpenID Connect) to authenticate and authorize users. - Bind the Role to the user's identity, ensuring they have the appropriate permissions. Important Note: This example provides a basic setup for RBAC with Service Accounts. In real-world scenarios, you might need to configure more complex RBAC rules to address your specific security requirements and user access control policies.]

by Lynn at Apr 30, 2026, 09:39 PM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10