Skip to content
This repository has been archived by the owner on Jan 14, 2020. It is now read-only.

Deploy Kubernetes

shoenisch edited this page Apr 18, 2017 · 11 revisions

Here's how to set up and run an Apache Tomcat server on a Kubernetes cluster. The following examples assume that you have prepared Photon Controller to deploy Kubernetes clusters by following the instructions in Creating a Kubernetes Cluster.

Spinning Up a Cluster for Tomcat

First, create a new cluster on Photon Controller for the Tomcat server:

photon service create -n Kube2 -k KUBERNETES --dns 192.168.209.2 \
--gateway 192.168.209.2 --netmask 255.255.255.0 --master-ip 192.168.209.35 \
--load-balancer-ip 192.168.209.34 \
--container-network  10.2.0.0/16 --etcd1 192.168.209.36  -c 2

The container network should be in CIDR format (for example, 10.2.0.0/16).

If you're deploying the cluster on VMware Workstation, skip the creation of etcd node 2 to work within the size constraints of your environment.

Deploying an App to the Cluster

Now we want to deploy a basic web server application onto the Kubernetes cluster we created.

Make sure you have the kubectl tool installed on your workstation. To download the kubectl utility, see Installing and Setting Up kubectl.

Download Replication Controller and Service Files

Grab the files below:

Now we can create an application by deploying a replication controller and the corresponding service. There may be a several minute delay while the image downloads on the first deployment.

  • kubectl -s 192.168.209.35:8080 create -f <path_to_rc>.yml
  • kubectl -s 192.168.209.35:8080 create -f <path_to_service>.yml

The pods should now be running. Confirm with this command:

kubectl -s 192.168.209.35:8080 get pods

You should see "Running" on the pods you've created.

Congrats: You now have an Apache Tomcat server running on the Kubernetes cluster.

Check Out the Application

We can view our Tomcat application at the following URL:

http://192.168.209.35:30001

Scaling with Kubernetes

We can scale out to multiple Replication Controllers quite easily by using kubectl:

kubectl -s 192.168.209.35:8080 scale --replicas=2 rc tomcat-server

After scaling, use kubectl to make sure you have two copies of the Tomcat Server pod:

kubectl -s 192.168.209.35:8080 get pods

Dealing with Environment Size Limitations

After you deploy your app on this cluster, you may need to delete it in order to create additional clusters in a small environment. When you are ready to delete it, run the following command:

photon service delete <cluster_uuid>

Clone this wiki locally