GitHub Actions workflow is always failing with provided KUBECONFIG

Hi Guys,

Somehow kubectl version is failing even if we set KUBECONFIG ( given in the course) in github actions. I’ve almost tried 20 different ways to check if I’m wrong anywhere , Can someone help is there any mistake in kubeconfig itself in the course, Anyone faced this issue before ?

dev-deploy:
needs: docker
runs-on: ubuntu-latest
environment:
name: development
steps:
- uses: actions/checkout@v4
- uses: azure/setup-kubectl@v4
with:
version: v1.31.0
- uses: azure/k8s-set-context@v4
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBECONFIG }}
context: default # current-context from kubeconfig is used as default
- run: kubectl version -o yaml

I’m not a fan of this particular lab, because for a Github Action to actually use a kubeconfig file, the cluster described in the kubeconfig file needs to be accessible to Github. IIRC, the file used in the example assumes the cluster is available on localhost, which is absurd – you can run kubectl config and similar commands that do not involve the server, which is not very useful.

What will work is to use a kubeconfig file that points to a cluster with a public IP address, which you’d also have to set up yourself.