Skip to content
Permalink
master
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
53 lines (52 sloc) 1.32 KB
---
kind: Service
apiVersion: v1
metadata:
name: http-lb
annotations:
service.beta.kubernetes.io/do-loadbalancer-protocol: "http"
service.beta.kubernetes.io/do-loadbalancer-sticky-sessions-type: "cookies"
service.beta.kubernetes.io/do-loadbalancer-sticky-sessions-cookie-name: "example"
service.beta.kubernetes.io/do-loadbalancer-sticky-sessions-cookie-ttl: "60"
spec:
type: LoadBalancer
selector:
app: nginx-example
# This is necessary for sticky-sessions to avoid NAT
# confusion on the way in.
externalTrafficPolicy: Local
ports:
- name: http
protocol: TCP
port: 80
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-example
spec:
replicas: 2
selector:
matchLabels:
app: nginx-example
template:
metadata:
labels:
app: nginx-example
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
protocol: TCP
# This is necessary for sticky-sessions because it can
# only consistently route to the same nodes, not pods.
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchLabels:
app: nginx-example
topologyKey: kubernetes.io/hostname