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.
Successfully complete this lab by achieving the following learning objectives:
- Lab Setup
Move to the
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).
lab-setup.shscript. (Note: This script will run for about 10–15 minutes.)
- Create the Webhook Docker Image
Note: Make sure you have set up your Docker Hub account before doing this objective.
Move into the
Log in to Docker Hub from the command line.
Makefilewith 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.
- Deploy the Mutating Webhook Configuration and Webhook
Update the deployment configuration with your Docker Hub username.
Initialize the working directory.
Apply the configuration.
- Test the Mutating Admission Webhook
Create a directory called
Move into to
Use the sample Terraform code to create two test Pods called
test-app-2, and add a label called
hello = "universe"to
Initialize your working directory.
Apply the webhook configuration.
Confirm that your mutating webhook is working:
test-app-1should have a
hello=worldlabel, even though one was not provided in the configuration.
test-app-2should have a
hello=universelabel, as you defined in the configuration.