koslib/helm-eks-action

Support using aws CLI's eks update-kubeconfig command

erran opened this issue ยท 5 comments

erran commented

๐Ÿ‘‹๐Ÿฝ 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

Closing since I figured out how to add a simple step to accomplish my goal: WyriHaximus/github-action-helm3#18 (comment)

      - 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. ๐Ÿ˜„

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

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

Dropping this as a note to myself/others for tracking โ€” I also found actions-hub/gcloud#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

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.