- Prerequisites
- Overview
- Change Directory
- Copy License
- Deploy the Layer7 Operator
- Tail the Layer7 Operator Logs
- Deploy a Layer7 API Gateway
- Inspect Resources
- Inspect the Gateway Custom Resource
- Update the Gateway Custom Resource
- Remove the Gateway Custom Resource
Please make sure you've completed the steps here before beginning this exercise.
Kubernetes operators automate tasks traditionally performed by a human operator of an application. Kubernetes operators should have the same level of deployment, behavior and troubleshooting expertise as a human operator when automating those tasks.
Kubernetes operators are Kubernetes extensions created using the Operator SDK. They make use of custom resources to manage applications and their components adhering to the Kubernetes principle of control loops. A control loop constantly observes the desired state of resources, analyzes the actual state of those resources, and executes actions to synchronize the current state with the desired state as necessary.
The Layer7 Operator has expert knowledge of Layer7 products, and in the preview release, it makes use of Gateway and Repository custom resources to automate the deployment, configuration and management of Layer7 API Gateways using static or dynamic config-as-code in the form of Graphman bundles from different sources of truth including git repositories or artifact repositories (or optionally backed by a MySQL database).
In this exercise, we will deploy the Layer7 Operator. We will then deploy a Gateway custom resource to deploy and scale a Gateway using the Layer7 Operator.
Assuming that you're currently in the folder you created for the workshop, and you've downloaded and uncompressed the labs repository to that folder, then change to the labs repository folder now:
cd cloud-workshop-labs-main
Copy the Gateway v11.x license file (license.xml) to ./exercise2-resources/
Linux/MacOS
cp ../license.xml ./exercise2-resources
Windows
copy ..\license.xml .\exercise2-resources
This lab will deploy the Layer7 Operator using kubectl
commands. It can also be deployed using Helm, Operator Hub and Openshift.
Linux/MacOS
kubectl apply -f ./layer7-operator/rbac.yaml
kubectl apply -f ./layer7-operator/operator.yaml
Windows
kubectl apply -f layer7-operator\rbac.yaml
kubectl apply -f layer7-operator\operator.yaml
We can watch what the Layer7 Operator is doing to manage custom resources by watching its logs.
Open up a new terminal to tail the Layer7 Operator logs.
Note: You may have to set your KUBECONFIG environment variable in the new terminal.
kubectl logs -f -l control-plane=controller-manager -c manager
We can tell the Layer7 Operator to deploy a Layer7 API Gateway by creating a new Gateway custom resource that describes the Layer7 API Gateway deployment to the Layer7 Operator.
First, create a Kubernetes secret with your Gateway v11.x license:
Linux/MacOS
kubectl create secret generic gateway-license --from-file=./exercise2-resources/license.xml
Windows
kubectl create secret generic gateway-license --from-file=exercise2-resources\license.xml
Then, create a Gateway custom resource (or CR). Be sure to watch the Layer7 Operator's logs as you do this:
Linux/MacOS
kubectl apply -f ./exercise2-resources/gateway.yaml
Windows
kubectl apply -f exercise2-resources\gateway.yaml
Inspect the resources that the Layer7 Operator created:
kubectl get all
Inspect the Gateway custom resource, and notice how its status has been updated by the Layer7 Operator:
kubectl get gateways
kubectl get gateway ssg -oyaml
Now lets make a change to the Gateway custom resource to see how the Layer7 Operator responds. Let's update its replicas from 1 to 2 to deploy a second Gateway:
kubectl edit gateway ssg
Change replicas: 1
to replicas: 2
, and save and exit the editor.
Observe the second Gateway pod:
kubectl get pods
kubectl delete gateway ssg