Setting up a Kubernetes cluster
Note that this guide is only helpful in setting up a development environment; this setup is not recommended for a production environment.
#
Prerequisites- You have a Kubernetes cluster setup, this could for example be a minikube cluster.
- You have admin privileges to the cluster, since the Operator installation is only possible with an admin user.
#
Enabling IngressTo access an application externally, you will create URLs using odo, which are implemented on a Kubernetes cluster by Ingress resources; installing an Ingress controller helps in using this feature on a Kubernetes cluster.
Minikube: To install an Ingress controller on a minikube cluster, enable the ingress addon with the following command:
minikube addons enable ingress
To learn more about ingress addon, see the documentation on Kubernetes website.
Other Kubernetes Cluster: To enable the Ingress feature on a Kubernetes cluster other than minikube, using the NGINX Ingress controller see the official NGINX Ingress controller installation documentation.
To use a different controller, see the Ingress controller documentation.
To learn more about enabling this feature on your cluster, see the Ingress prerequisites on the official kubernetes documentation.
#
Installing the Operator Lifecycle Manager (OLM)The Operator Lifecycle Manager(OLM) is a component of the Operator Framework, an open source toolkit to manage Kubernetes native applications, called Operators, in a streamlined and scalable way. (Source)
What are Operators?
The Operator pattern aims to capture the key aim of a human operator who is managing a service or set of services. Human operators who look after specific applications and services have deep knowledge of how the system ought to behave, how to deploy it, and how to react if there are problems.
People who run workloads on Kubernetes often like to use automation to take care of repeatable tasks. The Operator pattern captures how you can write code to automate a task beyond what Kubernetes itself provides. (Source)
To install an Operator, we will first need to install OLM (Operator Lifecycle Manager) on the cluster.
curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.18.3/install.sh | bash -s v0.18.3
Running the script will take some time to install all the necessary resources in the Kubernetes cluster including the OperatorGroup
resource.
Note: Check the OLM release page to use the latest version.
#
Installing the Service Binding Operatorodo uses Service Binding Operator to provide the odo link
feature which helps to connect an odo component to a service or another component.
Operators can be installed in a specific namespace or across the cluster(i.e. in all the namespaces).
kubectl create -f https://operatorhub.io/install/service-binding-operator.yaml
Running the command will create the necessary resource in the operators
namespace.
If you want to access this resource from other namespaces as well, add your target namespace to .spec.targetNamespaces
list in the service-binding-operator.yaml
file before running kubectl create
.
See Verifying the Operator installation to ensure that the Operator was installed successfully.
#
Installing an OperatorTo install an operator from the OperatorHub website:
- Visit the OperatorHub website.
- Search for an Operator of your choice.
- Navigate to its detail page.
- Click on Install.
- Follow the instruction in the installation popup. Please make sure to install the Operator in your desired namespace or cluster-wide, depending on your choice and the Operator capability.
- Verify the Operator installation.
#
Verifying the Operator installationWait for a few seconds for the Operator to install.
Once the Operator is successfully installed on the cluster, you can use odo
to verify the Operator installation and see the CRDs associated with it; run the following command:
odo catalog list services
The output can look similar to:
$ odo catalog list servicesServices available through OperatorsNAME CRDsdatadog-operator.v0.6.0 DatadogAgent, DatadogMetric, DatadogMonitorservice-binding-operator.v0.9.1 ServiceBinding, ServiceBinding
If you do not see your installed Operator in the list, follow the troubleshooting guide to find the issue and debug it.
#
Troubleshooting the Operator installationThere are two ways to confirm that the Operator has been installed properly. The examples you may see in this guide use Datadog Operator and Service Binding Operator.
Verify that its pod started and is in “Running” state.
kubectl get pods -n operators
The output can look similar to:
$ kubectl get pods -n operatorsNAME READY STATUS RESTARTS AGEdatadog-operator-manager-5db67c7f4-hgb59 1/1 Running 0 2m13sservice-binding-operator-c8d7587b8-lxztx 1/1 Running 5 6d23h
Verify that the ClusterServiceVersion (csv) resource is in Succeeded or Installing phase.
kubectl get csv -n operators
The output can look similar to the following:
$ kubectl get csv -n operatorsNAME DISPLAY VERSION REPLACES PHASEdatadog-operator.v0.6.0 Datadog Operator 0.6.0 datadog-operator.v0.5.0 Succeededservice-binding-operator.v0.9.1 Service Binding Operator 0.9.1 service-binding-operator.v0.9.0 Succeeded
If you see the value under PHASE column to be anything other than Installing or Succeeded, please take a look at the pods in
olm
namespace and ensure that the pod starting with nameoperatorhubio-catalog
is in Running state:$ kubectl get pods -n olmNAME READY STATUS RESTARTS AGEoperatorhubio-catalog-x24dq 0/1 CrashLoopBackOff 6 9m40s
If you see output like above where the pod is in CrashLoopBackOff state or any other state other than Running, delete the pod:
kubectl delete pods/<operatorhubio-catalog-name> -n olm