Using a Dynamic Admission Controller with Kubernetes

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

In Kubernetes, dynamic admission controllers let us validate or otherwise change the request objects for creating resources. Most often, these are webhooks that are deployed with Kubernetes itself. In this lab, we create and register one of these webhooks within our Kubernetes cluster.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Deploy Webhook

Create a Kubernetes deployment for the label-add-webhook webhook container. Deploy the webhook.

Register Controller

Register the deployed webhook as an admission controller.

Test

Run the test Pod and ensure the label has been added.

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 but is lacking deployment and registration configurations for use with Kubernetes. Write these configurations.

Before You Start

The image for the webhook is linuxacademycontent/k8s-label-add-webhook:1.0. It listens on port 8443.

Another webhook has been provided as an example.

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?