forked from actions-hub/kubectl
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
only handle attempts with KUBE_CONFIG defined
- Loading branch information
Andrew Harris
authored and
Andrew Harris
committed
Aug 24, 2023
1 parent
b383eea
commit bbf9ccb
Showing
2 changed files
with
18 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,32 +9,9 @@ To use kubectl put this step into your workflow: | |
|
||
### Authorization with config file | ||
```yaml | ||
- uses: actions-hub/kubectl@master | ||
- uses: andrrax/kubectl@only_kubeconfig | ||
env: | ||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} | ||
with: | ||
args: get pods | ||
``` | ||
### Authorization with credentials | ||
```yaml | ||
- uses: actions-hub/kubectl@master | ||
env: | ||
KUBE_HOST: ${{ secrets.KUBE_HOST }} | ||
KUBE_CERTIFICATE: ${{ secrets.KUBE_CERTIFICATE }} | ||
KUBE_USERNAME: ${{ secrets.KUBE_USERNAME }} | ||
KUBE_PASSWORD: ${{ secrets.KUBE_PASSWORD }} | ||
with: | ||
args: get pods | ||
``` | ||
### Authorization with a bearer token | ||
```yaml | ||
- uses: actions-hub/kubectl@master | ||
env: | ||
KUBE_HOST: ${{ secrets.KUBE_HOST }} | ||
KUBE_CERTIFICATE: ${{ secrets.KUBE_CERTIFICATE }} | ||
KUBE_TOKEN: ${{ secrets.KUBE_TOKEN }} | ||
KUBE_CONFIG: ${{ secrets.KUBECONFIG }} | ||
with: | ||
args: get pods | ||
``` | ||
|
@@ -46,7 +23,7 @@ I recommend using secrets for this. | |
### KUBECONFIG file | ||
First options its to use [kubeconfig file](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/). | ||
For this method `KUBE_CONFIG` required. | ||
For this method `KUBECONFIG` required. | ||
You can find it: `cat $HOME/.kube/config | base64 `. | ||
|
||
Optionally you can switch the [context](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/) (the cluster) if you have few in kubeconfig file. Passing specific context to `KUBE_CONTEXT`. To see the list of available contexts do: `kubectl config get-contexts`. | ||
|
@@ -56,21 +33,6 @@ Optionally you can switch the [context](https://kubernetes.io/docs/tasks/access- | |
| KUBE_CONFIG | string (base64) | | ||
| KUBE_CONTEXT | string | | ||
|
||
### KUBECONFIG file | ||
Another way to authenticate in the cluster is [HTTP basic auth](https://kubernetes.io/docs/reference/access-authn-authz/authentication/). | ||
|
||
For this you need to pass: | ||
- host (IP only, without protocol) | ||
- username | ||
- password | ||
- cluster CA certificate | ||
|
||
| Variable | Type | | ||
| --- | --- | | ||
| KUBE_HOST | string | | ||
| KUBE_USERNAME | string | | ||
| KUBE_PASSWORD | string | | ||
| KUBE_CERTIFICATE | string | | ||
|
||
## Example | ||
```yaml | ||
|
@@ -84,9 +46,9 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions-hub/kubectl@master | ||
- uses: andrrax/kubectl@only_kubeconfig | ||
env: | ||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} | ||
KUBE_CONFIG: ${{ secrets.KUBECONFIG }} | ||
with: | ||
args: get pods | ||
``` | ||
|
@@ -102,11 +64,11 @@ jobs: | |
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions-hub/kubectl@master | ||
- uses: andrrax/kubectl@only_kubeconfig | ||
env: | ||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} | ||
KUBE_CONFIG: ${{ secrets.KUBECONFIG }} | ||
- uses: actions-hub/kubectl@master | ||
- uses: andrrax/kubectl@only_kubeconfig | ||
with: | ||
args: get pods | ||
``` | ||
|
@@ -119,7 +81,7 @@ To use a specific version of kubectl use: | |
```yaml | ||
- uses: actions-hub/[email protected] | ||
env: | ||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }} | ||
KUBE_CONFIG: ${{ secrets.KUBECONFIG }} | ||
with: | ||
args: get pods | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters