kubernetes-eks
ActionsTags
(2)Action to apply artifacts files in your EKS cluster.
This action allows you to apply Kubernetes artifact files by simply pointing to the path where your file is located.
name: Build
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deployment
uses: Pablommr/[email protected]
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
KUBECONFIG: ${{ secrets.KUBECONFIG }}
KUBE_YAML: path_to_file/file.yml
To use this action, you just need a user that has permission to apply artifacts in your EKS cluster. For more information, see this link. Also, set up the necessary environment variables listed below.
AWS access key id for IAM role.
AWS secret key for IAM role.
Environment variable containing the base64-encoded kubeconfig data. Pay attention to the profile name; it must match the AWS_PROFILE_NAME.
One of them (or both) must be set.
KUBE_YAML is the path of file to file used to create/update the resource. This env can be an array with more then 1 file. (I.e. kubernetes/deployment.yml,artifacts/configmap.yaml )
FILES_PATH is the path of the directory where the files are located. All files in this current directory will be applied.
The files must be with *.yaml or *.yml extensions.
Profile name to be configured. If not passed, this env assume the value 'default'
(boolean)
Whether to run envsubst to substitute environment variables inside the file in KUBE_YAML. Your variable inside your file need begin with "$". If not passed, this env assume the value 'false'
(boolean)
If you use path in env FILES_PATH, you can set this env to true to apply files in subdirectory. Default value is false.
(boolean)
If you use path in env FILES_PATH, you can set this env to true to continue applying files in case of fail in one file. Default value is false.
(boolean)
Whether to watch the status of the latest rollout until it's done. The rollout only works for Deployment, StatefulSet, or DaemonSet resources and will only be executed if the Pods applied by KUBE_YAML finalize with an unchanged status. Default value is true.
(String)
Timeout to KUBE_ROLLOUT. This env must be in time format. (i.e.: 60s, 5m, 1h) and KUBE_ROLLOUT must be true. Defaul value is 20m.
Let's suppose you need to apply three artifacts in your EKS: one Deployment, one Service, and one ConfigMap. All your Kubernetes artifacts are inside the kubernetes folder, like this:
├── README.md
├── app
| └── files
├── kubernetes
│ ├── deployment.yaml
│ ├── envs
│ │ ├── prod
│ │ │ └── configmap.yaml
│ │ └── staging
│ │ └── configmap.yaml
│ └── service.yaml
└── another_files
You've already set up your build and just need to apply it in Kubernetes. Even if the only change was in the ConfigMap, you will need to roll out the pods. You want to apply just the prod ConfigMap, and you also need to substitute variables inside deployment.yml for some other value. Let's assume you want to change the image tag, so you can name your tag in the image line in deployment.yml with a placeholder, for example $IMAGE_TAG, like this:
image: nginx:$IMAGE_TAG
Then, pass the IMAGE_TAG as an environment variable with the desired value.
You can configure your pipeline like this:
name: Build
on:
push:
branches: [ main ]
workflow_dispatch:
env:
AWS_PROFILE_NAME: default
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
KUBECONFIG: ${{ secrets.KUBECONFIG }}
jobs:
deploy:
runs-on: ubuntu-latest
needs: build_and_push
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Deploy
uses: Pablommr/[email protected]
env:
FILES_PATH: kubernetes
KUBE_YAML: kubernetes/envs/prod/configmap.yaml
SUBPATH: false #Defaul value
ENVSUBST: true
KUBE_ROLLOUT: true
IMAGE_TAG: 1.21.6
In this setup, with FILES_PATH: kubernetes, you will apply all files under the kubernetes path (deployment.yaml and service.yaml), but none under env, since SUBPATH is set to false. However, you will still apply the ConfigMap with KUBE_YAML: kubernetes/envs/configmap.yaml.
- Add to broke pipeline in case of rollout failed
- Add KUBE_ROLLOUT_TIMEOUT option
- Alignment output logs
- Fix KUBE_YAML files
- Fix files validation in SUBPATH
- Fix to get resource name
- Add yq in background
- Added possibilitie to add path (env FILES_PATH) to apply multiple files
- Added env SUBPATH to apply files in supath
- Added env CONTINUE_IF_FAIL to continue applying files in fail case
- Added output on github action page
- Changed strategy to use an image that has already been built with dependencies in public registry kubernetes-eks, decreasing action execution time
- Added otpion to KUBE_ROLLOUT follow the rollout status in Action page
- Fix metacharacter replacement in ENVSUBST
- Project started
kubernetes-eks is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.