Last active
August 11, 2021 00:35
-
-
Save YannMjl/0732ddc26614294753c44f2a9888d58b to your computer and use it in GitHub Desktop.
This is a snipet of GitHub action job to deploy a kubernetes deployment to GCP cluster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
deploy_to_google_cloud: | |
name: Deploy to Google Cloud Platform | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout repo | |
uses: actions/checkout@v2 | |
# Setup gcloud CLI | |
- name: setup gcloud CLI | |
uses: google-github-actions/setup-gcloud@master | |
with: | |
project_id: ${{ secrets.GCP_PROJECT }} | |
# this is the json key of the service account created on the project | |
service_account_key: ${{ secrets.GCP_CREDENTIALS }} | |
export_default_credentials: true | |
# Deploy the app using kubernetes (deploy.yml) | |
- name: Deploy | |
# To run kubectl commands against a cluster created in Cloud Console, | |
# from another computer, or by another member of the project, | |
# you need to generate a kubeconfig entry in your environment. | |
# The rolling deployment is the standard default deployment to Kubernetes. | |
# It works by slowly, one by one, replacing pods of the previous version of | |
# your application with pods of the new version without any cluster downtime | |
run: | | |
gcloud config set compute/region us-central1 | |
gcloud config set compute/zone us-central1-c | |
gcloud container clusters get-credentials node-demo-k8s | |
envsubst < deploy.yml | |
envsubst < deploy.yml | kubectl apply -f - | |
kubectl rollout status -w deployment/nodejs-demo-app | |
kubectl get all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment