I am building CI/CD pipeline on Github Actions to build image, push it to registry and then deploy it with the helm chart. Here is my workflow:
name: CI/CD Build pipeline
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Build container image
run: docker build -t ${{ secrets.REGISTRY_NAME }}/mini-app:$(echo $GITHUB_SHA | head -c7) .
- name: Log in to DigitalOcean Container Registry with short-lived credentials
run: doctl registry login --expiry-seconds 12000 --access-token ${{ secrets.TEST_DIGITALOCEAN_ACCESS_TOKEN }} -v
- name: Push image to DigitalOcean Container Registry
run: docker push ${{ secrets.REGISTRY_NAME }}/mini-app:$(echo $GITHUB_SHA | head -c7)
- name: Save DigitalOcean kubeconfig with short-lived credentials
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 1200 cluster-name
- name: Install helm
uses: azure/setup-helm@v1
with:
version: 'v3.5.2'
id: install
- name: Deploy to staging
uses: WyriHaximus/github-action-helm3@v3
with:
exec: helm upgrade --install app helm/ -f $GITHUB_WORKSPACE/charts/VALUES_LOCATION.yaml --set image.tag=$(echo $GITHUB_SHA | head -c7) --namespace app
kubeconfig: '/home/runner/.kube/config'
overrule_existing_kubeconfig: "true"
There is an issue on the deploy step. Deploy process is failing due to error:
Run WyriHaximus/github-action-helm3@v3
PWD: /home/runner/work/app/app
Existing kubeconfig found, but provided kubeconfig is overruling it
Will be swapping out existing kubeconfig for the duration of the execution of this action
Preparing helm execution
Executing helm
WARNING: Kubernetes configuration file is group-readable. This is insecure. Location: /home/runner/.kube/config
WARNING: Kubernetes configuration file is world-readable. This is insecure. Location: /home/runner/.kube/config
Error: Kubernetes cluster unreachable: error loading config file "/home/runner/.kube/config": couldn't get version/kind; json parse error: json: cannot unmarshal string into Go value of type struct { APIVersion string "json:"apiVersion,omitempty""; Kind string "json:"kind,omitempty"" }
Have anybody ever faced this kind of situation? Is it an issue on the step of saving kubeconfig (kubernetes cluster kubeconfig save)? How to fix it?
Thanks in advance!