Skip to content

cn-dino/gke-actions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build and Deploy to GKE

Cloned from GKE github actions repo.

Not much to see here, this will probably be a mess while I try and figure it all out.

Google Kubernetes Engine - GitHub Actions

An example workflow that uses GitHub Actions to deploy a static website to an existing Google Kubernetes Engine cluster.

Workflow

For pushes to the default branch, master, the workflow will:

  1. Verify the Google Cloud Platform credentials are correct.

  2. Build, tag, and push the image to Google Container Registry.

    • gcloud serves as a credential helper for Docker. This workflow registers gcloud as a credential helper and uses the 'docker' command within the gcloud action to push the image.

    • The image is available through the following tags: latest, the branch name, and first 8 of the commit SHA.

  3. Use a Kubernetes Deployment to push the image to the cluster.

    • Note that a GKE deployment requires a unique Tag to update the pods. Using a constant tag latest or a branch name master may result in successful workflows that don't update the cluster.

Setup

  1. Create or reuse a Github repository for the example workflow:

  2. Create a repository.

  3. Move into your repository directory.

  4. Copy the example into the repository:

cp -r <path_to>/github-actions/example-workflows/gke/ ./
  1. Add your Project Id to the repository's secret, named GKE_PROJECT.

  2. Create a GKE cluster or select an existing GKE cluster.

  3. Update gke.yml with the following values:

  • GKE_CLUSTER: the name of your cluster.

  • GKE_ZONE: the zone your cluster resides.

  • IMAGE: your preferred Docker image name.

You can find the names of your clusters using the command: gcloud container clusters list, and the zone using the command: gcloud container clusters describe <CLUSTER_NAME>.

  1. Add the the following roles to your service account:
  • Kubernetes Engine Developer
  • Storage Admin

Run the workflow

  1. Add and commit your changes:
git add .
git commit -m "Set up Github workflow"
  1. Push to the master branch:
git push origin master
  1. View the workflow by selecting the Actions tab at the top of your repository. Then click on the Build and Deploy to GKE workflow to see the details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors