Designing a Dynamic Admission Controller for Kubernetes

45 minutes
  • 4 Learning Objectives

About this Hands-on Lab

Kuberenetes dynamic admission controllers allows you to validate or mutate your Kubernetes request objects to either approve or deny, or to change the object upon creation. In this hands-on lab, you will create a dynamic admission controller to add labels defined in the deployment file, as well as the needed deployment and registration configurations, and test nodes.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Write Webhook

Write a mutating webhook that adds labels to pods upon creation.

Refactor Webhook

Refactor the webhook so that the labels can be provided in the deployment code.

Deploy Admission Controller

Create the deployment and registration configurations and apply them.

Test Admission Controller

Run the webhook against a test pod.

Additional Resources

Scenario You are a DevOps engineer setting up admission controller webhooks for your Kubernetes clusters. You would like to create a mutating webhook that add labels to deployed pods with the ability to set which labels are used in the deployment file for the webhook, not coded into the webhook itself.

Create this webhook, deploy it, and set it up to use with Kubernetes.

You have the option to push and use your own Docker image or use linuxacademycontent/k8s-label-add-webhook:2.0, which has been provided for you.

Before You Start

To generate a cluster upon starting the lab, run aws configure, inputting the provided access and secret keys, as well as us-east-1 for the region (output format is user's choice). Next, run:

eksctl create cluster --name dev --region us-east-1 --nodegroup-name standard-workers --node-type t3.medium --nodes 1 --nodes-min 1 --nodes-max 1 --managed

It will take several minutes for the cluster to provision, when finished update the EKS configuration:

aws eks update-kubeconfig --name dev --region us-east-1

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?