simenandre / setup-gke-gcloud-auth-plugin

Installs a pre-requisite for "gcloud container clusters get-credentials" command with a modern k8s client.
Apache License 2.0
2 stars 3 forks source link
actions github-actions gke google

simenandre/setup-gke-gcloud-auth-plugin

⚠️ This plugin is deprecated. See the migration guide for how to achieve the same using Google's own github action

This GitHub Actions installs a pre-requisite for "gcloud container clusters get-credentials" command with a modern k8s client.

Quickstart

- uses: simenandre/setup-gke-gcloud-auth-plugin@v1

Example

name: On Push

permissions:
  id-token: write
  contents: read

on:
  push:
    branches:
      - main

jobs:
  apply-changes:
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Authenticate to GCP
        uses: google-github-actions/auth@v1
        with:
          credentials_json: ${{ secrets.GOOGLE_PROJECT_SA_KEY }}
          project_id: ${{ secrets.GOOGLE_PROJECT_ID }}

      - uses: simenandre/setup-gke-gcloud-auth-plugin@v1

      - uses: google-github-actions/get-gke-credentials@v1
        with:
          cluster_name: my-cluster
          location: us-central1-a

      # At this point you should be able to communicate with your cluster
      - run: kubectl get pods

Migration guide to google-github-actions/get-gke-credentials@v2

Assuming this is your current setup using this plugin:

- name: Authenticate to Google
  uses: "google-github-actions/auth@v1"
  with:
    credentials_json: "${{ secrets.GCP_SERVICEACCOUNT_KEY }}"

- uses: simenandre/setup-gke-gcloud-auth-plugin@v1

- name: Authenticate to GKE cluster
  uses: google-github-actions/get-gke-credentials@v1
  with:
    cluster_name: my_cluster
    location: europe-west1-b

Migrating to get-gke-credentials can be done like so:

- name: Authenticate to Google
  uses: "google-github-actions/auth@v2"
  with:
    credentials_json: "${{ secrets.GCP_SERVICEACCOUNT_KEY }}"

- uses: "google-github-actions/setup-gcloud@v2"
  with:
    install_components: "gke-gcloud-auth-plugin"

- name: Authenticate to GKE cluster
  uses: google-github-actions/get-gke-credentials@v2
  with:
    cluster_name: my_cluster
    location: europe-west1-b