GithubHelp home page GithubHelp logo

isabella232 / get-gke-credentials Goto Github PK

View Code? Open in Web Editor NEW

This project forked from google-github-actions/get-gke-credentials

0.0 0.0 0.0 1.22 MB

This action configures authentication to a GKE cluster.

License: Apache License 2.0

JavaScript 7.17% TypeScript 92.83%

get-gke-credentials's Introduction

get-gke-credentials

This action configures authentication to a GKE cluster via a kubeconfig file that can be used with kubectl or other methods of interacting with the cluster.

Authentication is performed by generating a short-lived token (default behaviour) or via the GCP auth plugin present in kubectl which uses the service account keyfile path in GOOGLE_APPLICATION_CREDENTIALS.

Prerequisites

This action requires:

  • Google Cloud credentials that are authorized to view a GKE cluster. See the Authorization section below for more information. You also need to create a GKE cluster.

  • This action runs using Node 16. If you are using self-hosted GitHub Actions runners, you must use runner version 2.285.0 or newer.

Usage

jobs:
  job_id:
    permissions:
      contents: 'read'
      id-token: 'write'

    steps:
    - id: 'auth'
      uses: 'google-github-actions/auth@v0'
      with:
        workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
        service_account: '[email protected]'

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

    # The KUBECONFIG env var is automatically exported and picked up by kubectl.
    - id: 'get-pods'
      run: 'kubectl get pods'

Inputs

  • cluster_name - (Required) Name of the cluster for which to get credentials. If specified as a full resource name (e.g. "projects/p/locations/l/clusters/c"), then then "project_id" and "location" inputs are optional. If only specified as the name (e.g. "my-cluster"), then the "project_id" and "location" inputs may be required.

  • location - (Optional) Location (e.g. region or zone) in which the cluster resides. This value is required unless you specify "cluster_name" as a full resource name.

  • project_id - (Optional) Project ID where the cluster is deployed. If provided, this will override the project configured by previous steps or environment variables. If not provided, the project will be inferred, best-effort.

  • use_auth_provider - (Optional) If true, use the Google Cloud auth plugin in kubectl instead of a short-lived access token. The default value is false.

  • use_internal_ip - (Optional) If true, use the internal IP address for the cluster endpoint. This is mostly used with private GKE clusters. The default value is false.

  • credentials - (DEPRECATED) This input is deprecated. See auth section for more details. Service account key to use for authentication. This should be the JSON formatted private key which can be exported from the Cloud Console. The value can be raw or base64-encoded.

Outputs

  • Exports env var KUBECONFIG which is set to the generated kubeconfig file path.

Authorization

There are a few ways to authenticate this action. A service account will be needed with at least the following roles:

  • Kubernetes Engine Cluster Viewer (roles/container.clusterViewer):
    • Get and list access to GKE Clusters. `

Via google-github-actions/auth

Use google-github-actions/auth to authenticate the action. You can use Workload Identity Federation or traditional Service Account Key JSON authentication. by specifying the credentials input. This Action supports both the recommended Workload Identity Federation based authentication and the traditional Service Account Key JSON based auth.

See usage for more details.

Authenticating via Workload Identity Federation

jobs:
  job_id:
    permissions:
      contents: 'read'
      id-token: 'write'

    steps:
    - id: 'auth'
      uses: 'google-github-actions/auth@v0'
      with:
        workload_identity_provider: 'projects/123456789/locations/global/workloadIdentityPools/my-pool/providers/my-provider'
        service_account: '[email protected]'

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

Authenticating via Service Account Key JSON

jobs:
  job_id:
    steps:
    - id: 'auth'
      uses: 'google-github-actions/auth@v0'
      with:
        credentials_json: '${{ secrets.gcp_credentials }}'

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

Via Application Default Credentials

If you are hosting your own runners, and those runners are on Google Cloud, you can leverage the Application Default Credentials of the instance. This will authenticate requests as the service account attached to the instance. This only works using a custom runner hosted on GCP.

jobs:
  job_id:
    steps:
    - id: 'get-credentials'
      uses: 'google-github-actions/get-gke-credentials@v0'
      with:
        cluster_name: 'my-cluster'
        location: 'us-central1-a'

The action will automatically detect and use the Application Default Credentials.

Versioning

We recommend pinning to the latest available major version:

- uses: 'google-github-actions/get-gke-credentials@v0'

While this action attempts to follow semantic versioning, but we're ultimately human and sometimes make mistakes. To prevent accidental breaking changes, you can also pin to a specific version:

- uses: 'google-github-actions/[email protected]'

However, you will not get automatic security updates or new features without explicitly updating your version number. Note that we only publish MAJOR and MAJOR.MINOR.PATCH versions. There is not a floating alias for MAJOR.MINOR.

get-gke-credentials's People

Contributors

averikitsch avatar bharathkkb avatar dependabot[bot] avatar dineshba avatar google-github-actions-bot avatar sethvargo 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.