Adding a Service Template
Exposing the workload through a templated Service.
Adding a Service Template is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 3 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.
Why You Need a Service
Pods get new IPs constantly. A Service gives your workload one stable address so other things can reach it reliably.
A Second Template File
Add templates/service.yaml next to your deployment template. Helm renders every file in templates, so both ship together.
The Service Skeleton
A Service starts like any manifest: apiVersion, kind: Service, and metadata. The release name keeps it tied to this install.
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}The Selector Links Pods
A Service finds its pods through a selector. It must match the labels on your Deployment's pods, or no traffic flows.
spec:
selector:
app: {{ .Release.Name }}Choose the Service Type
Parameterize type so users pick ClusterIP, NodePort, or LoadBalancer. ClusterIP is the safe in-cluster default.
type: {{ .Values.service.type }}Default the Type in values
Give service.type a default so a plain install just works. Group service settings under one key to stay tidy.
# values.yaml
service:
type: ClusterIP
port: 80Map the Port
The port is what clients connect to on the Service. Wire it to values so each install can expose a different port.
ports:
- port: {{ .Values.service.port }}Point at the Container Port
The targetPort is the port your container listens on. nginx serves on 80, so traffic on the Service forwards there.
ports:
- port: {{ .Values.service.port }}
targetPort: 80Declare the Container Port
For clarity, list the port your pod opens in the Deployment's containerPort. It documents intent and aids tooling.
ports:
- containerPort: 80The Complete Service Spec
Put it together: a templated Service whose selector matches your pods and whose port and type come from values.
spec:
type: {{ .Values.service.type }}
selector:
app: {{ .Release.Name }}
ports:
- port: {{ .Values.service.port }}
targetPort: 80Render Both Templates
Run helm template and confirm Helm emits two documents separated by ---: your Deployment and your new Service.
helm template web .Quick Check
A Service sends no traffic to your pods. What is the most likely cause?
Recap: Exposing the App
You added a Service template: selector matches the pods, type and port come from values, and targetPort hits the container. 🚀
Learn DevOps Bootcamp with an AI tutor — free
Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.
- Courses
- 142
- Lessons
- 568
Frequently Asked Questions
Is the “Adding a Service Template” lesson free?
Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Adding a Service Template”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.
What will I learn in “Adding a Service Template”?
Exposing the workload through a templated Service. You practise DevOps Bootcamp with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start DevOps Bootcamp?
No prior experience is required. DevOps Bootcamp on CoddyKit is structured for beginners through advanced learners, so you can start here or from the beginning and move at your own pace. This is lesson 3 of 4.
How long does the “Adding a Service Template” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this DevOps Bootcamp lesson?
Yes. Every DevOps Bootcamp lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- A Minimal Deployment Template
- Parameterizing the Container Image
- Adding a Service Template
- Installing and Iterating Your Chart