pipeline #5
This commit is contained in:
parent
47dc33c749
commit
a4aad68ee6
|
|
@ -109,65 +109,31 @@ jobs:
|
||||||
echo "📦 Image: ${IMAGE_NAME}"
|
echo "📦 Image: ${IMAGE_NAME}"
|
||||||
|
|
||||||
- name: Setup kubectl
|
- name: Setup kubectl
|
||||||
run: |
|
uses: azure/setup-kubectl@v3
|
||||||
# Download kubectl directly to avoid permission issues
|
with:
|
||||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
version: 'latest'
|
||||||
chmod +x kubectl
|
|
||||||
sudo mv kubectl /usr/local/bin/
|
|
||||||
kubectl version --client
|
|
||||||
|
|
||||||
- name: Configure kubectl
|
- name: Configure kubectl
|
||||||
env:
|
|
||||||
KUBECTLSECRET: ${{ secrets.KUBECTLSECRET }}
|
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.kube
|
mkdir -p ~/.kube
|
||||||
|
|
||||||
echo "🔍 Debugging KUBECTLSECRET..."
|
echo "🔍 Debugging KUBECTLSECRET..."
|
||||||
SECRET_LENGTH=${#KUBECTLSECRET}
|
echo "Secret length: ${#KUBECTLSECRET}"
|
||||||
echo "Secret length: $SECRET_LENGTH"
|
|
||||||
|
|
||||||
# Check if secret is empty
|
|
||||||
if [ "$SECRET_LENGTH" -eq 0 ]; then
|
|
||||||
echo "❌ ERROR: KUBECTLSECRET is empty!"
|
|
||||||
echo "Please configure the KUBECTLSECRET in Gitea repository secrets."
|
|
||||||
echo "Steps:"
|
|
||||||
echo "1. Run: cat ~/.kube/config | base64 -w 0"
|
|
||||||
echo "2. Copy the output"
|
|
||||||
echo "3. Add it as 'KUBECTLSECRET' secret in Gitea"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Try to decode as base64 first, if that fails, use as plain text
|
# Try to decode as base64 first, if that fails, use as plain text
|
||||||
if echo "$KUBECTLSECRET" | base64 -d > ~/.kube/config 2>/dev/null; then
|
if echo "${{ secrets.KUBECTLSECRET }}" | base64 -d > ~/.kube/config 2>/dev/null; then
|
||||||
echo "✅ KUBECTLSECRET decoded as base64"
|
echo "✅ KUBECTLSECRET decoded as base64"
|
||||||
else
|
else
|
||||||
echo "⚠️ KUBECTLSECRET is not base64, using as plain text"
|
echo "⚠️ KUBECTLSECRET is not base64, using as plain text"
|
||||||
echo "$KUBECTLSECRET" > ~/.kube/config
|
echo "${{ secrets.KUBECTLSECRET }}" > ~/.kube/config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "📁 kubeconfig created at ~/.kube/config"
|
echo "📁 kubeconfig created at ~/.kube/config"
|
||||||
chmod 600 ~/.kube/config
|
chmod 600 ~/.kube/config
|
||||||
|
|
||||||
# Validate kubeconfig
|
|
||||||
if [ ! -s ~/.kube/config ]; then
|
|
||||||
echo "❌ ERROR: kubeconfig file is empty!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add insecure-skip-tls-verify to handle self-signed certificates
|
|
||||||
echo "🔧 Configuring TLS settings for self-signed certificates..."
|
|
||||||
CURRENT_CONTEXT=$(kubectl config current-context)
|
|
||||||
CLUSTER_NAME=$(kubectl config view -o jsonpath="{.contexts[?(@.name=='$CURRENT_CONTEXT')].context.cluster}")
|
|
||||||
kubectl config set-cluster "$CLUSTER_NAME" --insecure-skip-tls-verify=true
|
|
||||||
|
|
||||||
echo "✅ kubeconfig validation and TLS configuration completed"
|
|
||||||
|
|
||||||
- name: Test kubectl connection
|
- name: Test kubectl connection
|
||||||
run: |
|
run: |
|
||||||
kubectl version --client
|
kubectl version --client
|
||||||
echo "Testing cluster connection..."
|
|
||||||
kubectl cluster-info
|
|
||||||
echo "Testing node access..."
|
|
||||||
kubectl get nodes
|
kubectl get nodes
|
||||||
|
|
||||||
- name: Deploy Feature Branch
|
- name: Deploy Feature Branch
|
||||||
|
|
@ -347,65 +313,31 @@ jobs:
|
||||||
echo "📦 Latest: ${LATEST_IMAGE}"
|
echo "📦 Latest: ${LATEST_IMAGE}"
|
||||||
|
|
||||||
- name: Setup kubectl
|
- name: Setup kubectl
|
||||||
run: |
|
uses: azure/setup-kubectl@v3
|
||||||
# Download kubectl directly to avoid permission issues
|
with:
|
||||||
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
version: 'latest'
|
||||||
chmod +x kubectl
|
|
||||||
sudo mv kubectl /usr/local/bin/
|
|
||||||
kubectl version --client
|
|
||||||
|
|
||||||
- name: Configure kubectl
|
- name: Configure kubectl
|
||||||
env:
|
|
||||||
KUBECTLSECRET: ${{ secrets.KUBECTLSECRET }}
|
|
||||||
run: |
|
run: |
|
||||||
mkdir -p ~/.kube
|
mkdir -p ~/.kube
|
||||||
|
|
||||||
echo "🔍 Debugging KUBECTLSECRET..."
|
echo "🔍 Debugging KUBECTLSECRET..."
|
||||||
SECRET_LENGTH=${#KUBECTLSECRET}
|
echo "Secret length: ${#KUBECTLSECRET}"
|
||||||
echo "Secret length: $SECRET_LENGTH"
|
|
||||||
|
|
||||||
# Check if secret is empty
|
|
||||||
if [ "$SECRET_LENGTH" -eq 0 ]; then
|
|
||||||
echo "❌ ERROR: KUBECTLSECRET is empty!"
|
|
||||||
echo "Please configure the KUBECTLSECRET in Gitea repository secrets."
|
|
||||||
echo "Steps:"
|
|
||||||
echo "1. Run: cat ~/.kube/config | base64 -w 0"
|
|
||||||
echo "2. Copy the output"
|
|
||||||
echo "3. Add it as 'KUBECTLSECRET' secret in Gitea"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Try to decode as base64 first, if that fails, use as plain text
|
# Try to decode as base64 first, if that fails, use as plain text
|
||||||
if echo "$KUBECTLSECRET" | base64 -d > ~/.kube/config 2>/dev/null; then
|
if echo "${{ secrets.KUBECTLSECRET }}" | base64 -d > ~/.kube/config 2>/dev/null; then
|
||||||
echo "✅ KUBECTLSECRET decoded as base64"
|
echo "✅ KUBECTLSECRET decoded as base64"
|
||||||
else
|
else
|
||||||
echo "⚠️ KUBECTLSECRET is not base64, using as plain text"
|
echo "⚠️ KUBECTLSECRET is not base64, using as plain text"
|
||||||
echo "$KUBECTLSECRET" > ~/.kube/config
|
echo "${{ secrets.KUBECTLSECRET }}" > ~/.kube/config
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "📁 kubeconfig created at ~/.kube/config"
|
echo "📁 kubeconfig created at ~/.kube/config"
|
||||||
chmod 600 ~/.kube/config
|
chmod 600 ~/.kube/config
|
||||||
|
|
||||||
# Validate kubeconfig
|
|
||||||
if [ ! -s ~/.kube/config ]; then
|
|
||||||
echo "❌ ERROR: kubeconfig file is empty!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Add insecure-skip-tls-verify to handle self-signed certificates
|
|
||||||
echo "🔧 Configuring TLS settings for self-signed certificates..."
|
|
||||||
CURRENT_CONTEXT=$(kubectl config current-context)
|
|
||||||
CLUSTER_NAME=$(kubectl config view -o jsonpath="{.contexts[?(@.name=='$CURRENT_CONTEXT')].context.cluster}")
|
|
||||||
kubectl config set-cluster "$CLUSTER_NAME" --insecure-skip-tls-verify=true
|
|
||||||
|
|
||||||
echo "✅ kubeconfig validation and TLS configuration completed"
|
|
||||||
|
|
||||||
- name: Test kubectl connection
|
- name: Test kubectl connection
|
||||||
run: |
|
run: |
|
||||||
kubectl version --client
|
kubectl version --client
|
||||||
echo "Testing cluster connection..."
|
|
||||||
kubectl cluster-info
|
|
||||||
echo "Testing node access..."
|
|
||||||
kubectl get nodes
|
kubectl get nodes
|
||||||
|
|
||||||
- name: Deploy to Production
|
- name: Deploy to Production
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue