gcloud config set project [PROJECT_ID]gcloud config set compute/zone [COMPUTE_ZONE]gcloud components update
- Create a container cluster: 
gcloud container clusters create [CLUSTER_NAME] - Ensure was created: 
gcloud container clusters list 
- You need to set a default cluster for the gcloud and kubectl command-line tools: 
gcloud config set container/cluster [CLUSTER_NAME] - Pass the cluster's credentials to kubectl: 
gcloud container clusters get-credentials [CLUSTER_NAME] 
kubectl config current-contextmust returngke_focus-sequencer-175820_us-east1-d_simulator-cluster
- Link your github repo: https://console.cloud.google.com/code/develop/repo?project=focus-sequencer-175820&authuser=0
 - Create a version trigger (Acionador de versão): https://console.cloud.google.com/gcr/triggers?project=focus-sequencer-175820&authuser=0
 
Additional resources
- https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-container-cluster
 - https://cloud.google.com/kubernetes-engine/docs/concepts/cluster-architecture
 - https://cloud.google.com/kubernetes-engine/docs/concepts/node-pools
 
- Cloud SQL - a postgres instance for staging and another for production (save the postgres user password when you create it)
 - Enable the Google Cloud SQL API for your project
 - Create a Cloud SQL service account with all privileges and download it.
 
- project id - 
focus-sequencer-175820 - cluster zone - 
us-east1-d - cluster id - 
simulator-cluster - sql instance id - 
simulator-stag-pgorsimulator-prod-pg - endpoint - use your public domain or ip
 
kubectl create namespace stagkubectl create namespace prod
To create files, can use the touch command. (man touch, for more details)
- Create a new file 
pg_usernameand executeecho "postgres" > pg_username - Create a new file 
pg_passwordand executeecho "<SAVED-PWD>" > pg_password - Generate a hash and save it with: 
mix phx.gen.secret - Create a new file 
secret_key_baseand executeecho "<SECRET>" > secret_key_base - Let's create the kubernetes secrets from created files for prod and stag envs:
 
kubectl create secret generic simulator --from-file ./secret_key_base --from-file ./pg_username --from-file ./pg_password --namespace stagkubectl create secret generic simulator --from-file ./secret_key_base --from-file ./pg_username --from-file ./pg_password --namespace prod
- After this, can remove them: 
rm -rf pg_username pg_password secret_key_base - Create the secret 
cloudsql-keyfilewith a filekeyfile.json(which must be the keyfile for thecloudsql-prodservice account previously created) 
cp <path-to-cloudsql-prod-keyfile> ./keyfile.json
kubectl create secret generic cloudsql-keyfile --from-file ./keyfile.json --namespace stag
kubectl create secret generic cloudsql-keyfile --from-file ./keyfile.json --namespace prod
rm -rf keyfile.json- kubectl create -f k8s/stag/simulator.web.deployment.yml --namespace stag
 - kubectl create -f k8s/stag/simulator.api.deployment.yml --namespace stag
 - kubectl create -f k8s/prod/simulator.web.deployment.yml --namespace prod
 - kubectl create -f k8s/prod/simulator.api.deployment.yml --namespace prod
 - kubectl create -f k8s/simulator.web.service.yml --namespace stag
 - kubectl create -f k8s/simulator.api.service.yml --namespace stag
 - kubectl create -f k8s/simulator.web.service.yml --namespace prod
 - kubectl create -f k8s/simulator.api.service.yml --namespace prod
 
Notes: When create a new service there are differences between
kubectl exposeandkubectl create. See the kubernetes docs for more details.
kubectl set image deployment/web-deployment web=gcr.io/focus-sequencer-175820/simulator.web:<commit-hash> --namespace <stag|prod>