This walkthrough will illustrate how simple it is to setup and manage Couchbase clusters using the Couchbase Operator within the Google Kubernetes Engine (GKE) on the Google Cloud Platform (GCP).
We will need a GCP account and then we will install glcoud.
We setup our environment with a single command (be sure to choose a default region):
gcloud init
Deploying a GKE cluster is straightfoward, using the command:
gcloud container clusters create mycluster --machine-type=n1-standard-4
Now we have to install and set up kubectl, so it can connect to the GKE cluster. Two commands will do that for us:
gcloud components install kubectl
gcloud container clusters get-credentials mycluster
We verify our kubectl with:
kubectl get nodes
We now see that three node are running:
GKE supports RBAC in order to limit permissions. Since the Couchbase Operator creates resources in our GKE cluster, we will need to grant it the permission to do so.
We do that with the following commands:
kubectl create clusterrolebinding cluster-admin-binding \
--clusterrole cluster-admin \
--user $(gcloud config get-value account)
kubectl create clusterrolebinding my-couchbase \
--clusterrole=cluster-admin \
--serviceaccount=default:default
Now that we have all the environment prerequisites in place, we are ready to deploy the Couchbase Operator.
We deploy the Couchbase Operator and then verify it with the following commands:
kubectl apply -f https://s3.amazonaws.com/packages.couchbase.com/kubernetes/beta/operator.yaml
kubectl get deployments
We now can see that the Couchbase Operator is deployed.
We are now in the final stretch!
Next we will create a Couchbase cluster with the following commands:
kubectl apply -f https://s3.amazonaws.com/packages.couchbase.com/kubernetes/beta/secret.yaml
kubectl apply -f https://s3.amazonaws.com/packages.couchbase.com/kubernetes/beta/couchbase-cluster.yaml
We should be able to see something like this:
We can view the all of the pods by running:
kubectl get pods
Now we have a Couchbase cluster running! To use the web console we will need setup port forwarding.
We do that with the kubectl command:
kubectl port-forward cb-example-0000 8091:8091
We need to make sure we leave the command running in the terminal:
Now we can open up a browser at http://localhost:8091
We will login using username=Administrator
and password=password
.
We are in! Click the 'Servers' link on the left side and we should see our clusters running.
Fin