hands-on lab

Using Security Contexts to Secure Kubernetes Clusters

Up to 40m
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.


There are many facets to security in Kubernetes. One small oversight can leave your cluster vulnerable to leaking sensitive data, running foreign workloads, and a host of other attacks. This lab shows you how to practice defense in depth in Kubernetes by covering a key security concept: security contexts. Examples of potential exploits from improperly configured clusters are also illustrated followed by guidance on how to prevent the attacks.

This lab is valuable to anyone working with Kubernetes, but the content has been prepared considering topics described in the Certified Kubernetes Administrator (CKA) Exam Curriculum. Completion of the lab will help you get hands-on experience, which is essential for passing the CKA exam.

Learning Objectives

Upon completion of this lab you will be able to:

  • Use pod and container security contexts to harden your environments

Intended Audience

  • Kubernetes cluster administrators
  • Certified Kubernetes Administrator (CKA) examinees


You should be familiar with:

  • Working with Kubernetes to deploy applications
  • Working at the command line in Linux

The following labs can be used to fulfill the prerequisites: Deploy a Stateless Application in a Kubernetes Cluster.


October 13th, 2023 - Updated Kubernetes to 1.28

June 13th, 2023 - Updated Kubernetes to 1.26

Environment before

Environment after

About the author

Bhupinder Singh
Lab Operations Specialist

Bhupinder is a Lab Operations Specialist with experience in Cloud Support and IT admin roles. He currently holds the AWS Solutions Architect Professional, AWS Solutions Architect Associate, and HashiCorp Certified Terraform Associate certifications. He enjoys learning about business processes and optimizing communication.

Covered topics

Lab steps

Connecting to the Kubernetes Cluster
Using Kubernetes Security Contexts