- Lab
- A Cloud Guru
Create Your First Kubernetes Operator
Hey, Gurus! Welcome to this hands-on lab. In this lab, we will take what we have learned and build our Kubernetes operator.
Path Info
Table of Contents
-
Challenge
Create the Operator Project
- Create the operator project directory called
memcached-operator
in a directory calledprojects
. - Move into the operator project directory that you just created.
- Set your
GOPATH
and enable the Go modules. - Initialize your operator project directory.
- Create the operator project directory called
-
Challenge
Create the API and Controller
- Create the API and controller.
Note: Remember you will need to use additional flags for the memcached image as follows:
--plugins="deploy-image/v1-alpha" --image=memcached:1.4.36-alpine --image-container-command="memcached,-m=64,modern,-v" --run-as-user="1001"
- Edit the
api/v1alpha1/memcached_types.go
file. - Change the validation marker for the maximum nodes that can be run from
3
to5
. - Update the code.
- Generate the CRD manifests and RBAC manifests.
- Create the API and controller.
-
Challenge
Deploy the Operator
- Log in to Docker Hub from the command line.
- Create an enviroment variable for your image.
- Make the operator image.
- Push your operator image to Docker Hub.
- Deploy your operator image to the cluster.
- Verify that your image was deployed.
-
Challenge
Create the Memcached Custom Resource
- Create the memcached custom resource from the
cache_v1alpha1_memcached.yaml
sample file and change the size from1
to3
. - Apply your CR to the cluster.
- Verify the deployment.
- Edit the CR and change the size from
3
to5
. - Apply the changes to the CR.
- Verify the changes to test and complete the lab.
- Create the memcached custom resource from the
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.