Kubernetes·Kubernetes from first pod to production app

Services

Give pods stable networking with ClusterIP, NodePort and LoadBalancer.

Intermediate 13 min read Lesson 4 of 300 Challenge included
What you will be able to do
  • Use ClusterIP for internal traffic.
  • Use a LoadBalancer or Ingress for public traffic.
  • Services select pods by labels.
  • Use port names for clarity.

In plain English

Pods have changing IPs, so a Service provides a stable virtual IP and DNS name. ClusterIP is internal, NodePort exposes a port on every node and LoadBalancer asks the cloud for an external load balancer.

service.yamlYAML
apiVersion: v1
kind: Service
metadata:
  name: web
spec:
  type: ClusterIP
  selector:
    app: web
  ports:
    - name: http
      port: 80
      targetPort: 80
Your turn

Expose port 80

Easy

Write a Service port mapping from port 80 to targetPort 8080.

YAML · starter
ports: []
Check your understanding before moving on.
Knowledge checkQuestion 1

Which Service type is internal to the cluster?

Select an answer to continue
Study tools

Make it yours.

Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.

Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign in
Finished reading?

Lock in what you just learned.

Mark this lesson complete to save your place and move one step closer to the certificate.

Next: ConfigMaps and Secrets
Lesson 4 of 300 · 0% of course