项目作者: koslib

项目描述 :
Github Action for executing Helm commands on EKS (using aws-iam-authenticator)
高级语言: Dockerfile
项目地址: git://github.com/koslib/helm-eks-action.git
创建时间: 2020-07-24T20:12:59Z
项目社区:https://github.com/koslib/helm-eks-action

开源协议:MIT License

下载


helm-eks-action

Github Action for executing Helm commands on EKS (using aws-iam-authenticator).

The Helm version installed is Helm3.

This action was inspired by kubernetes-action.

Instructions

This Github Action was created with EKS in mind, therefore the following example refers to it.

Input variables

  1. plugins: you can specify a list of Helm plugins you’d like to install and use later on in your command. eg. helm-secrets or helm-diff. This action does not support only a specific list of Helm plugins, rather any Helm plugin as long as you supply its URL. You can use the following example as a reference.
  2. command: your kubectl/helm command. This supports multiline as per the Github Actions workflow syntax.

example for multiline:

  1. ...
  2. with:
  3. command: |
  4. helm upgrade --install my-release chart/repo
  5. kubectl get pods

Example

  1. name: deploy
  2. on:
  3. push:
  4. branches:
  5. - master
  6. - develop
  7. jobs:
  8. deploy:
  9. runs-on: ubuntu-latest
  10. env:
  11. AWS_REGION: us-east-1
  12. CLUSTER_NAME: my-staging
  13. steps:
  14. - uses: actions/checkout@v3
  15. - name: AWS Credentials
  16. uses: aws-actions/configure-aws-credentials@v1
  17. with:
  18. role-to-assume: arn:aws:iam::<your account id>:role/github-actions
  19. role-session-name: ci-run-${{ github.run_id }}
  20. aws-region: ${{ env.AWS_REGION }}
  21. - name: kubeconfig
  22. run: |
  23. aws eks update-kubeconfig --name ${{ env.CLUSTER_NAME }} --region ${{ env.AWS_REGION }} --kubeconfig ./kubeconfig
  24. echo 'KUBE_CONFIG_DATA<<EOF' >> $GITHUB_ENV
  25. echo $(cat ./kubeconfig | base64) >> $GITHUB_ENV
  26. echo 'EOF' >> $GITHUB_ENV
  27. - name: helm deploy
  28. uses: koslib/helm-eks-action@master
  29. env:
  30. KUBE_CONFIG_DATA: ${{ env.KUBE_CONFIG_DATA }}
  31. with:
  32. plugins: "https://github.com/jkroepke/helm-secrets" # optional
  33. command: helm secrets upgrade <release name> --install --wait <chart> -f <path to values.yaml>

Response

Use the output of your command in later steps

  1. steps:
  2. - name: Get URL
  3. id: url
  4. uses: koslib/helm-eks-action@master
  5. with:
  6. command: kubectl get svc my_svc -o json | jq -r '.status.loadBalancer.ingress[0].hostname'
  7. - name: Print Response
  8. run: echo "Response was ${{ steps.url.outputs.response }}"

Main dependencies version table

The latest version of this action uses the following dependencies versions:

Package Version
awscli 1.24.0
helm 3.10.1
kubectl 1.25.4

It is very much possible that an update came out and I did not update the action on time. In this please, feel free to send me a PR and I’ll review it as soon as possible.

Accessing your cluster

It is required to set the KUBE_CONFIG_DATA env/secret in order to access your cluster. I recommend you do it dynamically using a step like that:

  1. - name: kubeconfig
  2. run: |
  3. aws eks update-kubeconfig --name ${{ env.CLUSTER_NAME }} --region ${{ env.AWS_REGION }} --kubeconfig ./kubeconfig
  4. echo 'KUBE_CONFIG_DATA<<EOF' >> $GITHUB_ENV
  5. echo $(cat ./kubeconfig | base64) >> $GITHUB_ENV
  6. echo 'EOF' >> $GITHUB_ENV

If you find this configuration option complicated, you can still supply KUBE_CONFIG_DATA as a repository secret, however this is not endorsed by this repository.

Contributing

Pull requests, issues or feedback of any kind are more than welcome by anyone!

If this action has helped you in any way and enjoyed it, feel free to submit feedback through issues or buy me a coffee!

Buy Me A Coffee