Skip to content

Latest commit

 

History

History
95 lines (75 loc) · 1.75 KB

8-services.md

File metadata and controls

95 lines (75 loc) · 1.75 KB

Services

Services

Service

`kubectl apply -f service.yaml

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: my-service
  labels:
    app: app
    tier: frontend
  annotations:
    external-dns.alpha.kubernetes.io/hostname: my-service.workshops.mikebild.com.
spec:
  selector:
    app: app
    tier: frontend
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 8080

Types

NodePort

NodePort

LoadBalancer

LoadBalancer

Monitoring and Health-Checks

Liveness Probe

spec:
  containers:
    - name: liveness
      image: k8s.gcr.io/busybox
      livenessProbe:
        httpGet:
          path: /healthz
          port: 8080
          httpHeaders:
            - name: X-Custom-Header
              value: Awesome
        initialDelaySeconds: 3
        periodSeconds: 3

Readiness Probe

spec:
  containers:
    - name: readiness
      image: k8s.gcr.io/busybox
      readinessProbe:
        exec:
          command:
            - cat
            - /tmp/healthy
        initialDelaySeconds: 5
        periodSeconds: 5

Init-Container