File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ on :
3+ push :
4+ branches :
5+ - main
6+ paths :
7+ - .github/workflows/kubeconfig.yml
8+ - kubeconfig/**
9+ jobs :
10+ kubeconfig :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - name : Checkout
14+ uses : actions/checkout@v2
15+ with :
16+ submodules : true
17+ - name : Login
18+ uses : docker/login-action@v1
19+ with :
20+ username : ${{ secrets.DOCKER_HUB_USERNAME }}
21+ password : ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
22+ - name : Setup QEMU
23+ uses : docker/setup-qemu-action@v1
24+ - name : Setup Docker
25+ uses : docker/setup-buildx-action@v1
26+ - name : Build Docker
27+ uses : docker/build-push-action@v2
28+ with :
29+ push : true
30+ context : ${{ github.job }}
31+ file : ${{ github.job }}/Dockerfile
32+ platforms : linux/amd64
33+ tags : ${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.job }}:latest
34+ cache-from : type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.job }}:buildcache
35+ cache-to : type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.job }}:buildcache,mode=max
36+ - name : Push Docker Description
37+ uses : peter-evans/dockerhub-description@v2
38+ with :
39+ username : ${{ secrets.DOCKER_HUB_USERNAME }}
40+ password : ${{ secrets.DOCKER_HUB_PASSWORD }}
41+ repository : ${{ secrets.DOCKER_HUB_USERNAME }}/${{ github.job }}
42+ short-description : ' 使用参考 README,信息参考:https://www.dosk.win/'
Original file line number Diff line number Diff line change 1+ FROM bitnami/kubectl:latest
2+ COPY gen-kubeconfig.sh /usr/local/bin/gen-kubeconfig
3+ WORKDIR /kube
4+ ENTRYPOINT ["/usr/local/bin/gen-kubeconfig" ]
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ set -e
3+
4+ TOKEN=$( cat /var/run/secrets/kubernetes.io/serviceaccount/token)
5+ CA=/var/run/secrets/kubernetes.io/serviceaccount/ca.crt
6+ NS=$( cat /var/run/secrets/kubernetes.io/serviceaccount/namespace)
7+ APISERVER=" https://${KUBERNETES_SERVICE_HOST} :${KUBERNETES_SERVICE_PORT} "
8+
9+ cat << EOF > /kube/config
10+ apiVersion: v1
11+ kind: Config
12+ clusters:
13+ - cluster:
14+ certificate-authority: ${CA}
15+ server: ${APISERVER}
16+ name: in-cluster
17+ contexts:
18+ - context:
19+ cluster: in-cluster
20+ namespace: ${NS}
21+ user: sa
22+ name: in-cluster
23+ current-context: in-cluster
24+ users:
25+ - name: sa
26+ user:
27+ token: ${TOKEN}
28+ EOF
29+
30+ echo " ✅ kubeconfig written to /kube/config"
You can’t perform that action at this time.
0 commit comments