Deploy an App into Kubernetes Even Faster (Than Last Week)

Introduction

Welcome back. This is the second blog in a series on Kubernetes. If you have not yet done so, please visit the previous blog to become familiar with basic Kubernetes concepts. In this post, we are going to explore automation tools that enable fast and repeatable deployment of arbitrarily complex applications. Automation tools that enable simple deployment of complex applications will also enable simple deployment of BIG-IP services. The application we will deploy is Joomla, an established content management system that has been adapted for containers. Joomla needs a database, so the deployment includes that as well. The first automation tool is Helm, which integrates well with Kubernetes. The second tool is Yipee.io, a commercial Software-as-a-Service offering that provides a visual method for deploying applications. Joomla will be deployed using each. Let’s get started.

Helm Overview

Helm is a tool that helps to manage dependencies for deploying more complex applications as a unit. If you have worked with a Linux package manager, such as apt or yum, you are familiar with the concept. Repositories exist to hold package definitions and dependency lists so that an operations professional can provision complex applications as pods into Kubernetes. As with other package managers, it also enables rapid removal of applications. 

Prepare Google Cloud

Before getting started, you need an account on the Google Container Engine: https://cloud.google.com/container-engine. The previous blog in this series covered setting up the account and a project and also getting to the Console, as well as creating a cluster. Before proceeding, ensure that your account has a project and cluster defined.

Install Helm

In order to use Helm, it needs to be installed into the virtual machine running the Google Cloud Shell.

Copy and paste the following commands into the Google Cloud Shell. First, get a copy of the Helm software.

 wget https://kubernetes-helm.storage.googleapis.com/helm-v2.4.1-linux-amd64.tar.gz

Extract the archive.

tar -xvf helm-v2.4.1-linux-amd64.tar.gz

Move the command to a bin directory on the path.

sudo mv linux-amd64/helm /usr/local/bin/

Get the credentials.

 gcloud container clusters get-credentials cluster-1 --zone us-central1-a

Start Helm and update the repository.

 helm init
 helm repo update

Now Helm is installed. The next step is to install a sample application.

Install Joomla via Helm

A common web application is a content management system (CMS) and a common CMS is Joomla. In this section, we will install a Joomla application, complete with the supporting database service. Since Joomla needs the services to operate, the entire deployment is treated as a single package and deployed as a pod.

Install Joomla.

 helm install --name my-joomla stable/joomla

Yes, it really is that simple. Joomla is now installed. You can see from the output of the command that there are still some steps to get the credentials. For now, look at the two pods created.

 kubectl get pods

To see the page, first display the URL.

 echo http://$(kubectl get svc --namespace default my-joomla-joomla -o jsonpath='{.status.loadBalancer.ingress[0].ip}')

Copy and paste the URL into a browser. You will need the credentials which can be found by copying and pasting the below commands into the Google Cloud Shell.

 echo Username: user
 echo Password: $(kubectl get secret --namespace default my-joomla-joomla -o jsonpath="{.data.joomla-password}" | base64 --decode)

Enter the credentials into the web page. You are now the administrator. Feel free to explore the Joomla application you deployed. When finished, let’s clean up.

 helm delete my-joomla --purge

That’s all there is to it. If you want to stop here, you should delete the cluster. Otherwise, the next section will deploy an application using a visual editor called Yipee.io.

Yipee.io Overview

In addition to being a clever name, Yipee.io is both a company and a service that enables visual design of container deployments for multiple environments, including Kubernetes. A developer can design an entire deployment without writing code. This service enables faster understanding of the deployment as well as rapid testing.

Create Cluster

If you retained the cluster from the Helm section, move on to the next section. Otherwise, create a cluster as shown in the previous blog in this series.

Yipee.io Account

To get started, set up an account on Yipee.io. Sign up for a free trial at https://yipee.io/ to perform the deployment in this section.

Using Yipee.io

Now that you have an account at Yipee.io, navigate to the Application Catalog.

Notice that you have several options, including creating your first app. Instead, let’s explore a public app that has already been defined. Click on the title of the Joomla app.

Here you will see the diagram of the Joomla application, containing two containers and four storage volumes.

If you wanted to make changes, you could copy to your own workspace and then edit the deployment. We will deploy it as defined. Download the configuration as a Kubernetes file.

Press the close button in the upper right.

If prompted, discard any changes.

Install Joomla via Yipee.io

We need to move the file to the Google Cloud Shell. Go to the Google Cloud Shell and type the following command (the command will not exit yet).

 cat > joomla-yio.yml

Then open the downloaded Yipee.io file with your favorite text editor and copy all of the text.

Next, paste that text into the Google Cloud Shell window.

Finally, press Control-D at the Google Cloud Shell. The command prompt should return. All we did here was move the text file for the Joomla application to a file where the Google Cloud Shell is running.

Before we deploy the application, we need to set some credentials environment variables to match the default credentials in the pod. These will be used as the default credentials for the first login.

 export MARIADB_ROOT_PASSWORD=squirrel 
 export JOOMLA_PASSWORD=bitnami

The envsubst command will encode the credentials into a new yaml file that will be used to deploy Joomla.

 envsubst < joomla-yio.yml > populated.yaml

As before, give kubectl permission to change the environment.

 gcloud container clusters get-credentials cluster-1 --zone us-central1-a

Next, deploy the application using the populated yaml file created above by the envsubst command.

 kubectl create -f populated.yaml

The application does not have an external IP, so give it one.

 kubectl expose deployment joomla --type=LoadBalancer --name=newmla

Get the URL. Repeat as long as it has a blank IP address. It may take a few minutes for the instance to become available.

 echo http://$(kubectl get svc --namespace default newmla -o jsonpath='{.status.loadBalancer.ingress[0].ip}')

Copy and paste the URL into a browser. You will need the credentials which can be found by copying and pasting the below commands into the Google Cloud Shell.

 echo Username: user
 echo Password: bitnami

Enter the credentials into the web page. You are now the administrator. Feel free to explore the Joomla application you deployed. When finished, let’s clean up with one command.

 kubectl delete -f populated.yaml

To minimize costs, delete the cluster before leaving the Google Container Engine.

Conclusion

You have just deployed an application into Kubernetes using two different tools: Helm and Yipee.io. Helm is more seamless and tightly integrated into Kubernetes. Yipee.io provides visual editing and a view of the application. Yipee.io also works with environments beyond Kubernetes, such as Docker. You might have noticed that handling default credentials in Kubernetes is not entirely smooth yet. Please leave a message in the comments below if you have any difficulties deploying the apps in this post. The next blog post will continue the trend of more complexity by introducing a BIG-IP and tools to integrate with Kubernetes.

Series Index

Deploy an App into Kubernetes in less than 24 Minutes

Deploy an App into Kubernetes Even Faster (Than Last Week)

Deploy an App into Kubernetes Using Advanced Application Services

What's Happening Inside my Kubernetes Cluster?

Published Jun 15, 2017
Version 1.0

Was this article helpful?

No CommentsBe the first to comment