engineerd / setup-kind

kind (Kubernetes in Docker) GitHub Action
MIT License
230 stars 27 forks source link
github github-actions kubernetes

@engineerd/setup-kind

Setup KinD (Kubernetes in Docker) with a single GitHub Action!

Because of a [deprecation in the GitHub Actions environment][gh-actions-path], versions lower than v0.5.0 will no longer work properly. See this issue for more details.

This action assumes a Linux environment (amd64 or arm64 architecture), and will not work on Windows or MacOS agents.

name: "Create cluster using KinD"
on: [pull_request, push]

jobs:
  kind:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: engineerd/setup-kind@v0.5.0
      - name: Testing
        run: |
          kubectl cluster-info
          kubectl get pods -n kube-system
          echo "current-context:" $(kubectl config current-context)
          echo "environment-kubeconfig:" ${KUBECONFIG}

Note: KUBECONFIG is automatically merged after cluster creation starting with version 0.6 of Kind. See this document for a detailed migration guide

Note: GitHub Actions workers come pre-configured with kubectl.

The following arguments can be configured on the job using the with keyword (see example above). Currently, possible inputs are all the flags for kind cluster create, with the additional version, which sets the Kind version to download and skipClusterCreation, which when present, skips creating the cluster (the Kind tools is configured in the path).

Optional inputs:

Example using optional inputs:

name: "Create cluster using KinD"
on: [pull_request, push]

jobs:
  kind:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: engineerd/setup-kind@v0.5.0
        with:
          version: "v0.11.1"
      - name: Testing
        run: |
          kubectl cluster-info
          kubectl get pods -n kube-system
          echo "current-context:" $(kubectl config current-context)
          echo "environment-kubeconfig:" ${KUBECONFIG}

[gh-actions-path]: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/