Running Cellery on top of Kind (Kubernetes IN Docker)

Sinthuja Suhothayan
wso2-cellery
Published in
7 min readOct 14, 2019

We have seen how to run Cellery in K3S at my previous post, and this article I am going to explain how Cellery can be deployed in Kind(Kubernetes IN Docker). Before going into the details on how to deploy and run Cellery on top of Kind, it is worth to understand what is Cellery and Kind. If you already knew about these, directly jump into the steps :) .

What is Cellery?

Cellery is a code-first approach to building, integrating, running and managing composite applications on Kubernetes. Build, push/pull, test, deploy, update, scale and observe cells. Create secure APIs by default. Use your existing container images, written in any language.

For more information about Cellery please read this article.

What is Kind (Kubernetes IN Docker)?

Kind is a tool for running local Kubernetes clusters using Docker container “nodes”. Kind is primarily designed for testing Kubernetes 1.11+, initially targeting the conformance tests. It’s very convenient to deploy Cellery on top of Kind for local deployments, therefore the users can easily prepare their development environment without any hassle.

OK, enough talking, let’s get started! :)

Steps to deploy Cellery on Kind

To deploy Cellery on Kind, first the k8s cluster should be created with kind, and should sure the kubectl is pointing to the correct cluster. Secondly, deploy Cellery on the kind’s k8s cluster as an existing cluster. Below are the detail steps of performing these actions.

  1. Create Kubernetes Cluster with Kind
  • Install Kind as mentioned here.
  • Cellery can be installed in Basic or Complete package as explained here. If you are going to deploy basic package, you will need at least 2 CPU, and 4GB memory allocated for the docker. If you are going to deploy Complete package, you will need 4 CPUs and 8GB memory allocated in docker as shown below.
Resource allocation for docker when deploying Cellery with complete package.
  • Both Basic and Complete packages can be installed in persistence mode or non-persistence mode. If persistence mode is enabled then, you can have the state of the Cellery deployment persisted including published APIs, observability data, etc. Otherwise, those information will be lost when the Kind cluster is created each time. First, let’s clone the github repository which has required resources as shown below. Clone the github repository in any preferred location. We refer this location as $GITHUB_CLONE_DIRECTORY.
$ git clone https://github.com/sinthuja/cellery-deployment 

To deploy Cellery with persistence mode, execute below steps when creating kind’s k8s cluster.

  • Create directory named cellery, and then apim_repository_deployment_server and mysql as sub directories of cellery as shown below. These directories will be mounted to the kubernetes cluster that we are going to create with kind.
$ cd $GITHUB_CLONE_DIRECTORY/kind$ mkdir cellery$ cd cellery$ mkdir apim_repository_deployment_server$ mkdir mysql
  • Go to $GITHUB_CLONE_DIRECTORY/kind/cellery-persistence-config.yaml file, and replace $GITHUB_CLONE_DIRECTORY with absolute path of your cloned directory. Note: the cellery directory created above is mentioned as the hostPath.
  • Now start the Kind cluster named cellery as shown below. First, go into directory $GITHUB_CLONE_DIRECTORY and create the cluster with the above configuration you modified.
$ cd $GITHUB_CLONE_DIRECTORY$ kind create cluster --config kind/config/cellery-persistence-config.yamlCreating cluster "kind" ...
✓ Ensuring node image (kindest/node:v1.15.3) 🖼
✓ Preparing nodes 📦
✓ Creating kubeadm config 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
Cluster creation complete. You can now use the cluster with:
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
kubectl cluster-info

To deploy Cellery with non-persistence mode, execute below command without passing the config parameter.

$ kind create clusterCreating cluster "kind" ...
✓ Ensuring node image (kindest/node:v1.15.3) 🖼
✓ Preparing nodes 📦
✓ Creating kubeadm config 📜
✓ Starting control-plane 🕹️
✓ Installing CNI 🔌
✓ Installing StorageClass 💾
Cluster creation complete. You can now use the cluster with:
export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"
kubectl cluster-info

Now, let’s make the kubectl client to point the kind cluster. For that execute below command. Please make sure to export the KUBECONFIG environment variable again if you switch to a different terminal as this will only alter the current terminal’s environmental variable.

$ export KUBECONFIG="$(kind get kubeconfig-path --name="kind")"# Verify whether kubectl is correctly working, let's check the 
# cluster info
$ kubectl cluster-info

2. Deploy Cellery on top of Kind k8s cluster

  • Install cellery to your machine as shown here, and confirm with cellery -version command to check the installation.
$ cellery versionCellery:
CLI Version: 0.4.0
OS/Arch: darwin/amd64
Ballerina:
Version: 0.991.0
Kubernetes
Server Version: v1.15.3
Client Version: v1.14.3
CRD: true
Docker:
Server Version: 19.03.2
Client Version: 19.03.2
  • Go to Cellery setup > Create > Existing Cluster > Persistent Volume (Yes/No) > Basic | Complete > Node Port. Here if you have selected persisted volume, then you should have create the config and used it when you are spawning the kind’s cluster as shown above.
$ cellery setup
✔ Create
✔ Existing cluster
✔ Persistent volume
✔ No
✔ Complete
✔ Node port [kubeadm, minikube]
? NodePort Ip address: [Press enter to use default NodePort ip address]
✔ Creating cellery runtime
✔ Setting up cellery namespace
✔ Applying istio crds
✔ Creating ingress-nginx
✔ Enabling istio injection
✔ Installing istio
✔ Creating controller
✔ Configuring mysql
✔ Creating ConfigMaps
✔ Creating Persistent Volume
✔ Adding apim
✔ Adding observability
✔ Checking cluster status...
✔ Cluster status...OK
✔ Checking runtime status (Istio)...
✔ Runtime status (Istio)...OK
✔ Checking runtime status (Cellery)...
✔ Runtime status (Cellery)...OK
✔ Successfully installed Cellery runtime.What's next ?
======================
To create your first project, execute the command:
$ cellery init
  • Kind currently exposes only a single Docker port to the host machine (the Kubernetes API server). To overcome this limitation we proxy the ports to the local machine with another set of containers running on the same level as the kind node(s). Let’s expose the Ingress NodePorts by creating two instances of socat for port 80 and 443 respectively.
$ cd $GITHUB_CLONE_DIRECTORY/kind$ ./kind-proxy.sh
  • Now execute below to check whether load balancer is reachable, and you should get 404 as response code.
$ curl -k https://localhost
default backend - 404
  • Go to /etc/hosts and add the below mentioned host entries.
127.0.0.1 wso2-apim wso2-apim-gateway cellery-k8s-metrics idp.cellery-system pet-store.com hello-world.com my-hello-world.com my-hipstershop.com cellery-dashboard wso2sp-observability-api

Run Pet-store application in Cellery

Let’s run the pet-store application on the newly deployed Cellery runtime.

  • Execute below step which pulls the cell image from cellery hub and run it.
$ cellery run wso2cellery/pet-fe-cell:latest -n pet-fe -l petStoreBackend:pet-be -d
  • Once the cell is deployed, access the URL : http://pet-store.com to use the pet-store. Login to the pet-store with username: admin, and password: admin, and purchase some accessories.
  • Now you can open and use the cellery dahboard to see observability data, if you have deployed Complete package of Cellery. Refer attached screenshots of the observability data.

That’s it! You are all set with your development environment to play with Cellery! :)

You can go to samples and try more use cases with this deployment.

Clean up

  • Run cellery setup > Manage > Existing Cluster > Cleanup.
$ cellery setup
✔ Manage
✔ Existing cluster
✔ cleanup
✔ Yes
✔ Yes
✔ Yes
✔ Yes
✔ Cleaning up cluster
  • Execute below commands to remove the kind’s kubernetes cluster.
$ kind delete cluster

Conclusion

It is very easy to create a kubernetes cluster with Kind, and you just need docker installation in your machine. Cellery will work with any kubeternetes cluster, and hence once we get the kubectl on host machine to point to the intended kind’s k8s cluster, you just need to execute a single command to install Cellery.

Note, I have used Kind version 0.5.1, and Cellery version 0.4.0 to tryout and the instructions provided above is based on those versions.

It is time to try more on Cellery, visit below links to get more ideas about it.

--

--