koslib / helm-eks-action

The simplest Github Action for executing Helm commands on EKS - cluster authentication included
MIT License
61 stars 61 forks source link

Support using aws CLI's eks update-kubeconfig command #8

Closed erran closed 3 years ago

erran commented 3 years ago

👋🏽 Hey @koslib what are your thoughts on leveraging update-kubeconfig as per Amazon's Create kubeconfig documentation? I'd be happy to contribute if it's something you're interested in.

We'd be able to optionally use this over KUBE_CONFIG_DATA using a few new arguments under with: like so:

  1. cluster_name which is passed into the update-kubeconfig command's --name argument.
  2. update_kubeconfig_path which if supplied is passed into the update-kubeconfig command's --kubeconfig argument.
# generates kubeconfig in the default kubeconfig location
aws eks --region us-east-1 update-kubeconfig --name my-staging-cluster

# generates kubeconfig in the specified location
aws eks --region us-east-1 update-kubeconfig --name my-staging-cluster --kubeconfig kubeconfig-staging
erran commented 3 years ago

Closing since I figured out how to add a simple step to accomplish my goal: https://github.com/WyriHaximus/github-action-helm3/issues/18#issuecomment-698582423

      - name: Generate kubeconfig
        id: generate-kubeconfig
        run: |-
          aws eks --region ${{ env.AWS_REGION }} update-kubeconfig --name ${{ env.CLUSTER_NAME }}
          KUBECONFIG="$(cat ~/.kube/config)"
          KUBECONFIG="${KUBECONFIG//'%'/'%25'}"
          KUBECONFIG="${KUBECONFIG//$'\n'/'%0A'}"
          KUBECONFIG="${KUBECONFIG//$'\r'/'%0D'}"
          echo "::set-output name=kubeconfig::$KUBECONFIG"

Since similar to how it is described in that issue this is a docker action I'll close this out since access could be tricky. 😄

koslib commented 3 years ago

Hello @erran, this is actually great stuff! I hadn't thought of that at all to be honest, but it seems like a great option to have. Do you think contributing docs in this action for this would be useful for other users too? If yes, feel free to send in a PR and we can discuss further if "internal" support for this would make more sense in the future!

Thanks for the great idea once again!

erran commented 3 years ago

I’d be happy to contribute a docs update around this and I’ll make sure to include how I was able to use the output with this action. 😃

erran commented 3 years ago

Dropping this as a note to myself/others for tracking — I also found https://github.com/actions-hub/gcloud/issues/11 when I got an error from this action base64: truncated base64 input. My above snippet will need to be updated to base64 encode the output.

erran commented 3 years ago

Sorry for not updating anyone sooner. In my use case I ended up using the built-in helm binary instead of this action due to issues using the KUBECONFIG environment variable regardless of what I tried with base64 decoding/replacing newlines.