Using Multiple Containers in a Kubernetes Pod

30 minutes
  • 3 Learning Objectives

About this Hands-on Lab

Multi-container Pods in Kubernetes use additional containers within the same Pod to solve technical challenges. This lab will allow you to get hands-on with multi-container Pods. You will build expertise as you design your own multi-container Pod in order to address a real-world issue.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Update the Service to Use the New Port

There is a Service called hive-svc located in the default Namespace. Modify this service so that it listens on port 9076.

Add an init Container to Delay Startup

The app is managed by the app-gateway Deployment located in the default Namespace. Add an init container to the Pod template so that startup will be delayed by 10 seconds. You can do this by using the busybox:stable image and running the command sh -c sleep 10.

Add an Ambassador Container to Make the App Use the New Service Port

Find the app-gateway Deployment located in the default Namespace. Add an ambassador container to the Deployment’s Pod template using the haproxy:2.4 image.

Supply the ambassador container with an haproxy configuration file at /usr/local/etc/haproxy/haproxy.cfg. There is already a ConfigMap called haproxy-config in the default Namespace with a pre-configured haproxy.cfg file.

You will need to edit the command of the main container so that it points to localhost instead of hive-svc.

Additional Resources

Welcome to HiveCorp, a software design company that is totally not run by bees! Your team is working on part of the company's honey management app. Sorry, money management, not honey management!

Your app reaches out to a Service maintained by another team. Some recent changes by the other team have led to some issues:

  • Your team's app Pods need to delay startup by a few seconds to allow time for some auxiliary systems to react to the Pod's presence.
  • The other team wants to change the external Port exposed by their Service, and your team's app will need to be updated accordingly. Use an ambassador container so that this port is more easily configurable in the future.

Solve these problems by modifying your app's Deployment. Use an init container to delay your app's startup, and use an ambassador container to allow your app to use the new Service port in a configurable way.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?