Skip to content
EgyKode
06 · KubernetesLab 35 / 59
Guided labkubernetes

Core Kubernetes Workloads, ConfigMaps & Secrets

Get the application running on Kubernetes with its configuration and secrets outside the image.

Time
31 min
Level
Intermediate
Objectives
4 objectives
Cost
Low cost

Where this fits in the platform

Before you start

CostLow cost

Depends on an existing cluster. The Kubernetes objects here cost nothing; the EKS cluster underneath them is $0.10/hour. If you created it in the EKS lab, destroy it when you finish this one.

Nothing to pay in the browser. Open the terminal runs this against a simulated cloud — the same API calls and the same commands, with no account and no bill. The figure above applies only if you build it in your own.

How to clean up

The scenario#

The image has the database hostname compiled in, so staging and production are different builds of the same commit. The password is in the same file. There are no probes, so a hung process keeps receiving traffic, and no limits, so one leaking container takes the node with it.

Hands-on environment

Run this lab in a real terminal, free and in your browser. The environment is temporary and yours alone — break it as much as you like.

Open the terminal

Opens in Killercoda, in a new tab — keep this page open for the steps.

Run it on your own machine

Run this lab on your own machine. One command starts the environment, with everything the lab needs already installed:

You will need:

  • docker
  • kubectl
  • kind
git clone https://github.com/EgyKode/EgyKode-lab.git
cd EgyKode-lab
./egykode start k8s
./egykode shell

You need Docker and Git installed. Everything else runs inside the environment. The first start downloads it and takes a few minutes; later starts are seconds.

Not sure what you already have? Run: npm run doctor — it checks and changes nothing.

Run it on AWS

This lab builds real cloud infrastructure, so it needs your own AWS account. Follow the cost and cleanup notes above — the resources are yours, and so is the bill.

Anything you tick here is your own record. EgyKode cannot see inside that terminal, so the success criteria stay self-assessed even when the environment checks your work for you.

A namespace, and why not default

Step 1 of 4

What you are building#

text
  Namespace: platform
    |
    +-- ConfigMap    non-secret config      -> env vars
    +-- Secret       credentials            -> env vars, RBAC-scoped
    +-- Deployment   2 replicas, probes, limits
    +-- Service      ClusterIP, stable name

Build it#

Verify it worked#

Terminal
# The config is injected, not baked in
kubectl exec -n platform deploy/api -- env | grep -E 'LOG_LEVEL|DB_HOST'
 
# Endpoints exist — this is what a Service actually resolves to
kubectl get endpointslices -n platform -l kubernetes.io/service-name=api
 
# Readiness removes a Pod without restarting it
kubectl exec -n platform deploy/api -- touch /tmp/unhealthy   # if your app honours it
kubectl get pods -n platform          # READY 0/1, RESTARTS unchanged
kubectl get endpointslices -n platform -l kubernetes.io/service-name=api  # one fewer address
 
# QoS is what you intended
kubectl get pods -n platform -o custom-columns=NAME:.metadata.name,QOS:.status.qosClass
 
# Reachable by name from inside the cluster
kubectl run curl --rm -it --image=curlimages/curl --restart=Never -n platform -- \
  curl -s -o /dev/null -w '%{http_code}\n' http://api/

The readiness test is the one worth doing carefully: seeing READY 0/1 with RESTARTS 0 and one fewer endpoint is the difference between understanding readiness and having copied it.


Clean up#

DestructiveThis removes real resources. Check which environment you are in first.

Terminal
kubectl delete namespace platform

Cost of this lab: Free on kind or minikube. On EKS you are paying for the cluster either way; these objects add nothing.

Success criteria

0 of 4

The concept behind it

Ready to try it without help?Do the challenge

Next up

Lab 35 of 59 on the project path

Amazon EKS Cluster & Managed Node Group ProvisioningProvision the cluster everything else runs on, with worker nodes in private subnets and no public endpoint.31 minIntermediateBillable — destroy resources when you finish

Previous: Kubernetes Storage: PVC, PV and StorageClass