2021-11-17 00:58:28 +08:00
# GCP Load Balancers for type=LoadBalacer of Kubernetes Services
2024-10-15 01:01:00 +08:00
> **Removed**: Since v1.31 (the Kubespray counterpart is v2.27), Kubernetes no longer supports `cloud_provider`. (except external cloud provider)
2021-11-17 00:58:28 +08:00
Google Cloud Platform can be used for creation of Kubernetes Service Load Balancer.
2022-08-24 21:54:03 +08:00
This feature is able to deliver by adding parameters to `kube-controller-manager` and `kubelet` . You need specify:
2021-11-17 00:58:28 +08:00
2022-08-24 21:54:03 +08:00
```ShellSession
2021-11-17 00:58:28 +08:00
--cloud-provider=gce
--cloud-config=/etc/kubernetes/cloud-config
2022-08-24 21:54:03 +08:00
```
2021-11-17 00:58:28 +08:00
2022-08-24 21:54:03 +08:00
To get working it in kubespray, you need to add tag to GCE instances and specify it in kubespray group vars and also set `cloud_provider` to `gce` . So for example, in file `group_vars/all/gcp.yml` :
2021-11-17 00:58:28 +08:00
2022-08-24 21:54:03 +08:00
```yaml
2021-11-17 00:58:28 +08:00
cloud_provider: gce
gce_node_tags: k8s-lb
2022-08-24 21:54:03 +08:00
```
2021-11-17 00:58:28 +08:00
2022-08-24 21:54:03 +08:00
When you will setup it and create SVC in Kubernetes with `type=LoadBalancer` , cloud provider will create public IP and will set firewall.
2021-11-17 00:58:28 +08:00
Note: Cloud provider run under VM service account, so this account needs to have correct permissions to be able to create all GCP resources.