Testing a Dynamic Admission Controller for Kubernetes

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Kubernetes dynamic admission controllers let us validate or mutate our Kubernetes request objects to either approve, deny, or change the object upon creation. In this hands-on lab, we review a provided admission controller that add labels to a resource and then create the needed configuration to test it. We’ll also see if we can update the deployment code to use our own labels.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Update Deployment

Update the deployment to use the desired labels when the webhook is run.

Create Test Resources

Create a test pod and test deployment.

Test

Deploy the webhook and test.

Additional Resources

Scenario

You are a DevOps engineer setting up admission controller webhooks for your Kubernetes clusters. One such webhook, the label-add-webhook, adds labels to all new resources, which can be designated in the deployment configuration of the webhook. Create two test resource configurations for the webhook, and update the provided labels in the deployment so the env is prod and the team is dev.

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?