Update .gitea/workflows/k3s.yaml
This commit is contained in:
parent
d61836080a
commit
0e05fca4a2
@ -14,7 +14,8 @@ jobs:
|
||||
|
||||
- name: Install kubectl
|
||||
env:
|
||||
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
|
||||
K3S_TOKEN: ${{ secrets.K3S_TOKEN }}
|
||||
K3S_CERT: ${{ secrets.K3S_CERT }}
|
||||
shell: bash
|
||||
run: |
|
||||
# Fetch the latest stable version of kubectl
|
||||
@ -44,8 +45,36 @@ jobs:
|
||||
mv kubelogin/kubelogin kubelogin/kubectl-oidc_login
|
||||
export PATH=$PATH:$(realpath kubelogin)
|
||||
|
||||
# Configure kubeconfig
|
||||
# Create the kubeconfig file with the K3S_TOKEN and K3S_CERT
|
||||
mkdir -p ~/.kube
|
||||
echo "$KUBE_CONFIG" > ~/.kube/config
|
||||
|
||||
# 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
|
||||
kubectl delete -f kubernetes.yaml
|
||||
kubectl apply -f kubernetes.yaml
|
||||
kubectl apply -f kubernetes.yaml
|
||||
|
||||
Loading…
Reference in New Issue
Block a user