Chapter 19: Kubernetes Services, Ingress and Volumes
Chala mitrano, aaj aapan Service types, cluster madhla DNS, Ingress, volumes aani thodi safety. Chapter 18 madhe Deployment aani ready Pods baghitale. Ithe stable name aani disk. Ghabru naka.
What you will learn in this chapter
- ClusterIP, NodePort, LoadBalancer and ExternalName
- How a Service name becomes Pod IPs
- Ingress for a hostname, and what kind does not give you
- emptyDir, hostPath, config and secret volumes, PV and PVC
- RBAC, Git, NetworkPolicy, non-root, known registries
- The path from a Git commit to a running Deployment
Concepts in this chapter
- 19.1Why Pods need a stable front door
- 19.2ClusterIP — load balance inside the cluster
- 19.3NodePort — a port on the node, for a lab
- 19.4LoadBalancer — when a cloud should publish it
- 19.5ExternalName — an alias to a name outside
- 19.6Service DNS, step by step
- 19.7Ingress — a hostname, not a free public domain
- 19.8Volumes inside a Pod
- 19.9PersistentVolume, claim and StorageClass
- 19.10Safety
- 19.11From a Git commit to a running Deployment
- 19.12Lab — name, DNS, one claim
The chapter recap is at the end of the last concept page.
Practice Tasks
Suppose we are on the DevOps team at Mahindra, the automobile and farm equipment company, working from Nashik. Ganesh Wankhede leads the team, and we look after the tractor service log. Costs are counted in INR. In the tasks below we do real DevOps jobs on this project using what this lesson teaches. Mahindra is a real company, but this project, the people, servers, IP addresses and numbers are made up for practice.
0 / 12
Easy ConfigMap manifest
Why: Settings in Git can be reviewed like code.
What to do: Write a ConfigMap tractor-service-config with data LOG_LEVEL: info and REGION: ap-south-1.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Use "- " for list items and fill each value from the task.
- Check the colons and spacing, then click Check answer.
Medium Expose a deployment
Why: A Service gives pods one stable address.
What to do: Expose deployment tractor-service in mahindra-prod as a ClusterIP service on port 80 forwarding to container port 5000.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium Service manifest
Why: The Service finds pods by label and balances traffic.
What to do: Write a ClusterIP Service tractor-service selecting app: tractor-service, port 80 to targetPort 5000.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Use "- " for list items and fill each value from the task.
- Check the colons and spacing, then click Check answer.
Medium Create a secret
Why: Passwords belong in a Secret, not in the image.
What to do: Create a generic secret db-cred in mahindra-prod with DB_PASSWORD=changeme.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium Port-forward for a local test
Why: Reach an internal service from your laptop without opening it to the internet.
What to do: Forward local port 8080 to port 80 of service tractor-service in mahindra-prod.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium Create a ConfigMap
Why: Config outside the image means one image for every environment.
What to do: Create a ConfigMap tractor-service-config in mahindra-prod with LOG_LEVEL=info.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Medium How many pods?
Why: Quick capacity maths comes up in every on-call.
What to do: One pod of Mahindra's tractor-service handles 400 requests per second. Peak traffic is 3000 requests per second. How many replicas are needed at minimum?
- Write down the facts or numbers the task gives you.
- Work it out step by step.
- Type only the final answer (one word or number) in the box.
- Click Check answer.
Medium Pods in all namespaces
Why: Cluster-wide views catch problems outside your own namespace.
What to do: List pods across all namespaces.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Hard Ingress for a domain
Why: Ingress sends outside HTTP traffic for a host to the right Service.
What to do: Write an Ingress tractor-service (networking.k8s.io/v1) with ingressClassName nginx, host app.mahindra.example.com, path / (pathType Prefix) to service tractor-service port 80.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Use "- " for list items and fill each value from the task.
- Check the colons and spacing, then click Check answer.
Hard Env from ConfigMap and Secret
Why: The pod reads settings and passwords without baking them into the image.
What to do: Write a Pod tractor-service (container app, image mahindra/tractor-service:1.2.1) that loads all keys from ConfigMap tractor-service-config and sets env DB_PASSWORD from Secret db-cred key DB_PASSWORD.
- Start from the top-level keys the task names.
- Indent child keys with 2 spaces (no tabs).
- Use "- " for list items and fill each value from the task.
- Check the colons and spacing, then click Check answer.
Hard Encrypt a secrets file
Why: Vault lets you commit secrets safely, encrypted.
What to do: Encrypt the file group_vars/all/secrets.yml with Ansible Vault.
- Read the task and pick the tool it needs (git, docker, kubectl, terraform, ansible...).
- Write the tool name, then the sub-command (the action word).
- Add the flags the task needs, each followed by its value.
- Add names, files or paths at the end, then click Check answer.
Hard Name the approach
Why: GitOps tools like Argo CD are now common in K8s teams.
What to do: At Mahindra a tool inside the cluster keeps pulling manifests from a Git repo and makes the cluster match it. What is this approach called (one word)?
- Write down the facts or numbers the task gives you.
- Work it out step by step.
- Type only the final answer (one word or number) in the box.
- Click Check answer.
Ravi Sir's Cards: 27 revision, interview and comparison cards for this chapter · मराठी cards