k8s kubeadm rpm如何更新打包

1、安装rpmrebuild和rpmbuild工具

#安装rpmbuild工具套件

yum install rpm-build

#下载rpmrebuild源码包

wget --no-check-certificate https://cfhcable.dl.sourceforge.net/project/rpmrebuild/rpmrebuild/2.15/rpmrebuild-2.15.tar.gz

2、配置rpm重编译目录

编辑~/.rpmmacros文件,在其中加入以下内容:

[root@mn01 ~]# cat ~/.rpmmacros
%_topdir /data01/rpmbuild

3、创建编译目录

mkdir -p /data01/rpmbuild/{BUILDROOT,SPECS}

4、解压下载rpmrebuild源码包

cd /data01/rpmbuild
tar -zxvf rpmrebuild-2.15.tar.gz -C /data01/rpmbuild

5、安装需要重新打包的rpm包

rpm -ivh kubeadm-1.20.8-0.x86_64.rpm

6、生成rpm所需要的编译脚本kubeadm-1.20.8-0.spec

# 第5步中已经安装了kubeadm安装包,我们可以通过以下命令查看安装的软件包

rpm -qa | grep kubeadm

# 获取到的是不带版本和发行版的包名为net-tools来重新生成

cd /root/rpmbuild
./rpmrebuild.sh -s SPECS/kubeadm-1.20.8-0.spec kubeadm-1.20.8-0

查看kubeadm-1.20.8-0.spec文件内容如下,这里我只展示关键部分:

%description
Command-line utility for administering a Kubernetes cluster.
%files
%attr(0755, root, root) "/usr/bin/kubeadm"
%attr(0644, root, root) "/usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf"

7、解压原始rpm包

cd /root/rpmbuild/BUILDROOT
mkdir kubeadm-1.20.8-0.x86_64
cd kubeadm-1.20.8-0.x86_64
cp -a ~/kubeadm-1.20.8-0.x86_64.rpm .
rpm2cpio kubeadm-1.20.8-0.x86_64.rpm |cpio -idv

#得到以下内容

./usr/bin/kubeadm
./usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
76603 块

8、用编译好的kubeadm替换当前usr/bin目录下kubeadm

#编译方法见kubeadm编译,解决k8s证书一年有效期问题文章

cp -a /usr/local/gopath/src/k8s.io/kubernetes/_output/bin/kubeadm /root/rpmbuild/BUILDROOT/kubeadm-1.20.8-0.x86_64/usr/bin/

9、重新打包rpm包

rpmbuild -ba /data01/rpmbuild/SPECS/kubeadm-1.20.8-0.spec

#执行结果如下

处理文件:kubeadm-1.20.8-0.x86_64
Provides: kubeadm = 1.20.8-0 kubeadm(x86-64) = 1.20.8-0
Requires(rpmlib): rpmlib(FileDigests) <= 4.6.0-1 rpmlib(PayloadFilesHavePrefix) <= 4.0-1 rpmlib(CompressedFileNames) <= 3.0.4-1
写道:/data01/rpmbuild/SRPMS/kubeadm-1.20.8-0.src.rpm
写道:/data01/rpmbuild/RPMS/x86_64/kubeadm-1.20.8-0.x86_64.rpm
执行(%clean): /bin/sh -e /var/tmp/rpm-tmp.XhZIYv
+ umask 022
+ cd /data01/rpmbuild/BUILD
+ /usr/bin/rm -rf /data01/rpmbuild/BUILDROOT/kubeadm-1.20.8-0.x86_64
+ exit 0

10、查看编译好的rpm包

ls -l /data01/rpmbuild/RPMS/x86_64/
-rw-r--r-- 1 root root 8656372 12月 5 21:37 kubeadm-1.20.8-0.x86_64.rpm

你可能感兴趣的:(kubernetes,linux,java)