Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the default Kubeconfig or allow using it #18

Open
NasAmin opened this issue Jul 29, 2020 · 5 comments
Open

Use the default Kubeconfig or allow using it #18

NasAmin opened this issue Jul 29, 2020 · 5 comments
Milestone

Comments

@NasAmin
Copy link

NasAmin commented Jul 29, 2020

Hi,

First of all, thanks for creating this action!
I have tried to use this action where I am deploying to an EKS cluster. So I am using other actions that sets up aws credentials and kubernetes clusters like these

      - name: Configure AWS credentials for EKS deployment
        uses: aws-actions/configure-aws-credentials@v1
        with:
          aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws-region: ${{ secrets.EKS_REGION }}

      - name: Setup kubeconfig
        id: setup-kubeconfig
        run: |
          aws eks --region ${{ secrets.EKS_REGION }} update-kubeconfig --name ${{ secrets.EKS_CLUSTER_NAME }}

However, the entrypoint.sh script seems to be always overwriting the contents of the default kubeconfig.
Can we make than optional and use a flag like USE_DEFAULT_KUBECONFIG=false.
So we can then override this flag and set it to true.
If true then we skip creating the kubeconfig and also the cleanup.

Is that doable?

Regards,

Nas

@WyriHaximus
Copy link
Owner

Did some research in #19 and there are a few options. A) you grab the file from the filesystem and pass it into the action, or B) you put it in ./ (your workspace directory). Since this action runs a Docker container it doesn't have access to the default ~/ (/home/runner/) but instead has access to the workspaces you're in by default.

You can try option B out with:

      - run: mkdir ./.kube -p || true
      - run: cp ~/.kube/config ./.kube/
      - name: Deploy
        uses: WyriHaximus/github-action-helm3@use-existing-kubeconfig-when-available
        with:
          exec: helm COMMAND
      - run: rm ./.kube/config -fR

@WyriHaximus WyriHaximus mentioned this issue Aug 2, 2020
@WyriHaximus WyriHaximus added this to the v2.2.0 milestone Aug 13, 2020
@WyriHaximus
Copy link
Owner

@NasAmin haven't forgotten about this. The main issue lies in that this is a Docker based action, so I'm going to change it over to a nodejs based action and add helm as a bin command so that the UI doesn't change. But it should provide access to ~/.kube/config more naturally

@devsibwarra
Copy link

devsibwarra commented Sep 24, 2020

I was able to get a successful Helm deployment with this action using

      - name: Copy kubectl config to output for helm deploy
        id: kube
        run: |
          CONFIG="$(cat ${HOME}/.kube/config)"
          CONFIG="${CONFIG//'%'/'%25'}"
          CONFIG="${CONFIG//$'\n'/'%0A'}"
          CONFIG="${CONFIG//$'\r'/'%0D'}"
          echo "::set-output name=config::$CONFIG"
      - name: Deploy
        uses: WyriHaximus/github-action-helm3@v2
        with:
          exec: helm ...
          kubeconfig: '${{ steps.kube.outputs.config }}'

I needed several CONFIG set lines due to set-output truncating multiline strings

edit: re-reading your comment above, this seems like option A. Now with an example!

@WyriHaximus
Copy link
Owner

So when I initially created this action, there was no Helm 3 on GA yet. These days it does, so I'm going to change this action to by just running the script provided, in #19. And also include a deprecation notice that you can now use it directly on GA without the need for an GA. Not sure about the future, but will keep the repo around for when Helm4 might popup to ensure you don't accidentally run v4 when you need v3 or something like that.

@WyriHaximus
Copy link
Owner

For those interested: #29 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants