CFN Cloud
Cloud Future New Life
en zh
2025-10-05 · 0 views

Service: Stable Access

Use Services to turn dynamic Pods into a stable address.

Pod IPs change, but a Service provides a stable entry point and routes traffic to Pods through label selectors.

Common types

  • ClusterIP: internal access
  • NodePort: expose on node ports
  • LoadBalancer: cloud LB integration
  • Headless: no load balancing

Example Service

apiVersion: v1
kind: Service
metadata:
  name: api
spec:
  selector:
    app: api
  ports:
    - port: 80
      targetPort: 8080

Troubleshooting

  • Ensure selector matches Pod labels
  • Check kubectl get endpoints api

Practical notes

  • Start with a quick inventory: kubectl get nodes, kubectl get pods -A, and kubectl get events -A.
  • Compare desired vs. observed state; kubectl describe usually explains drift or failed controllers.
  • Keep names, labels, and selectors consistent so Services and controllers can find Pods.

Quick checklist

  • The resource matches the intent you described in YAML.
  • Namespaces, RBAC, and images are correct for the target environment.
  • Health checks and logs are in place before promotion.

References