Permalink
Cannot retrieve contributors at this time
digitalocean-cloud-controller-manager/docs/controllers/services/examples/http-with-sticky-sessions.yml
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53 lines (52 sloc)
1.32 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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 |