1、如何获取rpm包,及制作kubernetes镜像
1.1 官方yum源,有翻墙能力的 请使用
cat <<EOF > /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=http://yum.kubernetes.io/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=1 repo_gpgcheck=1 gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg EOF
1.2 自行编译生成相关rpm包
下载源码包 git clone https://github.com/kubernetes/release kubeadm cd kubeadm/rpm sh docker-build.sh
结果在 rpm/output/x86_64/yum/
kubectl-1.8.2-0.x86_64.rpm kubelet-1.8.2-0.x86_64.rpm kubeadm-1.8.2-0.x86_64.rpm kubernetes-cni-0.5.1-0.x86_64.rpm
期间会生成一个docker image叫kubelet-rpm-builder,也需要翻墙
我已上传自己私有仓
注意:如果提前下载好kubelet-rpm-builder,需要修改rpm目录下的docker-build.sh 和Dockerfile
Dockerfile修改如下:
FROM foxchan/kubelet-rpm-builder USER root ADD entry.sh /root/ COPY ./ /root/rpmbuild/SPECS ENTRYPOINT ["/root/entry.sh"]
docker-build.sh
#!/bin/sh set -e echo "Cleaning output directory..." sudo rm -rf output/* mkdir -p output docker run -ti --rm -v $PWD/output/:/root/rpmbuild/RPMS/ kubelet-rpm-builder $1 sudo chown -R $USER $PWD/output echo echo "----------------------------------------" echo echo "RPMs written to: " ls $PWD/output/*/ echo echo "Yum repodata written to: " ls $PWD/output/*/repodata/
2、利用github,创建kubernetes镜像
2.1 Dockerfile上传到github
github上新建一个工程,https://github.com/foxchenlei/docker-library
然后在工程中新增: ./kube-apiserver-amd64/Dockerfile
,Dockerfile内容为:
FROM gcr.io/google_containers/kube-apiserver-amd64:v1.8.2 MAINTAINER FoxChan
2.2 Docker Hub上创建Automated build
到docker hub上,Create -> Create Automated Build
,新增一个Github类型的自动编译,选择docker-library项目;修改Repository的Name为kube-apiserver-amd64
,简单填下描述,这样就创建了一个Automated Build。
进到Repository kube-apiserver-amd64
,Build Setting中填写Dockerfile Location为
,修改Docker Tag Name为1.8.2,Save Change and Trigger;然后点Build Details,可以看到build的过程,状态切为Success就可以了。kube-apiserver-amd64
2.3 剩下的,就是重复上面的操作,把你需要的镜像全部构建到hub.docker.com,以后需要的时候 就pull下来