: Run a command in a build docker container. Common invocations:
build/run.sh make: Build just linux binaries in the container. Pass options and packages as necessary.
build/run.sh make cross: Build all binaries for all platforms. To build only a specific platform, add KUBE_BUILD_PLATFORMS=<os>/<arch>
build/run.sh make kubectl KUBE_BUILD_PLATFORMS=darwin/amd64: Build the specific binary for the specific platform (kubectl and darwin/amd64 respectively in this example)
build/run.sh make test: Run all unit tests
build/run.sh make test-integration: Run integration test
// CertificateValidity defines the validity for all the signed certificates generated by kubeadm - CertificateValidity = time.Hour * 24 * 365 + CertificateValidity = time.Hour * 24 * 3650
// CACertAndKeyBaseName defines certificate authority base name CACertAndKeyBaseName = "ca"
// CertificateValidity defines the validity for all the signed certificates generated by kubeadm - CertificateValidity = time.Hour * 24 * 365 + CertificateValidity = time.Hour * 24 * 3650
// CACertAndKeyBaseName defines certificate authority base name CACertAndKeyBaseName = "ca"
cherry-pick
在分支上完成修改之后,我们将这个修改 cherry-pick 到其他的 tag 上面去,下面以 v1.21.4 为例子:在 v1.21.4 tag 的基础之上将上述的修改 cherry-pick 过来,重新打上新的 tag。
获取上述修改的 commit id
1
$ COMMIT_ID=$(git rev-parse HEAD)
checkout 到 v1.21.4 这个 tag 上
1 2 3 4 5 6 7 8 9 10 11
$ git checkout v1.21.4 Note: checking out 'v1.21.4'.
You are in'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:
HEAD is now at 3cce4a82b44 Release commit for Kubernetes v1.21.4
将修改 cherry-pick 到当前 tag 上
1 2 3 4 5
$ git cherry-pick $COMMIT_ID [detached HEAD baadbe03458] Update kubeadm CertificateValidity time to ten years Date: Tue Aug 24 16:32:49 2021 +0800 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/kubeadm.yaml
重新打上新的 tag,如 v1.21.4-patch-1.0
1 2
$ git tag v1.21.4-patch-1.0 -f Updated tag 'v1.21.4-patch-1.0' (was 70bcbd6de6c)
将 tag push 到 repo 中触发 workflow
1 2 3 4 5 6 7 8 9 10
$ git push origin --tags -f Enumerating objects: 17, done. Counting objects: 100% (17/17), done. Delta compression using up to 4 threads Compressing objects: 100% (9/9), done. Writing objects: 100% (10/10), 1.13 KiB | 192.00 KiB/s, done. Total 10 (delta 7), reused 0 (delta 0) remote: Resolving deltas: 100% (7/7), completed with 7 local objects. To github.com:k8sli/kubernetes.git + c2a633e07ec...baadbe03458 v1.21.4-patch-1.0 -> v1.21.4-patch-1.0 (forced update)
整个构建过程大概需要 7 分钟左右,效率还是蛮高的。
总结
上面只展示了以一个 tag 为单位进行构建的流程,想要构建其他版本的 kubeadm ,可以按照同样的流程和方法来完成。其实写一个 shell 脚本来处理也是十分简单,如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/bin/bash
set -o errexit set -o nounset
# 定义 commit ID : ${COMMIT:="48e4b4c7c62a84ab4ec363588721011b73ee77e6"}