一、如何獲取rpm包,及製做kubernetes鏡像github
1
2
3
4
5
6
7
8
9
10
|
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
3
4
5
6
|
下載源碼包
git clone
https:
//github
.com
/kubernetes/release
kubeadm
cd
kubeadm
/rpm
sh docker-build.sh
|
結果在 rpm/output/x86_64/yum/
docker
1
2
3
4
|
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 p_w_picpath叫kubelet-rpm-builder,也須要×××api
我已上傳本身私有倉bash
foxchan/kubelet-rpm-builderapp
注意:若是提早下載好kubelet-rpm-builder,須要修改rpm目錄下的docker-build.sh 和Dockerfile
ide
Dockerfile修改以下:ui
1
2
3
4
5
|
FROM foxchan
/kubelet-rpm-builder
USER root
ADD entry.sh
/root/
COPY ./
/root/rpmbuild/SPECS
ENTRYPOINT [
"/root/entry.sh"
]
|
docker-build.sh google
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
#!/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/
|
二、利用github,建立kubernetes鏡像
url
2.1 Dockerfile上傳到github
github上新建一個工程,https://github.com/foxchenlei/docker-library
而後在工程中新增: ./kube-apiserver-amd64/Dockerfile
,Dockerfile內容爲:
1
2
|
FROM gcr.io
/google_containers/kube-apiserver-amd64
:v1.8.2
MAINTAINER FoxChan
|
到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下來