https://github.com/mlibrary/deploy-to-kubernetes
Action for deploying a ghcr image to a kuberenetes cluster
https://github.com/mlibrary/deploy-to-kubernetes
Last synced: 3 months ago
JSON representation
Action for deploying a ghcr image to a kuberenetes cluster
- Host: GitHub
- URL: https://github.com/mlibrary/deploy-to-kubernetes
- Owner: mlibrary
- License: other
- Created: 2021-09-09T14:37:13.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-04-07T14:29:38.000Z (about 3 years ago)
- Last Synced: 2025-02-21T04:02:33.348Z (over 1 year ago)
- Size: 25.4 KB
- Stars: 1
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# deploy-to-kubernetes
Action for deploying a ghcr image to a kuberenetes cluster
Uses [kubectl set image](https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#-em-image-em-) command.
## Example
To use this action to deploy a deployment image to the `web` deployment and `web` container:
```
- name: Deploy to NAMESPACE
uses: mlibrary/deploy-to-kubernetes@v3
with:
registry_token: ${{ secrets.GITHUB_TOKEN }}
image: ghcr.io/myorganization/my_app:latest
cluster_ca: ${{ secrets.KUBERNETES_CA }}
cluster_server: my-kubernetes-server
namespace_token: ${{ secrets.NAMESPACE_CA }}
namespace: my-app-namespace
```
To use this action to deploy a cronjob image
```
- name: Deploy to NAMESPACE
uses: mlibrary/deploy-to-kubernetes@v3
with:
registry_token: ${{ secrets.GITHUB_TOKEN }}
image: ghcr.io/myorganization/my_app:latest
cluster_ca: ${{ secrets.KUBERNETES_CA }}
cluster_server: my-kubernetes-server
namespace_token: ${{ secrets.NAMESPACE_CA }}
namespace: my-app-namespace
resource_type: cronjob
resource_name: my-cronjob-name
container: my-cronjob-name
```
## Inputs
### Required
| Name | Description |
|----------|-------------|
| `registry_token` | The token to use to log in to the registry. For GHCR this shold be `${{ secrets.GITHUB_TOKEN }}`.|
| `image` | Image to deploy, e.g. `registry/organization/image_name:tag` |
|`cluster_server` | The Kubernetes server |
| `cluster_ca` | The Kubernetes cluster CA certificate, base64-encoded, e.g. from:
`cat ~/.kube/certs/my-cluster/k8s-ca.crt \| base64` |
| `namespace_token`| A base64-encoded Kubernetes service account token that can be used to set the image for the given deployment in the given namespace, e.g. from:
`kubectl -n my-namespace get -o json secret my-service-token \| jq -r .data.token` |
|`namespace` | The Kubernetes namespace to deploy to. |
### Optional
| Name | Description | Value |
|------|-------------|-------|
|`registry`| Registry to log in to | `ghcr.io` |
|`registry_username`| Username to log into the registry with | `${{ github.actor }}` |
|`resource_type`| Any resource type, comma-separated set of resource types, or 'all'| `deployment` |
|`resource_name`| Name of the resource whose image to set, a label selector like `--selector='app=someapp'`, or `--all` | `web` |
|`container`| The container in the resource whose image to set, or "*" for all containers | `web` |