Difficulty: Introduction
Estimated Time: 10 minutes

Sidecar containers

These next steps provide a simple introduction to the idea of putting two containers in a Pod to achieve the sidecar pattern. The primary advantage of sidecars is separation of concerns. Each containers is highly cohesive in terms of responsibilities, yet they work together to provide a single solution.

With a Kubernetes cluster and a CLI tool called kubectl, a few steps will get a Nginx web server running along with its sidecar.

You will learn how:

  • to use the basics of the kubectl CLI tool,
  • to install Nginx on Kubernetes,
  • containers are deployed as Deployments in Pods,
  • a Service can provide access to a replication of Pods,
  • two containers can work together to provide a solution,
  • two containers can share information through a shared file mount.

Nginx is a web server which can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. The software was created by Igor Sysoev and first publicly released in 2004. A company of the same name was founded in 2011 to provide support and Nginx plus paid software.

Nginx is free and open-source software, released under the terms of a BSD-like license. A large fraction of web servers use NGINX, often as a load balancer. -- Wikipedia

Conclusion

You now understand two different techniques for starting a container on Kubernetes. Nginx is a commonly used for serving up web contents and as you can see is easy to start on Kubernetes. There are thousands of other containers that can easily be started with these same basic steps.

Lessons Learned

With these steps you have learned how:

  • to use the basics of the kubectl CLI tool,
  • to install Nginx on Kubernetes,
  • containers are deployed as Deployments in Pods,
  • a Service can provide access to a replication of Pods,
  • two containers work together to provide a solution,
  • two containers share information through a shared file mount.

References


No Fluff Just Stuff

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.

Sidecar Containers

Step 1 of 3

Your Kubernetes Cluster

For this scenario, Katacoda has just started a fresh Kubernetes cluster for you. Verify it's ready for your use.

kubectl version --short && \ kubectl get componentstatus && \ kubectl get nodes && \ kubectl cluster-info

The Helm package manager used for installing applications on Kubernetes is also available.

helm version --short

Kubernetes Dashboard

You can control the cluster with the kubectl CLI tool or through the Kubernetes Dashboard. Because the dashboard can be accessed publicly, it is protected and requires the secret access token to sign in. Copy the token from this secret.

export TOKEN=$(kubectl describe secret $(kubectl get secret | awk '/^dashboard-token-/{print $1}') | awk '$1=="token:"{print $2}') && echo -e "\n--- Copy and paste this token for dashboard access --\n$TOKEN\n---"

To access the dashboard, click on the Kubernetes Dashboard tab above the command line or from this link: https://[[HOST_SUBDOMAIN]]-30000-[[KATACODA_HOST]].environments.katacoda.com/. At the sign in prompt select Token and paste in the token, you copied a moment ago.

For Kubernetes clusters exposed to the public, always lock administration access including access to the dashboard.

Terminal
Kubernetes Dashboard
sidecar-pod