Starting on Google Kubernetes (GKE)

Pablo Reyes
1 min readSep 18, 2021

Creating and deploying cluster

Of course, we need installed kubectl and gcloud cli. On my case, I add devspace for easy management of my infrastructure.

gcloud init # login, set region and select project
gcloud container clusters create gke-cluster --num-nodes=1
gcloud container clusters get-credentials gke-cluster

On this point you have gcloud configured, a running cluster and your kubectl configured with you new cluster.

After that, you just need to apply all manifests, helm installs or any k8s management tool. On my case, just a simple devspace deploy.

Ingress (optional)

Maybe your infrastructure need an ingress. Just follow official kubectl apply for GKE.

Kubernetes dashboard (optional)

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.3.1/aio/deploy/recommended.yaml
gcloud config config-helper --format=json | jq -r '.credential.access_token'
kubectl proxy

And go to K8S dashboard.

Connecting to database (vía proxy)

After SQL cloud database creation, you have various ways to connect to cloud database. We choose SQL Proxy as a pod sidecar, like Google recommendation. Its not common way on K8S, but they promise us a secure connection and a low latency.

Create a service account for SQL cloud service and download json.

kubectl create secret generic my-service-account --from-file=service_account.json=downloaded-file-key.json

Add SQL Proxy as a sidecar.

Enable Cloud SQL Admin API.

--

--

Pablo Reyes

Desarrollador Web. Emprendedor compulsivo. Apasionado por el cine, los viajes y la fotografía. CEO de SaldoAr y Reyesoft. Trato de no dejar nada a medi