Deploy your Kubernetes applications easily with Cellery

Mirage Abeysekara
wso2-cellery
Published in
3 min readNov 2, 2019

So you have an application ready to be deployed into a Kubernetes cluster and you want to do it in an easy way, that’s Great! In this article, we are going to deploy a Todo application using standard Kubernetes YAML’s and compare it by deploying the same application using Cellery.

In our very simple Todo application, we have a single todo service which provides add/update/list for todos and a MySQL database.

Deploying the Todo application using standard Kubernetes YAML’s

Prerequisite

  • Kubernetes cluster with an ingress controller
  • Some knowledge in Kubernetes

Deploying MySQL

Create a SQL initialization ConfigMap which is used for populate SQL schema.

kubectl apply -f https://gist.githubusercontent.com/Mirage20/10583417525b9a2ec8bb4fe13493ac1a/raw/8ed025b8a8454674e439d5090a9cb9517a8060aa/todos-mysql-init-sql.yaml

Create the MySQL deployment

kubectl apply -f https://gist.githubusercontent.com/Mirage20/9b08567f384eeb1d5950cb5358e37ad7/raw/ae057323bd5766dcc18469252ae54bd0786ec7c9/todos-mysql-db-deployment.yaml

Create the service for the MySQL deployment

kubectl apply -f https://gist.githubusercontent.com/Mirage20/c1e21da28c0d617c1db3c01b91afbbaa/raw/ea644197062631c6c75f70f6f69c947f63aad3f0/todos-mysql-db-service.yaml

Now our MySQL deployment should run properly. Run kubectl get pods and verify whether the MySQL pod is running.

Deploying Todo Service

Create a Secret containing MySQL credentials for our todo service

kubectl apply -f https://gist.github.com/Mirage20/33e19a96754319f839745c321a18f4c4/raw/5412527946571b6c71dd5c213a50d864a5f615a4/todos-db-credentials.yaml

Create Todo service deployment and service by running the following two commands

kubectl apply -f https://gist.github.com/Mirage20/0b2d3f555dc8b6f89717b30994506d22/raw/8b170e09352bfdf39ecc8a266e3e4387ed1a6c46/todos-deployment.yaml
kubectl apply -f https://gist.github.com/Mirage20/cce4287d0e11bc2b5325c667de6f0c84/raw/d4c3cb32fcceff8167eab57913b43dbbc610125d/todos-service.yaml

We need an ingress in order to expose our application and test it. Create a ingress by running the following command

kubectl apply -f https://gist.github.com/Mirage20/07ce7ade3912846d351d12cfec3cd112/raw/ceae42b20da553ce493937771b33888097f4fdb6/todo-app-ingress.yaml

Run kubectl get pods verify our two pods are in running state. Once all in running state, run kubectl get ing todo-app-ingress to get our IP address and hostname to invoke the service. The command should output something similar to following,

NAME               HOSTS          ADDRESS         PORTS   AGE
todo-app-ingress todo-app.org 172.17.17.101 80 40h

Invoke our service by running the following command, (make sure to replace the IP address)

curl http://172.17.17.101/todos -H "Host: todo-app.org"

You should get an output similar to this

[
{
"id": 1,
"title": "Walk",
"content": "Walk for 30 min around 6 PM",
"done": false
},
{
"id": 2,
"title": "Pay Bills",
"content": "Pay electricity and water bills",
"done": false
}
]

Deploying Todo application using Cellery

Now, if you follow this far, you will understand that’s quite a bit of YAML’s you have to write and maintain in order to deploy our simple application. By using Cellery, you can wrap your entire application into Cells and deploy them into the Kubernetes cluster.

Prerequisite

  • Kubernetes cluster with Cellery installed (See Quick Setup Guide for more information)

For our sample, we can use a single cell to deploy our application. Run the following command to deploy our todo service as a cell and expose it via the ingress.

kubectl apply -f https://gist.github.com/Mirage20/3c499885acc950fa7406d8d97c30889b/raw/c7634455a0362b5f0900133928f46dda8df0bacb/todo-app.yaml

Once you verify the pods are running, get the IP and hostname by running kubectl get ing todo-app-ingress invoke the service by running following command,

curl http://172.17.17.101/todos -H "Host: todo-app.org"

You should see the same response output as above.

Yes, that's all you need in order to deploy our application with Cellery. Of course, this is only a small benefit you can get when you using Cellery. But Cellery can offer a lot more than that. For example, Cellery has built-in application monitoring, security, API Management, scale-to-zero (if necessary) support for your applications. Further, if you hate YAML’s, Cellery offers writing deployments using Ballerina programming language. See Why Cellery is code-first? blog for more information.

See Cellery Kubernetes API Overview for more information about writing Cellery YAML’s

If you are interested in Cellery or have any questions, say hi to the community Slack channel and follow us on Twitter.

--

--