Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tale/kubectl-action
GitHub Action to manage a K8s cluster using kubectl
https://github.com/tale/kubectl-action
github-actions kubectl kubernetes
Last synced: 13 days ago
JSON representation
GitHub Action to manage a K8s cluster using kubectl
- Host: GitHub
- URL: https://github.com/tale/kubectl-action
- Owner: tale
- License: mit
- Created: 2022-04-07T00:48:49.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-06T02:47:05.000Z (5 months ago)
- Last Synced: 2024-10-14T13:34:34.829Z (about 1 month ago)
- Topics: github-actions, kubectl, kubernetes
- Language: TypeScript
- Homepage:
- Size: 1.35 MB
- Stars: 30
- Watchers: 1
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# kubectl-action
GitHub Action to manage a K8s (Kubernetes) cluster using kubectl.
## Usage
To use this action, add the following step to your GitHub Action workflow:
```yaml
- uses: tale/kubectl-action@v1
with:
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
```Keep in mind that the action expects a base64 encoded string of your Kubernetes configuration. The simplest way to do that is to run `cat $HOME/.kube/config | base64` and save that output as an action secret. It's additionally possible to generate a config file using the `aws` CLI for EKS or any other tools with other cloud providers.
It's also possible to specify the version of the [kubectl](https://kubernetes.io/docs/reference/kubectl/) CLI to use. The current default release used by this action is the latest version.
```yaml
- uses: tale/kubectl-action@v1
with:
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
kubectl-version: v1.22.0
```Once you've completed this setup, you have direct access to the `kubectl` binary and command in the rest of your actions. Here's a full example to give you some inspiration:
```yaml
name: Kubectl Actionon:
workflow_dispatch:jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: tale/kubectl-action@v1
with:
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
- run: kubectl get pods
```Here's an example using AWS EKS:
```yaml
name: Kubectl Actionon:
workflow_dispatch:jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
aws-region: us-east-2
- name: Generate kubeconfig
run: |
{
echo 'EKS_CREDS<> $GITHUB_ENV
- uses: tale/kubectl-action@v1
with:
base64-kube-config: ${{ env.EKS_CREDS }}
- run: kubectl get pods
```