L4 LoadBalancer

Similarly to AWS cloud provider, GKE also supports using the L4 LoadBalancer for Kubernetes Services. Just specify Service.spec.type as the LoadBalancer, and then GKE will set up and configure the L4 LoadBalancer automatically.

Note that the corresponding firewall rule between the L4 LoadBalancer and the Kubernetes node can be created by the cloud provider automatically. This is simple but powerful enough if you want to quickly expose your application to the internet:

$ cat grafana.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana
spec:
replicas: 1
selector:
matchLabels:
project: devops-with-kubernetes
app: grafana
template:
metadata:
labels:
project: devops-with-kubernetes
app: grafana
spec:
containers:
- image: grafana/grafana
name: grafana
ports:
- containerPort: 3000 --- apiVersion: v1 kind: Service metadata: name: grafana spec: ports: - port: 80 targetPort: 3000 type: LoadBalancer selector:
project: devops-with-kubernetes
app: grafana


//deploy grafana with Load Balancer service $ kubectl create -f grafana.yml deployment.apps "grafana" created
service "grafana" created

//check L4 Load balancer IP address $ kubectl get svc grafana
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
grafana LoadBalancer 10.59.244.97 35.243.118.88 80:31213/TCP 1m


//can reach via GCP L4 Load Balancer
$ curl -I 35.243.118.88
HTTP/1.1 302 Found
Content-Type: text/html; charset=utf-8
Location: /login
Set-Cookie: grafana_sess=186d81bd66d150d5; Path=/; HttpOnly
Set-Cookie: redirect_to=%252F; Path=/; HttpOnly
Date: Sun, 09 Dec 2018 02:25:48 GMT
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset