Hey, Gurus! Welcome to this hands-on lab. In this lab, we will take what we have learned and build our Kubernetes operator.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- 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
- 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.
- 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.
- 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