From 6173b73cfba01d750b425026ce6a9b423a8369f0 Mon Sep 17 00:00:00 2001 From: Mattias Wiberg Date: Mon, 9 Jun 2025 22:04:05 +0200 Subject: [PATCH] ci: deployment debugging --- .forgejo/workflows/build-and-deploy.yaml | 41 ++++++++++++++++++------ 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/.forgejo/workflows/build-and-deploy.yaml b/.forgejo/workflows/build-and-deploy.yaml index 6e23112..ef72fa1 100644 --- a/.forgejo/workflows/build-and-deploy.yaml +++ b/.forgejo/workflows/build-and-deploy.yaml @@ -62,9 +62,7 @@ jobs: run: | COMMIT_HASH=$(echo ${GITHUB_SHA} | cut -c1-7) VERSION_TAG="${COMMIT_HASH}" - echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_OUTPUT - - - name: Set up kubectl + echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_OUTPUT - name: Set up kubectl run: | # Install kubectl curl -LO "https://dl.k8s.io/release/stable.txt" @@ -72,6 +70,13 @@ jobs: curl -LO "https://dl.k8s.io/release/$KUBE_VERSION/bin/linux/amd64/kubectl" chmod +x kubectl mv kubectl /usr/local/bin/ + + # Make sure we don't use any existing microk8s config + if [ -f /var/snap/microk8s/current/credentials/client.config ]; then + echo "Detected microk8s config - we'll use our own config instead" + # Backup any existing config and make sure it won't be used + [ -d $HOME/.kube ] && mv $HOME/.kube $HOME/.kube.bak + fi - name: Set up Helm run: | @@ -80,14 +85,16 @@ jobs: chmod +x get_helm.sh ./get_helm.sh - # Create kubeconfig using service account token - - name: Configure kubeconfig from service account + # Create kubeconfig using service account token - name: Configure kubeconfig from service account run: | - # Create kubeconfig using service account token - mkdir -p $HOME/.kube - cat > $HOME/.kube/config < $CONFIG_FILE <> $GITHUB_ENV + + # Verify the config is pointing to the correct server + echo "Checking kubectl configuration..." + KUBECTL_SERVER=$(KUBECONFIG=$CONFIG_FILE kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}') + echo "Kubectl is configured to use server: $KUBECTL_SERVER"- name: Verify Kubernetes connectivity + run: | + # Test connectivity to the Kubernetes cluster + echo "Testing Kubernetes API connectivity..." + kubectl cluster-info + kubectl get nodes + - name: Deploy with Helm run: | # Deploy using Helm with service account authentication + echo "Deploying with Helm to server: $(kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}')" helm upgrade --install nextjs-slack-clone ${{ env.HELM_CHART_PATH }} \ --namespace ${{ env.NAMESPACE }} \ --set image.tag=${{ steps.generate_tag.outputs.VERSION_TAG }} \