ci: deployment debugging
Some checks failed
/ build-and-push (push) Successful in 1m29s
/ deploy (push) Failing after 52s

This commit is contained in:
Mattias Wiberg 2025-06-09 22:04:05 +02:00
parent 8ab94c0cb3
commit 81ee90f1bc

View file

@ -62,8 +62,8 @@ jobs:
run: | run: |
COMMIT_HASH=$(echo ${GITHUB_SHA} | cut -c1-7) COMMIT_HASH=$(echo ${GITHUB_SHA} | cut -c1-7)
VERSION_TAG="${COMMIT_HASH}" VERSION_TAG="${COMMIT_HASH}"
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_OUTPUT echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_OUTPUT - name: Set up kubectl
- name: Set up kubectl - name: Set up kubectl
run: | run: |
# Install kubectl # Install kubectl
@ -72,6 +72,13 @@ jobs:
curl -LO "https://dl.k8s.io/release/$KUBE_VERSION/bin/linux/amd64/kubectl" curl -LO "https://dl.k8s.io/release/$KUBE_VERSION/bin/linux/amd64/kubectl"
chmod +x kubectl chmod +x kubectl
mv kubectl /usr/local/bin/ 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 - name: Set up Helm
run: | run: |
@ -83,11 +90,14 @@ jobs:
# Create kubeconfig using service account token # Create kubeconfig using service account token
- name: Configure kubeconfig from service account - name: Configure kubeconfig from service account
run: | run: |
# Create kubeconfig using service account token # Create a dedicated kubeconfig file for this job
mkdir -p $HOME/.kube CONFIG_FILE="$HOME/custom-kubeconfig"
cat > $HOME/.kube/config <<EOF
# Create fresh config with explicit server URL
cat > $CONFIG_FILE <<EOF
apiVersion: v1 apiVersion: v1
kind: Config kind: Config
preferences: {}
clusters: clusters:
- name: cluster - name: cluster
cluster: cluster:
@ -105,11 +115,27 @@ jobs:
namespace: ${{ env.NAMESPACE }} namespace: ${{ env.NAMESPACE }}
current-context: default current-context: default
EOF EOF
chmod 600 $HOME/.kube/config chmod 600 $CONFIG_FILE
# Set KUBECONFIG environment variable to use our config
echo "KUBECONFIG=$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 - name: Deploy with Helm
run: | run: |
# Deploy using Helm with service account authentication # 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 }} \ helm upgrade --install nextjs-slack-clone ${{ env.HELM_CHART_PATH }} \
--namespace ${{ env.NAMESPACE }} \ --namespace ${{ env.NAMESPACE }} \
--set image.tag=${{ steps.generate_tag.outputs.VERSION_TAG }} \ --set image.tag=${{ steps.generate_tag.outputs.VERSION_TAG }} \