How to master the Certified Kubernetes Security Specialist (CKS) CNCF program
First thing’s first: why CKS? Why do you need to study and obtain yet another Kubernetes certification? Let’s talk a step back. If you are into Kubernetes, CKA and CKAD are the two closely related certifications helping developers and DevOps teams to get acclimated to the world of Kubernetes; CKS is a different ball game. CKS leaps further to test the skills, knowledge, and proficiency on a broad range of best practices for securing container-based applications and Kubernetes platforms during build, deployment, and runtime. By the way, having the CKA certification is a mandatory requirement to take the CKS exam.
But why is security a critical topic when it comes to containers? Well, think about it this way: with traditional computing models, the Operating System (OS) offered a tightly-coupled architecture. Then, along came cloud, introducing a new world of “exposure” and a host of new security challenges with an additional layer to protect for (virtualization) and of course the attack surface that is now… “decentralized”. Containers are yet another abstraction. This time it is the operating system being virtualized to package only the required runtime for apps to run anywhere.
But in a microservice-based world, and as organizations are moving apps to containers - by just refactoring or even re-platforming them based on new microservice-based architectures, they have to skill up to face new security risks. This transition path is fraught with many perils encountering new threats at every step. Hence security has become a very crucial aspect.
CKS covers a comprehensive toolbox to help and bring that "awareness on all areas where security needs to be hardened for a Kubernetes based deployment." CKS is for all users in IT Operations, DevOps and platform teams that deal with Kubernetes across:
You will be examined in setting up clusters (10% exam weight), hardening them (15%) and their infrastructure (15%), securing microservice-based apps (20%), supply chain security (20%) and monitoring, logging and runtime security (20%). You will have 2 hours to complete 16 questions.
All the tools and features you need to know about
CKS is all about security carried through ecosystem tools/packages. There are 10 tools in total that anyone taking the exam will have to familiarize themselves with, and know how to use. Those are:
Runtime security tool based on rules
Application security framework used both for Linux and Kubernetes security
Open Policy Agent
Policy enforcement engine for Kubernetes
Validating webhook to enforce OPA policies in a Kubernetes cluster
Container sandbox to run pods securely
Image vulnerability scanner
Image vulnerability scanner
CIS Benchmarking for Kubernetes
Kubehunter [Optional but Good to Know]
Sonobuoy [Optional but Good to Know]
Tool to run e2e conformance tests on Kubernetes Cluster
Beyond the above 10 tools, there are important native Kubernetes concepts and features that you need to be comfortable with. Those are:
Access control to regulate access to resources at Cluster level and Namespace level
Policies to define how a pod can communicate with other pods and network entities
Pod Security Context
A security context defines privilege and access control settings for a Pod or Container
Set of policies to record different stages of events in Kubernetes cluster
Web based UI to monitor and manage Kubernetes cluster
Admission controller to limit the Node and Pod objects a kubelet can modify
Admission controller to enforce policies during image pull
Pod Security Policy
Admission controller to enforce different security controls on Kubernetes applications cluster-wide
Setting up a system to practice
One of the important questions is: where do you practice? In order to try out all the tools and utilities noted above we would need a minimum configuration of:
- 1 Control Plane
- 1 worker node with 1.19 Kubernetes cluster running on Ubuntu OS
Here’s a quick overview of the steps you need to take:
- Install Kubernetes 1.19 with one Control Plane and a worker
- Upgrade the setup to 1.20 using the Kubernetes document
- Enable Auditing on the Kubernetes cluster and add audit rules
- Install K8s dashboard on the cluster and secure it
- Enable Node Restriction Admission controller and verify the feature on the worker node
- Enable ImagePolicy Admission controller and test image pull using the kube-image-bouncer server.
- Download and run kubebench on the Control Plane node and worker node
- Use the cluster to try out network security policies and RBAC
- Download and run Sonobuoy conformance check on the cluster
- Install trivy and claire on the Control Plane node.
- Scan all the images that are available as part of the Kubernetes deployment
- Create a nginx pod with Dockerfile.
- Ensure that the pod does not run as root and has the minimum set of privileges
- Launch the pod with different Security contexts
- Install gVisor and launch the Nginx pod using gVisor
- Configure Apparmor on the system and run the nginx pod using an apparmor profile
- Install Seccomp, configure it to block syscalls and run the nginx pod using the seccomp profile
Important links and tips:
- You probably already know this one: https://www.cncf.io/certification/cks
- Killer Shell - CKS CKA CKAD Simulator and don’t forget to check this out: every user who registers for the CKS gets two killer shells for practice for free https://killer.sh/faq. The shells are super helpful to get a hands-on before the Exam. Keep one shell reserved for the day before the exam as it helps you warm up your K8s skills right before you need it the most! Also try their CKS playground here: https://github.com/surajssd/cks-playground
- All Kubernetes exams allow browsing the Kubernetes doc site, so might be useful to create a bookmark for all the core pages to save time during the exams.
Jq is a convenient tool for exams. Most of the security reports would be in JSON format that can be viewed with a text editor. JQ would help users extract just the piece of info they need with ease. To get the list of all pod names and the corresponding image used
kubectl get pods -n kube-system -o json | jq '.items.spec.containers | .name +" "+ .image'
A quick primer on jq can be found here:
Do not worry about setting up auto-completion, and it’s already set up for you.
Make use of it liberally. For example, an alias of k=kubectl would come in very handy.
Install and configure all the tools to get an excellent understanding of the deployment and configuration aspects of the tool. This comes in very handy for debugging tool issues in the exam.
Don’t forget to check out our January CKS webinar and recording and good luck!
K8s, Palette, our upcoming webinar, events, and much more!
We are using the information you provide to us to send you our montly newsletter. You may unsubscribe at any time.