github action kubeadm编译证书100年
github action kubeadm编译证书100年
直接fork官网kubernets 然后创建工作流 参考地址
name: Build kubeadm 99 year
on:
push:
tags:
- 'v*'
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Dump GitHub context
run: echo "RELEASE_VERSION=${GITHUB_REF:10}" >> $GITHUB_ENV
#run: echo "NOW::$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_ENV
- name: Get Env
run: echo '${{ env.RELEASE_VERSION }}'
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
ref: ${{ env.RELEASE_VERSION }}
- name: Sed Env
run: |
sed -i "s/365/365 * 99/" /home/runner/work/kubernetes/kubernetes/cmd/kubeadm/app/constants/constants.go
sed -i "s/10)/99)/" /home/runner/work/kubernetes/kubernetes/staging/src/k8s.io/client-go/util/cert/cert.go
- name: Get Env
run: |
find . -name constants.go |xargs cat |grep 365
find . -name cert.go |xargs cat |grep 365d
#- name: github
# run: git clone --branch v1.18.2 https://github.com/kubernetes/kubernetes.git
# - name: Get dependencies
# run: |
# go get -v -t -d ./...
# if [ -f Gopkg.toml ]; then
# curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
# dep ensure
# fi
- name: Get workpath
run: pwd
#- name: 切换分支
# run: git checkout v1.18.2
- name: Build
run: KUBE_GIT_TREE_STATE=clean make all WHAT=cmd/kubeadm GOFLAGS=-v
- name: Get paGth
run: find . -name kubeadm
- name: Kubeadm version
run: |
chmod +x ./_output/local/bin/linux/amd64/kubeadm
./_output/local/bin/linux/amd64/kubeadm version
#制品库打包
- name: Upload assets
run: |
mkdir myki
cp ./_output/local/bin/linux/amd64/kubeadm kubeadm-${{ env.RELEASE_VERSION }}
sha256sum kubeadm-${{ env.RELEASE_VERSION }} > kubeadm-${{ env.RELEASE_VERSION }}.sha256sum.txt
#制品库上传
- name: Release and upload binary file
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
kubeadm-${{ env.RELEASE_VERSION }}
kubeadm-${{ env.RELEASE_VERSION }}.sha256sum.txt
# - uses: actions/upload-artifact@v2
# with:
# name: kubeadm-${{ env.RELEASE_VERSION }}
# path: myki
自己编译
git reset --hard v1.22.3
mkdir .github/workflows/
curl -o .github/workflows/kubeadm.yml https://github.com/21ki/github-action/raw/main/kubeadm-build-99year/kubeadm.yml
git add .github/workflows/kubeadm.yml
git commit -am "kubeadm_build"
git tag v1.22.3-patch-1.0 -f
git push origin v1.22.3-patch-1.0 -f
然后执行证书更新命令
cp -r /etc/kubernetes/pki /etc/kubernetes/pki.origin
kubeadm init phase kubeconfig all --config initconfig.yaml
cp -dprf /etc/kubernetes/*.conf /opt/
kubeadm init phase kubeconfig all --config initconfig.yaml
cp /etc/kubernetes/admin.conf ~/.kube/config
#重启容器
docker ps | grep -v pause | grep -E "etcd|scheduler|controller|apiserver" | awk '{print $1}' | awk '{print "docker","restart",$1}' | bash
#查看证书时间
kubeadm alpha certs check-expiration
文章作者 🐳Myki
上次更新 2020-06-20