Exam CKS Topic 1 Question 19 Discussion

Actual exam question for Linux Foundation's CKS exam
Question #: 19
Topic #: 1
You have a Pod that runs an application that accesses a database service running in a different namespace. You want to enforce a rule that only allows the pod to connect to the database service on a specific port. Explain how to achieve this using NetworkPolicy.

Suggested Answer:

Solution (Step by Step) :
1. Create a NetworkPolicy:
- Create a ' NetworkPoIicV resource that defines the rules for the pod.
- This example allows the pod to connect to the database service on port 5432 in the 'database-namespace namespace.

2. Apply the NetworkPolicy: - Apply the 'NetworkPolicy' using 'kubectl apply -f database-access-policy.yaml 3. Verify the Policy: - Run the application in the pod and attempt to connect to the database service on the specified port- - Verify that the connection is successful. - Attempt to connect to the database service on a different port or from a different namespace. - Verity that these attempts are blocked.

by Harriet at May 04, 2026, 03:28 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