CD5: Kubernetes essentials

Lesson 4 of 5 · reading 15–25 minutes; practice and project time is on the module page

Configuration, secrets and traffic from outside

🎯You'll be able to

Pass settings and secrets to pods, understand how Kubernetes Secrets are stored, and route outside traffic to a Service.

🏠The everyday picture

A hotel's front desk hands each guest a printed welcome card (the Wi-Fi name, breakfast times) and, separately, a sealed envelope with the room safe's code. One gate at the front leads guests to the right building.

📘What it really is

📝A worked example

Input (not verified): kubectl create secret generic routerani-db --from-literal=DATABASE_URL='postgres://routerani:<generated>@db:5432/routerani', then kubectl get secret routerani-db -o yaml.

Expected output: the YAML shows DATABASE_URL: followed by a long base64 string. kubectl get secret routerani-db -o jsonpath='{.data.DATABASE_URL}' | base64 -d prints the original value, which shows why access to Secrets must be limited.

🌍Where it's used

📝Case scenario

An edtech company committed Kubernetes Secret YAML files to Git, believing the base64 values were encrypted. A student intern decoded one in seconds during a hackathon and reported it. The team rotated the passwords, removed the files from Git, and moved to a secrets manager with a sync operator, so the repository held only the secret names.

🖱️Try it

Run echo -n 'postgres://routerani:Example123@db:5432/routerani' | base64 and then decode the result with base64 -d (on Windows PowerShell, use [Text.Encoding]::UTF8.GetString([Convert]::FromBase64String('<the string>'))). Success: you've seen that base64 hides nothing.

⚠️Common mistakes

🛠️For your project

RouteRani's Project 1 keeps the password out of Git with random_password; on Kubernetes the same goal is met with a secrets manager and RBAC.

✅Quick check

Is base64 encryption?

Show the answer

No, it's an encoding that anyone can reverse.

What does an Ingress add over a LoadBalancer Service?

Show the answer

One entry point that routes many hostnames and paths to different Services.

← PreviousProbes, resources and rolling updates
ProLearners Assist