Kubernetes is a great tool for running applications. In this lab, you will have a chance to get hands-on with the process of deploying and configuring Kubernetes applications all the way from code to K8s. You will create a Git repository for your code, build a container image for the application using Docker, and run and configure the application in a Kubernetes cluster.
Successfully complete this lab by achieving the following learning objectives:
- Create a Codebase Using Git
Clone the application GitHub repository to the lab server under
The repository is located at
Optionally, you can create your own fork in GitHub (requires a GitHub account) and clone that instead.
- Build a Docker Image for the App with All Needed Dependencies
The source code already includes a Dockerfile, but it is not configured to include the necessary
servepackage that will be used to serve the static app content.
Edit the Dockerfile to run the command
yarn global add serveduring the image build process in order to install this package within the resulting image.
Then, build a Docker image for the app called
<YOUR_DOCKER_HUB_USERNAME>/pirate-day:0.0.1. Push the image to Docker Hub.
- Deploy the Application to Kubernetes with the Necessary Config
Create a ConfigMap called
pirate-configwith the following data:
data: .env: | REACT_APP_PIRATE_MESSAGE='No!'
Feel free to customize the message value if you wish.
Create a Pod called
pirate-dayto run the container image for the app.
- Attach the label
app=pirate-dayto the Pod.
- Mount the
pirate-configConfigMap data to a file within the container at
/usr/src/app/.env. This should make the app display the message defined in the ConfigMap data.
There is a pre-existing Service that will allow you to access the app for testing. Using the Public IP address of the K8s Server, you should be able to access the app in a browser at
- Attach the label