https://github.com/kevin7282/github-actions-gcr
- Create a new Google Cloud Project (or select an existing project) and enable the Container Registry and Kubernetes Engine APIs.
- Create a new GKE cluster or select an existing GKE cluster.
- Create or reuse a GitHub repository for the example workflow:
- Create a repository.
- Setup IAM roles to your service account:
- Create a JSON service account key for the service account.
- Add the following secrets to your repository's secrets:
GKE_PROJECT: Google Cloud project ID GKE_SA_KEY: the content of the service account JSON file Update .github/workflows/gke.yml to match the values corresponding to the VM
gcloud container clusters get-credentials gke-cluster1 —-region=us-central1 -—project=sincere-actor-377315 gcloud auth activate-service-account --key-file=D:\devops\sincere-actor-377315-c1f7b863241e.json
TODO: Make more features for Falsk website
Build image and run local:
docker image build -t nginx-deployment:1.1.0 .
docker container run -p 80:80 --rm nginx-deployment:1.1.0
docker stop $(docker ps -q)
Upload to GCR:
docker tag nginx-deployment:blue nginx-deployment:1.1.0 gcr.io/sincere-actor-377315/nginx-deployment:1.1.0
docker tag nginx-deployment:1.1.0 gcr.io/sincere-actor-377315/nginx-deployment:1.1.0
docker push gcr.io/sincere-actor-377315/nginx-deployment:1.1.0
but as you are already here (github) you can try:
docker image build -t nginx-deployment:1.1.1 .
docker tag nginx-deployment:1.1.1 gcr.io/sincere-actor-377315/nginx-deployment:1.1.1
docker push gcr.io/sincere-actor-377315/nginx-deployment:1.1.1
- Clone the repository
- Go to dockers folder
kubectl apply -f blue.yaml
kubectl apply greenserice.yaml
- Deployment and service should be available
https://console.cloud.google.com/kubernetes/workload/overview?project=sincere-actor-377315
gcr.io reposity:
https://console.cloud.google.com/artifacts/docker/sincere-actor-377315/us/gcr.io/nginx-deployment?project=sincere-actor-377315
TODO use the handler after install to run the application
Kubernetes Engine > Services > External endpoints
https://console.cloud.google.com/kubernetes/service/us-central1/gke-cluster1/default/nginx-service/overview?project=sincere-actor-377315