Difficulty: Intermediate
Estimated Time: 20 minutes

First Kubernetes Application

As a prerequisite, we assume you have an introductory working knowledge of Minikube covered in the Minikube scenario of this course.

Minikube Kubernetes

This scenario takes you through the basics of deploying an application on Kubernetes. The application is nothing notable, but it's simple enough to get started. In the following steps you will learn:

  • to deploy and start the echoserver application
  • to scale the application
  • Services load balance between multiple Pods of the app
  • Kubernetes resilience maintains the declared state even with failures
  • to rollout a new version of an application

Conclusion

Once an application is in a container, it's fairly simple to ask Kubernetes to serve up the container in multiple Pods fronted with a load balancing Service. Thereafter, Kubernetes dutifully respects your declared request by ensuring the application remains running on the cluster.

There are many other types of resources that can be added to Kubernetes besides just Pods, Services and Deployments, however these are the most common resources. Later, explore the Helm scenarios to see how whole charts of more complex deployments can be installed.

Lessons Learned

With these steps you have learned:

  • how to Deploy an application,
  • how to Scale an application,
  • how to load balance an application with a Service for multiple Pods of an application,
  • how Resilience maintains the declared state even with failures,
  • how to Roll out new versions of an application.

For a deeper understanding of these topics and more join me, Jonathan Johnson, for a transcendent experience on the No Fluff Just Stuff Software Symposium Tour.

First App

Step 1 of 5

Deployment

Ensure Minikube is running and ready to accept your upcoming declarations.

minikube status

Deploy a simple application called echoserver.

kubectl create -f echoserver.yaml

A simpler way to do this is with the run command, but this only creates a Pod. We actually want a Deployment with a ReplicaSet kubectl run hello --generator=run-pod/v1 --image=k8s.gcr.io/echoserver:1.9 --port=8080

Take a look at the YAML files that defines this application.

cat echoserver.yaml

Notice this not only defines a kind: Deployment, but inside the deployment is a ReplicaSet of a 'Pod' and that pod consists of one Container. The Deployment is a preferred way of deploying applications instead of simply standing up just a Pod. You may see the advantage in the later step that scales the application.

It's only about 44 MB so it downloads and starts within a few moments. Ensure the Available status changes from 0 to 1.

kubectl get deployments,pods

With this the application is running, however it's not accessible. A service is needed for access.