Update .gitea/workflows/k3s.yaml
Some checks failed
CI / build (push) Failing after 20s

This commit is contained in:
jonas 2025-03-13 08:32:13 +00:00
parent b41af4f3fe
commit fa17a5399f

View File

@ -1,8 +1,10 @@
name: k3s
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
@ -14,8 +16,7 @@ jobs:
- name: Install kubectl
env:
K3S_TOKEN: ${{ secrets.K3S_TOKEN }}
K3S_CERT: ${{ secrets.K3S_CERT }}
KUBE_CONFIG: ${{ secrets.K3S_CONFIG }}
shell: bash
run: |
# Fetch the latest stable version of kubectl
@ -45,36 +46,8 @@ jobs:
mv kubelogin/kubelogin kubelogin/kubectl-oidc_login
export PATH=$PATH:$(realpath kubelogin)
# Create the kubeconfig file with the K3S_TOKEN and K3S_CERT
# Configure kubeconfig
mkdir -p ~/.kube
# Base64 decode the K3S_CERT and write it to a file
echo "$K3S_CERT" | base64 --decode > ~/.kube/ca.crt
# Create the kubeconfig file
cat <<EOF > ~/.kube/config
apiVersion: v1
kind: Config
clusters:
- name: k3s-cluster
cluster:
certificate-authority: ~/.kube/ca.crt
server: https://kubernetes.default.svc:6443
users:
- name: k3s-user
user:
token: ${K3S_TOKEN}
contexts:
- name: k3s-context
context:
cluster: k3s-cluster
user: k3s-user
current-context: k3s-context
EOF
# Test the kubeconfig setup by printing the cluster info
kubectl cluster-info
# Apply Kubernetes configuration
echo "$KUBE_CONFIG" > ~/.kube/config
kubectl delete -f kubernetes.yaml
kubectl apply -f kubernetes.yaml