This commit is contained in:
parent
b41af4f3fe
commit
fa17a5399f
@ -1,8 +1,10 @@
|
|||||||
name: k3s
|
name: CI
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
pull_request:
|
||||||
|
branches: [ "main" ]
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
@ -14,8 +16,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install kubectl
|
- name: Install kubectl
|
||||||
env:
|
env:
|
||||||
K3S_TOKEN: ${{ secrets.K3S_TOKEN }}
|
KUBE_CONFIG: ${{ secrets.K3S_CONFIG }}
|
||||||
K3S_CERT: ${{ secrets.K3S_CERT }}
|
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
# Fetch the latest stable version of kubectl
|
# Fetch the latest stable version of kubectl
|
||||||
@ -45,36 +46,8 @@ jobs:
|
|||||||
mv kubelogin/kubelogin kubelogin/kubectl-oidc_login
|
mv kubelogin/kubelogin kubelogin/kubectl-oidc_login
|
||||||
export PATH=$PATH:$(realpath kubelogin)
|
export PATH=$PATH:$(realpath kubelogin)
|
||||||
|
|
||||||
# Create the kubeconfig file with the K3S_TOKEN and K3S_CERT
|
# Configure kubeconfig
|
||||||
mkdir -p ~/.kube
|
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 delete -f kubernetes.yaml
|
||||||
kubectl apply -f kubernetes.yaml
|
kubectl apply -f kubernetes.yaml
|
||||||
Loading…
Reference in New Issue
Block a user