0Pricing
Helm Academy · Lesson

Adding a Service Template

Exposing the workload through a templated Service.

Adding a Service Template is a free Helm Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Helm Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

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: 80

Map 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: 80

Declare the Container Port

For clarity, list the port your pod opens in the Deployment's containerPort. It documents intent and aids tooling.

ports:
  - containerPort: 80

The 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: 80

Render 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. 🚀

Frequently asked questions

Is the “Adding a Service Template” lesson free?

Yes — the full text of “Adding a Service Template” is free to read here on the web, and the Helm Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Helm Academy course, upgrade to CoddyKit PRO.

What will I learn in “Adding a Service Template”?

Exposing the workload through a templated Service. You practise Helm Academy 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 Helm Academy?

No prior experience is required. Helm Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

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 Helm Academy lesson?

Yes. Every Helm Academy 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

  1. A Minimal Deployment Template
  2. Parameterizing the Container Image
  3. Adding a Service Template
  4. Installing and Iterating Your Chart
← Back to Helm Academy