You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: contrib/service-loadbalancer/README.md
+3-90Lines changed: 3 additions & 90 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,9 +32,11 @@ __L7 load balancing of Http services__: The load balancer controller automatical
32
32
33
33
__L4 loadbalancing of Tcp services__: Since one needs to specify ports at pod creation time (kubernetes doesn't currently support port ranges), a single loadbalancer is tied to a set of preconfigured node ports, and hence a set of TCP services it can expose. The load balancer controller will dynamically add rules for each configured TCP service as it pops into existence. However, each "new" (unspecified in the tcpServices section of the loadbalancer.json) service will need you to open up a new container-host port pair for traffic. You can achieve this by creating a new loadbalancer pod with the `targetPort` set to the name of your service, and that service specified in the tcpServices map of the new loadbalancer.
34
34
35
+
35
36
### Cross-cluster loadbalancing
36
37
37
-
On cloud providers that offer a private ip range for all instances on a network, you can setup multiple clusters in different availability zones, on the same network, and loadbalancer services across these zones. On GCE for example, every instance is a member of a single network. A network performs the same function that a router does: it defines the network range and gateway IP address, handles communication between instances, and serves as a gateway between instances and other networks. On such networks the endpoints of a service in one cluster are visible in all other clusters in the same network, so you can setup an edge loadbalancer that watches a kubernetes master of another cluster for services. Such a deployment allows you to fallback to a different AZ during times of duress or planned downtime (eg: database update).
First setup your 2 clusters, and a kubeconfig secret as described in the [sharing clusters example] (../../examples/sharing-clusters/README.md). We will create a loadbalancer in our first cluster (US) and have it publish the services from the second cluster (EU). This is the entire modified loadbalancer manifest:
193
-
194
-
```yaml
195
-
apiVersion: v1
196
-
kind: ReplicationController
197
-
metadata:
198
-
name: service-loadbalancer
199
-
labels:
200
-
app: service-loadbalancer
201
-
version: v1
202
-
spec:
203
-
replicas: 1
204
-
selector:
205
-
app: service-loadbalancer
206
-
version: v1
207
-
template:
208
-
metadata:
209
-
labels:
210
-
app: service-loadbalancer
211
-
version: v1
212
-
spec:
213
-
volumes:
214
-
# token from the eu cluster, must already exist
215
-
# and match the name of the volume using in container
216
-
- name: eu-config
217
-
secret:
218
-
secretName: kubeconfig
219
-
nodeSelector:
220
-
role: loadbalancer
221
-
containers:
222
-
- image: gcr.io/google_containers/servicelb:0.1
223
-
imagePullPolicy: Always
224
-
livenessProbe:
225
-
httpGet:
226
-
path: /healthz
227
-
port: 8081
228
-
scheme: HTTP
229
-
initialDelaySeconds: 30
230
-
timeoutSeconds: 5
231
-
name: haproxy
232
-
ports:
233
-
# All http services
234
-
- containerPort: 80
235
-
hostPort: 80
236
-
protocol: TCP
237
-
# nginx https
238
-
- containerPort: 443
239
-
hostPort: 8080
240
-
protocol: TCP
241
-
# mysql
242
-
- containerPort: 3306
243
-
hostPort: 3306
244
-
protocol: TCP
245
-
# haproxy stats
246
-
- containerPort: 1936
247
-
hostPort: 1936
248
-
protocol: TCP
249
-
resources: {}
250
-
args:
251
-
- --tcp-services=mysql:3306,nginxsvc:443
252
-
- --use-kubernetes-cluster-service=false
253
-
# use-kubernetes-cluster-service=false in conjunction with the
254
-
# kube/config will force the service-loadbalancer to watch for
255
-
# services form the eu cluster.
256
-
volumeMounts:
257
-
- mountPath: /.kube
258
-
name: eu-config
259
-
env:
260
-
- name: KUBECONFIG
261
-
value: /.kube/config
262
-
```
263
-
264
-
Note that it is essentially the same as the rc.yaml checked into the service-loadbalancer directory expect that it consumes the kubeconfig secret as an extra KUBECONFIG environment variable.
0 commit comments