Configuring Kubernetes Pods

1.5 hours
  • 3 Learning Objectives

About this Hands-on Lab

Kubernetes offers a variety of ways in which pods can be customized and configured. This allows you to design your applications in Kubernetes in a way that meets your particular needs. In this lab, we will go through the process of setting up a highly customized Kubernetes pod that utilizes several of the available options for configuring pods. This will help you become more familiar with pod configuration and give you the chance to work with a variety of configuration options hands-on.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Create a ConfigMap Called `candy-service-config` to Store the Container’s Configuration Data
  1. Create a file called candy-service-config.yml that contains the ConfigMap definition.
  2. Use the file to create the ConfigMap in the cluster.
Create a Kubernetes Secret Called `db-password` to Store the Database Password
  1. Create a file called db-password-secret.yml to store the secret definition.
  2. Create the secret in the cluster using the file.

Note: In a real-world scenario, you should delete this file after creating the object since it contains sensitive data!

Create the Pod for the `candy-service` Application According to the Provided Specification
  1. Create the pod definition in a file located at /home/cloud_user/candy-service-pod.yml.
  2. Create the pod in the cluster.
  3. Make sure your pod is up and running.

Additional Resources

Your company is nearing completion of their new mobile app, a candy-themed game. This application has some backend infrastructure the company plans to run using Kubernetes. They want to begin deploying one of their backend services to the cluster and have asked you to create a pod definition that meets the specifications required by the software. Create a pod definition in /home/cloud_user/candy-service-pod.yml, and then create a pod in the cluster using this definition to make sure it works.

The specifications are as follows:

  • The current image for the container is linuxacademycontent/candy-service:1. You do not need a custom command or args.
  • There is some configuration data the container will need:

    It will expect to find this data in a file at /etc/candy-service/candy.cfg. Store the configuration data in a ConfigMap called candy-service-config, and provide it to the container as a mounted volume.

  • The container will need to run with the file system group with the id 2000. You will need to set this using the securityContext.
  • The container should expect to use 64MiB of memory and 250m CPU (use resource requests).
  • The container should be limited to 128MiB of memory and 500m CPU (use resource limits).
  • The container needs access to a database password in order to authenticate with a backend database server. The password is Kub3rn3t3sRul3s!. It should be stored in a secure fashion (as a Kubernetes secret called db-password) and passed to the container as an environment variable called DB_PASSWORD.
  • The container will need to access the Kubernetes API using the service account candy-svc. The service account already exists, so just configure the pod to use it.

If you get stuck, be sure to check out the lab guide or the solution video. Good luck!

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?