Skip to content
EgyKode
Guided lab

Core Kubernetes Workloads, ConfigMaps & Secrets

31 minIntermediate

This creates billable resources. Run it in a dev environment and destroy it when you finish. Set a budget alarm first.

Success criteria

0 of 4

What you are building#

What are Core Kubernetes API Workloads?#

Kubernetes abstracts application infrastructure into declarative API objects:

  • Namespace: Provides logical resource isolation (nti-devops). Prevents naming collisions and acts as a boundary for RBAC and ResourceQuotas.
  • ConfigMap: Decouples non-sensitive configuration artifacts (database hostnames, debug flags) from container images.
  • Secret: Encodes sensitive credentials (passwords, tokens) in Base64 for injection into pods.
  • Deployment: Declarative controller managing pod creation, scaling, self-healing pod replacements, and zero-downtime rolling updates.
  • Service (ClusterIP): Provides a stable, internal virtual IP and DNS name (nti-django-svc.nti-devops.svc.cluster.local) load-balancing traffic across dynamic pod IP addresses.
text
                                KUBERNETES WORKLOAD ARCHITECTURE
                                
  +-----------------------------------------------------------------------------------+
  |  KUBERNETES CLUSTER (AWS EKS)                                                     |
  |  NAMESPACE: nti-devops                                                            |
  |                                                                                   |
  |  +-----------------------+     +-------------------+                              |
  |  |    ConfigMap          |     |      Secret       |                              |
  |  |  (app-config)         |     |   (app-secret)    |                              |
  |  +-----------+-----------+     +---------+---------+                              |
  |              |                           |                                        |
  |              +-------------+-------------+                                        |
  |                            | Injected as Env Vars                                 |
  |                            v                                                      |
  |  +-------------------------------------------------+                              |
  |  |  DEPLOYMENT: nti-django-app (Replicas: 2)       |                              |
  |  |  +--------------------+   +------------------+  |                              |
  |  |  | Pod 1 (Django App) |   | Pod 2 (Django)   |  |                              |
  |  |  +---------+----------+   +--------+---------+  |                              |
  |  +------------|-----------------------|------------+                              |
  |               +-----------+-----------+                                           |
  |                           |                                                       |
  |                           v                                                       |
  |            +------------------------------+                                       |
  |            |   SERVICE (ClusterIP)        |                                       |
  |            |   nti-django-svc:8000        |                                       |
  |            +------------------------------+                                       |
  +-----------------------------------------------------------------------------------+

Steps#

Step 1: Connect to EKS Cluster & Apply Namespace#

Terminal
aws eks update-kubeconfig --name nti-devops-eks --region us-east-1
cd 04-Kubernetes-Orchestration/Lab11-K8s-Workloads-Config
kubectl apply -f namespace.yaml

Step 2: Apply Workload Manifests#

Terminal
kubectl apply -f configmap.yaml -f secret.yaml
kubectl apply -f deployment.yaml -f service.yaml

Verify it worked#

Terminal
kubectl get all -n nti-devops

Expected Output:

text
NAME                                  READY   STATUS    RESTARTS   AGE
pod/nti-django-app-6d8b9f7c4d-x9y8z   1/1     Running   0          45s
pod/nti-django-app-6d8b9f7c4d-w1v2u   1/1     Running   0          45s
 
NAME                     TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
service/nti-django-svc   ClusterIP   10.100.150.42   <none>        8000/TCP   45s
 
NAME                             READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nti-django-app   2/2     2            2           45s


Clean up#

Run this even if you did not finish. Everything above is destroyable, and an account full of half-built experiments is how a surprise bill starts.

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

Terminal
kubectl delete -f . --ignore-not-found
kubectl get all -A | grep -v kube-system
# Then destroy the cluster if you are finished for the day.

Cost of this lab: 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.

The concept behind it

Ready to try it without help?Do the challenge