forked from IBM-Cloud/kube-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iks_multi-zone_cluster_app_via_LoadBalancer_and_aggregate_capacity.yaml
118 lines (118 loc) · 3.82 KB
/
iks_multi-zone_cluster_app_via_LoadBalancer_and_aggregate_capacity.yaml
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# Warning: In order to make this work as of October 2018 you have to open a ticket with IBM Cloud. Please refer to documentation and howto.
apiVersion: v1
kind: Service
metadata:
annotations:
service.kubernetes.io/ibm-load-balancer-cloud-provider-enable-features: "ipvs"
service.kubernetes.io/ibm-load-balancer-cloud-provider-zone: dal10 # instructs kube to create the LB in this zone # NEED TO EDIT!
labels:
app: echoserver-deployment-whole-region
name: iks-new-loadbalancer-dal10
namespace: default
spec:
ports:
- name: port-1
port: 1884
protocol: TCP
targetPort: 8080
selector:
app: echoserver-deployment-whole-region
type: LoadBalancer
externalTrafficPolicy: Local # Preserve the original IP address of the client connecting
---
apiVersion: v1
kind: Service
metadata:
annotations:
service.kubernetes.io/ibm-load-balancer-cloud-provider-enable-features: "ipvs"
service.kubernetes.io/ibm-load-balancer-cloud-provider-zone: dal12 # instructs kube to create the LB in this zone # NEED TO EDIT!
labels:
app: echoserver-deployment-whole-region
name: iks-new-loadbalancer-dal12
namespace: default
spec:
ports:
- name: port-1
port: 1884
protocol: TCP
targetPort: 8080
selector:
app: echoserver-deployment-whole-region
type: LoadBalancer
externalTrafficPolicy: Local # Preserve the original IP address of the client connecting
---
apiVersion: v1
kind: Service
metadata:
annotations:
service.kubernetes.io/ibm-load-balancer-cloud-provider-enable-features: "ipvs"
service.kubernetes.io/ibm-load-balancer-cloud-provider-zone: dal13 # instructs kube to create the LB in this zone # NEED TO EDIT!
labels:
app: echoserver-deployment-whole-region
name: iks-new-loadbalancer-dal13
namespace: default
spec:
ports:
- name: port-1
port: 1884
protocol: TCP
targetPort: 8080
selector:
app: echoserver-deployment-whole-region
type: LoadBalancer
externalTrafficPolicy: Local # Preserve the original IP address of the client connecting
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: echoserver-deployment-whole-region
namespace: default
labels:
app: echoserver-deployment-whole-region
spec:
replicas: 20 # start 20 replicas and spread the application out across the worker nodes (also across the region)
selector:
matchLabels:
app: echoserver-deployment-whole-region
template:
metadata:
labels:
app: echoserver-deployment-whole-region
spec:
affinity:
podAntiAffinity: # Spread out the "echoserver-deployment-whole-region" pods on the worker nodes as evenly as possible
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- echoserver-deployment-whole-region # if a pod matching app=echoserver-deployment-whole-region already runs on a node, try to find another node
topologyKey: kubernetes.io/hostname
containers:
- name: echoserver
image: k8s.gcr.io/echoserver:1.10
env:
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
restartPolicy: Always