Action to apply artifacts files in your EKS cluster.
This action enables you to apply kubernetes artifacts files just pointing the path where your file is.
name: Build
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Deployment
uses: Pablommr/kubernetes-eks@v1.2.0
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 have heve permission to apply artifacts in your EKS cluster (More info see in this link), and setup some ENV's variables listed next.
AWS access key id for IAM role.
AWS secret key for IAM role.
Environment variable name containing base64-encoded kubeconfig data. Need atention with profile name that must be the same in AWS_PROFILE_NAME.
Path to file used to create/update the resource.
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)
Whether to watch the status of the latest rollout until it's done. The rollout onlly works to deployment/statefulset/daemonset and only be executed if the POD's applyed by KUBE_YAML finalize with unchaged status.
Let's suppose you need apply 3 artifacts in you EKS, one deployment, one service, and one configmap, add all your kubernetes artifacts are inside in folder kubernetes, some like this:
├── README.md
├── app
| └── files
├── kubernetes
| ├── service.yml
| ├── configmap.yaml
| └── deployment.yml
└── another_files
You already set up your build and just need apply in your kubernetes. You have the premise that always the pipeline run, even that change was in the configmap for exemple, you will need rollout the pods, and you will need too substitute your variables inside deployment.yml for some another value. Let's assume you want to change the image tag, so you can name your tag in image line in deployment.yml with some name, for example $IMAGE_TAG, like this:
image: nginx:$IMAGE_TAG
And then pass the IMAGE_TAG as a env with value wished.
So, you can configure your pipeline in this way:
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@v3
-
name: Service
uses: Pablommr/kubernetes-eks@v1.2.0
env:
KUBE_YAML: kubernetes/service.yml
-
name: Configmap
uses: Pablommr/kubernetes-eks@v1.2.0
env:
KUBE_YAML: kubernetes/configmap.yml
-
name: Deployment
uses: Pablommr/kubernetes-eks@v1.2.0
env:
KUBE_YAML: kubernetes/deployment.yml
ENVSUBST: true
KUBE_ROLLOUT: true
IMAGE_TAG: 1.21.6
- Changed strategy to use an image that has already been built with dependencies in public registry kubernetes-eks, decreasing action execution time
- Add otpion to KUBE_ROLLOUT follow the rollout status in Action page
- Fix metacharacter replacement in ENVSUBST
- Project started