-
Abstraction over Deployments
-
Expose via network ports or load-balancer
-
Service Discovery via DNS
-
DNS Annotations for external DNS
`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
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
spec:
containers:
- name: readiness
image: k8s.gcr.io/busybox
readinessProbe:
exec:
command:
- cat
- /tmp/healthy
initialDelaySeconds: 5
periodSeconds: 5