Certified Kubernetes Administrator (CKA) Exercises, Network Policy, Namespace
I started preparation for the CKA Kubernetes exam. In this series, I will share some exercises I find useful during my preparation in order to help you better prepare for the CKA exam. I will gather all exercises in my github account, clone this repo to get all exercises at once.
CKA exercises series published posts:
- Network Policy
- Network Policy, Namespace
Prerequisites
-
Existing Kubernetes cluster
-
Kubernetes cluster with CNI supporting Network Policies, for example, Calico CNI
Install Calico CNI to EKS cluster example: https://docs.aws.amazon.com/eks/latest/userguide/calico.html
Environment Preparation
It’s an example of an application with backend/frontend separated with namespaces and admin namespace which need to have access to both namespaces (frontend and backend)
- web pod(frontend) needs to talk with api pod(backend).
- must be an access to web pod from all namespaces.
- admin needs to have access to web/api pods.
Create frontend namespace and deploy web pod into:
Create backend namespace and deploy api pod into:
Create admin namespace and deploy admin pod into:
Create test namespace and deploy test pod into:
This namespace/pod will be used for testing, no network policies will be installed to this namespace
Validate that connections between all pods in different namespaces permitted.
You must see ‘Welcome to nginx!’ reply in all cases.
Exercises
Deny all traffic from all namespaces. Create Network policy and deploy to frontend/backend/admin namespaces.
You must see ‘Connection timed out’ instead of ‘Welcome nignx’
Allow ingress in api pod from web pod. Create Network policy and deploy to backend namespace.
You must see ‘Welcome nignx’
Allow ingress to web pod from all namespaces. Create Network policy and deploy to frontend namespace.
You must see ‘Welcome nignx’
Allow ingress in api/web pods for admin pod. Modify network policy of api pod and deploy it to backend namespace.
You must see ‘Welcome nignx’
Solution
Deny traffic from all namespaces.
Allow ingress in api pod from web pod.
Allow ingress in web from all namespaces.
Allow ingress in api/web pods for admin pod.
You need add it to 2 (network policy for api), because web pod already allows ingress from all namespaces.
I will publish new posts of CKA exersises series first in my personal blog, and in this github account, please clone this repo so I would now it’s valuable to you and I will create more of exercises.
Please subscribe to my YT channel
Also follow me on medium and Twitter @warolv
My account on medium: warolv.medium.com