- Lab
- A Cloud Guru
Create a Mutating Admission Controller Webhook with Terraform
In this lab, you will create and deploy a mutating webhook, along with its configuration. First, you will create the webhook Docker image from the provided code. Then, you will update the webhook deployment Terraform code with the image and deploy the mutating webhook. Next, you will apply the webhook registration code to finish up the deployment. Finally, you will create a couple of test Pods to confirm your mutating webhook is working as expected.
Path Info
Table of Contents
-
Challenge
Lab Setup
-
Move to the
mutating-admission-webhook
directory. -
Create an access key in the AWS Management Console. (You need to copy the Access key and Secret access key and keep them somewhere safe and accessible for the next step).
-
Make the
lab-setup.sh
script executable. -
Run the
lab-setup.sh
script. (Note: This script will run for about 10–15 minutes.)
-
-
Challenge
Create the Webhook Docker Image
Note: Make sure you have set up your Docker Hub account before doing this objective.
-
Move into the
mutating-webhook
directory. -
Log in to Docker Hub from the command line.
-
Update the
Makefile
with your Docker Hub username. -
Build the mutating webhook. (Note: This can take between 5–10 minutes.)
-
Build the Docker image.
-
Push the Docker image to Docker Hub.
-
Deploy the required certificates.
-
-
Challenge
Deploy the Mutating Webhook Configuration and Webhook
-
Update the deployment configuration with your Docker Hub username.
-
Initialize the working directory.
-
Apply the configuration.
-
-
Challenge
Test the Mutating Admission Webhook
-
Create a directory called
test-pods
. -
Move into to
test-pods
directory. -
Use the sample Terraform code to create two test Pods called
test-app-1
andtest-app-2
, and add a label calledhello = "universe"
totest-app-2
. -
Initialize your working directory.
-
Apply the webhook configuration.
-
Confirm that your mutating webhook is working:
test-app-1
should have ahello=world
label, even though one was not provided in the configuration.test-app-2
should have ahello=universe
label, as you defined in the configuration.
-
What's a lab?
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.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.