-
Notifications
You must be signed in to change notification settings - Fork 149
/
https-with-sticky-sessions.yml
54 lines (53 loc) · 1.42 KB
/
https-with-sticky-sessions.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
---
kind: Service
apiVersion: v1
metadata:
name: https-lb
annotations:
service.beta.kubernetes.io/do-loadbalancer-protocol: "https"
service.beta.kubernetes.io/do-loadbalancer-certificate-id: "c019bbf4-cad2-4884-8a20-410ddad7f54a"
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: https
protocol: TCP
port: 443
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