Azure / k8s-deploy

GitHub Action for deploying to Kubernetes clusters
MIT License
252 stars 103 forks source link

Bug: Unable to get config, even after using `k8s-set-context` #280

Open pilotkid opened 1 year ago

pilotkid commented 1 year ago

What happened?

Unable to successfully authenticate cluster

KUBE_CONFIG has been validated by using the following command

- uses: actions-hub/kubectl@master
  env:
    KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
  with:
    args: get pods

The workflow file is as follows


name: Deploy test site
on:
  push:
    branches:
      - master
  workflow_dispatch:      
jobs:
  build-and-deploy:
    timeout-minutes: 30
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@master

      - name: Validate KUBE_CONFIG
        uses: actions-hub/kubectl@master
        env:
          KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
        with:
          args: get pods

      - name: Login to Container Registry
        uses: docker/login-action@v2
        with:
          registry: ${{ secrets.REGISTRY_IP }}
          username: ${{ secrets.REGISTRY_USERNAME }}
          password: ${{ secrets.REGISTRY_KEY }}

      - name: Build Docker container
        run: docker build --pull --rm -f "dockerfile" -t shooter-api:latest "."

      - name: Push Image To Registry
        run: |
          docker tag shooter-api:latest ${{ secrets.REGISTRY_IP }}/straight-score/shooter-api:${{ github.sha }}
          docker push ${{ secrets:REGISTRY_IP }}/straight-score/shooter-api:${{ github.sha }}

      - uses: azure/setup-kubectl@v2.0

      - uses: Azure/k8s-set-context@v2
        with:
          kubeconfig: ${{ secrets.KUBE_CONFIG }}

      - uses: Azure/k8s-deploy@v4
        with:
          action: deploy
          strategy: basic
          namespace: 'default'
          manifests: |
              kube/next
          images: '${{ secrets.REGISTRY_IP }}/straight-score/shooter-api:${{ github.sha }}'
          force: true

Version

Runner

Github Ubuntu-latest

Relevant log output

Run Azure/k8s-deploy@v4
Unexpected error attempting to determine if executable file exists '/usr/local/bin/kubectl/kubectl': Error: ENOTDIR: not a directory, stat '/usr/local/bin/kubectl/kubectl'
Deploying manifests
  /opt/hostedtoolcache/kubectl/1.26.1/x64/kubectl apply -f /tmp/deployment.yaml,/tmp/ingress.yaml,/tmp/service.yaml --force --namespace default
  error: error loading config file "/home/runner/work/_temp/kubeconfig_167635718[23](https://github.com/Straight-Score/shooter-api/actions/runs/4171189337/jobs/7220872590#step:13:24)89": 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\"" }
  Error: Error: undefined
OliverMKing commented 1 year ago

@pilotkid can you try again with bumping azure/setup-kubectl and azure/k8s-set-context to v3?

Based on the error message, it looks like your Kubeconfig is unable to be parsed correctly. I wonder if it is in a different format. Could you post the general format of your Kubeconfig (with the important information redacted)?

github-actions[bot] commented 1 year ago

This issue is idle because it has been open for 14 days with no activity.