google-github-actions / get-gke-credentials

A GitHub Action that configure authentication to a GKE cluster.
https://cloud.google.com/gke
Apache License 2.0
100 stars 41 forks source link

Documented `kubeconfig_path` output is never set #290

Closed mikepilat closed 7 months ago

mikepilat commented 7 months ago

TL;DR

The documentation and action.yaml describe the output value kubeconfig_path that is supposed to point to the generated kubeconfig file, but it is empty after authenticating to a cluster.

Expected behavior

The output should be set.

Observed behavior

The output is not set.

Action YAML

jobs:
  deploy-kubernetes:
    name: Deploy to Kubernetes
    runs-on: ubuntu-latest
    permissions:
      contents: "read"
      id-token: "write"
    steps:
      - id: "auth"
        name: "Authenticate to Google Cloud"
        uses: "google-github-actions/auth@v1"
        with:
          workload_identity_provider: "my_wip"
          service_account: "my_sa"

      - id: "creds"
        name: Get GKE Credentials
        uses: "google-github-actions/get-gke-credentials@v1"
        with:
          cluster_name: "my_cluster"
          location: "my_region"
          use_internal_ip: true

      - id: "echo-path"
        name: Echo Kubeconfig Path
        run: |
          echo ${{ steps.creds.outputs.kubeconfig_path }}

Log output

No response

Additional information

This feature is helpful in my case since I am coordinating actions across multiple GKE clusters. Being able to auth to each cluster once and then act on all of them based on kubeconfig as needed is useful; Relying on solely the env vars output by the action makes this difficult, or multiple auths necessary.

You can of course work around this issue by capturing the KUBE_CONFIG_PATH env var to a GitHub output:

      - id: "capture-config"
        name: Capture Kubeconfig
        run: |
          echo "kubeconfig_path=$(echo -n $KUBE_CONFIG_PATH)" >> "$GITHUB_OUTPUT"

You can refer to this in later steps as steps.capture-config.outputs.kubeconfig_path.

PR incoming with the fix...