Giter Site home page Giter Site logo

googlecloud-kubernetes-challenge's Introduction

GoogleCloud-Kubernetes-challenge

Google Kubernetes Engine - GitHub Actions

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

This code is intended to be an example. You will likely need to change or update values to match your setup.

Workflow description

For pushes to the master branch, this workflow will:

  1. Download and configure the Google Cloud SDK with the provided credentials.

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

  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 a new Google Cloud Project (or select an existing project) and enable the Container Registry and Kubernetes Engine APIs.

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

  3. Create or reuse a GitHub repository for the example workflow:

    1. Create a repository.

    2. Move into the repository directory:

      $ cd <repo>
      
    3. Copy the example into the repository:

      $ cp -r <path_to>/github-actions/example-workflows/gke/ .
      
  4. Create a Google Cloud service account if one does not already exist.

  5. Add the the following Cloud IAM roles to your service account:

    • Kubernetes Engine Developer - allows deploying to GKE

    • Storage Admin - allows publishing to Container Registry

    Note: These permissions are overly broad to favor a quick start. They do not represent best practices around the Principle of Least Privilege. To properly restrict access, you should create a custom IAM role with the most restrictive permissions.

  6. Create a JSON service account key for the service account.

  7. 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

  8. Update .github/workflows/gke.yml to match the values corresponding to your VM:

    • GKE_CLUSTER - the instance name of your cluster

    • GCE_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>
    

Run the workflow

  1. Add and commit your changes:

    $ git add .
    $ git commit -m "Set up GitHub workflow"
    
  2. Push to the master branch:

    $ git push -u origin master
    
  3. View the GitHub Actions Workflow by selecting the Actions tab at the top of your repository on GitHub. Then click on the Build and Deploy to GKE element to see the details.

GKE - Google Cloud Platform #JUARA GCP - 2020

googlecloud-kubernetes-challenge's People

Contributors

priyosan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.