解決Kubeadm在安裝K8s中的版本問題

Docker源

curl -o /etc/yum.repos.d/Docker-ce-Ali.repo  https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

安裝特定版本

[root@k8s-master ~]# yum list docker-ce --showduplicates | sort -r
Repository docker-ce-stable is listed more than once in the configuration
Repository docker-ce-stable-debuginfo is listed more than once in the configuration
Repository docker-ce-stable-source is listed more than once in the configuration
Repository docker-ce-edge is listed more than once in the configuration
Repository docker-ce-edge-debuginfo is listed more than once in the configuration
Repository docker-ce-edge-source is listed more than once in the configuration
Repository docker-ce-test is listed more than once in the configuration
Repository docker-ce-test-debuginfo is listed more than once in the configuration
Repository docker-ce-test-source is listed more than once in the configuration
Repository docker-ce-nightly is listed more than once in the configuration
Repository docker-ce-nightly-debuginfo is listed more than once in the configuration
Repository docker-ce-nightly-source is listed more than once in the configuration
 * updates: mirrors.aliyun.com
Loaded plugins: fastestmirror
Installed Packages
 * extras: mirrors.aliyun.com
docker-ce.x86_64            3:18.09.7-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.6-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.5-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.4-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.3-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.2-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.1-3.el7                    docker-ce-stable 
docker-ce.x86_64            3:18.09.0-3.el7                    docker-ce-stable 
docker-ce.x86_64            18.06.3.ce-3.el7                   docker-ce-stable 
docker-ce.x86_64            18.06.3.ce-3.el7                   @docker-ce-stable
docker-ce.x86_64            18.06.2.ce-3.el7                   docker-ce-stable 
docker-ce.x86_64            18.06.1.ce-3.el7                   docker-ce-stable 
docker-ce.x86_64            18.06.0.ce-3.el7                   docker-ce-stable 
docker-ce.x86_64            18.03.1.ce-1.el7.centos            docker-ce-stable 
···                   略   略   略  ···········

在docker-ce-17.06.0后引入了一個新的廢棄策略,但yum卻錯誤地將此應(yīng)用到了所有的docker-ce版本上流济,所以我們只需添加一個忽略選項即可:
還有,在18.06版本的Docker上,不需要同時安裝docker-ce-selinux
注意格式

[root@k8s ~]# yum -y install --setopt=obsoletes=0 docker-ce-18.06.3.ce 
Loaded plugins: fastestmirror
Repository docker-ce-stable is listed more than once in the configuration
Repository docker-ce-stable-debuginfo is listed more than once in the configuration
Repository docker-ce-stable-source is listed more than once in the configuration
Repository docker-ce-edge is listed more than once in the configuration
Repository docker-ce-edge-debuginfo is listed more than once in the configuration
Repository docker-ce-edge-source is listed more than once in the configuration
Repository docker-ce-test is listed more than once in the configuration
Repository docker-ce-test-debuginfo is listed more than once in the configuration
Repository docker-ce-test-source is listed more than once in the configuration
Repository docker-ce-nightly is listed more than once in the configuration
Repository docker-ce-nightly-debuginfo is listed more than once in the configuration
Repository docker-ce-nightly-source is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package docker-ce.x86_64 0:18.06.3.ce-3.el7 will be installed
--> Processing Dependency: libltdl.so.7()(64bit) for package: docker-ce-18.06.3.ce-3.el7.x86_64
--> Running transaction check
---> Package libtool-ltdl.x86_64 0:2.4.2-22.el7_3 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================

#  Package                    Arch                 Version                           Repository                      Size

Installing:
 docker-ce                  x86_64               18.06.3.ce-3.el7                  docker-ce-stable                41 M
Installing for dependencies:
 libtool-ltdl               x86_64               2.4.2-22.el7_3                    base                            49 k
# Transaction Summary
Install  1 Package (+1 Dependent package)
Total download size: 41 M
Installed size: 168 M
Downloading packages:
(1/2): libtool-ltdl-2.4.2-22.el7_3.x86_64.rpm                                                    |  49 kB  00:00:00     

## (2/2): docker-ce-18.06.3.ce-3.el7.x86_64.rpm                                                     |  41 MB  00:00:05     

Total                                                                                   6.9 MB/s |  41 MB  00:00:05     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : libtool-ltdl-2.4.2-22.el7_3.x86_64                                                                   1/2 
  Installing : docker-ce-18.06.3.ce-3.el7.x86_64                                                                    2/2 
  Verifying  : libtool-ltdl-2.4.2-22.el7_3.x86_64                                                                   1/2 
  Verifying  : docker-ce-18.06.3.ce-3.el7.x86_64                                                                    2/2 
Installed:
  docker-ce.x86_64 0:18.06.3.ce-3.el7                                                           
Dependency Installed:
  libtool-ltdl.x86_64 0:2.4.2-22.el7_3                                                           
Complete!

kubeadm kubectl kubelet源

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
 http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
yum list kubelet kubeadm kubectl --showduplicates|sort -r
[root@k8s-master ~]# yum list kubelet kubeadm kubectl  --showduplicates|sort -r
Repository docker-ce-stable is listed more than once in the configuration
Repository docker-ce-stable-debuginfo is listed more than once in the configuration
Repository docker-ce-stable-source is listed more than once in the configuration
Repository docker-ce-edge is listed more than once in the configuration
Repository docker-ce-edge-debuginfo is listed more than once in the configuration
Repository docker-ce-edge-source is listed more than once in the configuration
Repository docker-ce-test is listed more than once in the configuration
Repository docker-ce-test-debuginfo is listed more than once in the configuration
Repository docker-ce-test-source is listed more than once in the configuration
Repository docker-ce-nightly is listed more than once in the configuration
Repository docker-ce-nightly-debuginfo is listed more than once in the configuration
Repository docker-ce-nightly-source is listed more than once in the configuration
 * updates: mirrors.aliyun.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
kubelet.x86_64                       1.9.9-0                         kubernetes 
kubelet.x86_64                       1.9.8-0                         kubernetes 
kubelet.x86_64                       1.9.7-0                         kubernetes 
kubelet.x86_64                       1.9.6-0                         kubernetes 
kubelet.x86_64                       1.9.5-0                         kubernetes 
kubelet.x86_64                       1.9.4-0                         kubernetes 
kubelet.x86_64                       1.9.3-0                         kubernetes 
kubelet.x86_64                       1.9.2-0                         kubernetes 
···                ···············    略   略   略  ···········

安裝特定版本

這里安裝1.15版本

yum -y install kubeadm-1.15.0-0 kubelet-1.15.0-0 

驗證

[root@k8s-master ~]# kubelet --version
Kubernetes v1.15.0
[root@k8s-master ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:40:16Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:32:14Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
[root@k8s-master ~]# kubeadm version
kubeadm version: &version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-19T16:37:41Z", GoVersion:"go1.12.5", Compiler:"gc", Platform:"linux/amd64"}
  [root@k8s ~]# kubeadm init  --apiserver-advertise-address 172.31.189.219 --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=cri
[init] Using Kubernetes version: v1.15.0
[preflight] Running pre-flight checks


[WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/


[preflight] Pulling images required for setting up a Kubernetes cluster
[preflight] This might take a minute or two, depending on the speed of your internet connection
[preflight] You can also perform this action in beforehand using 'kubeadm config images pull'
[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"
[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"
[kubelet-start] Activating the kubelet service
[certs] Using certificateDir folder "/etc/kubernetes/pki"
[certs] Generating "ca" certificate and key
[certs] Generating "apiserver-kubelet-client" certificate and key
[certs] Generating "apiserver" certificate and key
[certs] apiserver serving cert is signed for DNS names [k8s kubernetes kubernetes.default kubernetes.default.svc kubernetes.default.svc.cluster.local] and IPs [10.96.0.1 172.31.189.219]
[certs] Generating "front-proxy-ca" certificate and key
[certs] Generating "front-proxy-client" certificate and key
[certs] Generating "etcd/ca" certificate and key
[certs] Generating "etcd/server" certificate and key
[certs] etcd/server serving cert is signed for DNS names [k8s localhost] and IPs [172.31.189.219 127.0.0.1 ::1]
[certs] Generating "etcd/healthcheck-client" certificate and key
[certs] Generating "apiserver-etcd-client" certificate and key
[certs] Generating "etcd/peer" certificate and key
[certs] etcd/peer serving cert is signed for DNS names [k8s localhost] and IPs [172.31.189.219 127.0.0.1 ::1]
[certs] Generating "sa" key and public key
[kubeconfig] Using kubeconfig folder "/etc/kubernetes"
[kubeconfig] Writing "admin.conf" kubeconfig file
[kubeconfig] Writing "kubelet.conf" kubeconfig file
[kubeconfig] Writing "controller-manager.conf" kubeconfig file
[kubeconfig] Writing "scheduler.conf" kubeconfig file
[control-plane] Using manifest folder "/etc/kubernetes/manifests"
[control-plane] Creating static Pod manifest for "kube-apiserver"
[control-plane] Creating static Pod manifest for "kube-controller-manager"
[control-plane] Creating static Pod manifest for "kube-scheduler"
[etcd] Creating static Pod manifest for local etcd in "/etc/kubernetes/manifests"
[wait-control-plane] Waiting for the kubelet to boot up the control plane as static Pods from directory "/etc/kubernetes/manifests". This can take up to 4m0s
[apiclient] All control plane components are healthy after 19.502141 seconds
[upload-config] Storing the configuration used in ConfigMap "kubeadm-config" in the "kube-system" Namespace
[kubelet] Creating a ConfigMap "kubelet-config-1.15" in namespace kube-system with the configuration for the kubelets in the cluster
[upload-certs] Skipping phase. Please see --upload-certs
[mark-control-plane] Marking the node k8s as control-plane by adding the label "node-role.kubernetes.io/master=''"
[mark-control-plane] Marking the node k8s as control-plane by adding the taints [node-role.kubernetes.io/master:NoSchedule]
[bootstrap-token] Using token: r6npjy.59peqgwyyvp300eb
[bootstrap-token] Configuring bootstrap tokens, cluster-info ConfigMap, RBAC Roles
[bootstrap-token] configured RBAC rules to allow Node Bootstrap tokens to post CSRs in order for nodes to get long term certificate credentials
[bootstrap-token] configured RBAC rules to allow the csrapprover controller automatically approve CSRs from a Node Bootstrap Token
[bootstrap-token] configured RBAC rules to allow certificate rotation for all node client certificates in the cluster
[bootstrap-token] Creating the "cluster-info" ConfigMap in the "kube-public" namespace
[addons] Applied essential addon: CoreDNS
[addons] Applied essential addon: kube-proxy

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can join any number of worker nodes by running the following on each as root:

kubeadm join 172.31.189.219:6443 --token r6npjy.59peqgwyyvp300eb \


--discovery-token-ca-cert-hash sha256:2cb56c70069e62679739cfab11fed220b3723435c499a912f0c9f5a3923e861d 
kubeadm join 192.168.0.89:6443 --token kcf3qd.ipq5xmyj02fqqqj9 \
    --discovery-token-ca-cert-hash sha256:dae5a339cedaef0b81e2e3d27997ae9d06e2e7b684af05d28c6624bf0c9d892b
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市绪杏,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌或油,老刑警劉巖,帶你破解...
    沈念sama閱讀 217,542評論 6 504
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件驰唬,死亡現(xiàn)場離奇詭異顶岸,居然都是意外死亡,警方通過查閱死者的電腦和手機(jī)叫编,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,822評論 3 394
  • 文/潘曉璐 我一進(jìn)店門辖佣,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人搓逾,你說我怎么就攤上這事卷谈。” “怎么了霞篡?”我有些...
    開封第一講書人閱讀 163,912評論 0 354
  • 文/不壞的土叔 我叫張陵世蔗,是天一觀的道長。 經(jīng)常有香客問我朗兵,道長污淋,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 58,449評論 1 293
  • 正文 為了忘掉前任余掖,我火速辦了婚禮寸爆,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘盐欺。我一直安慰自己赁豆,他們只是感情好,可當(dāng)我...
    茶點故事閱讀 67,500評論 6 392
  • 文/花漫 我一把揭開白布冗美。 她就那樣靜靜地躺著魔种,像睡著了一般。 火紅的嫁衣襯著肌膚如雪粉洼。 梳的紋絲不亂的頭發(fā)上务嫡,一...
    開封第一講書人閱讀 51,370評論 1 302
  • 那天,我揣著相機(jī)與錄音漆改,去河邊找鬼心铃。 笑死,一個胖子當(dāng)著我的面吹牛挫剑,可吹牛的內(nèi)容都是我干的去扣。 我是一名探鬼主播,決...
    沈念sama閱讀 40,193評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼愉棱!你這毒婦竟也來了唆铐?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,074評論 0 276
  • 序言:老撾萬榮一對情侶失蹤奔滑,失蹤者是張志新(化名)和其女友劉穎艾岂,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體朋其,經(jīng)...
    沈念sama閱讀 45,505評論 1 314
  • 正文 獨居荒郊野嶺守林人離奇死亡王浴,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,722評論 3 335
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了梅猿。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片氓辣。...
    茶點故事閱讀 39,841評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖袱蚓,靈堂內(nèi)的尸體忽然破棺而出钞啸,到底是詐尸還是另有隱情,我是刑警寧澤喇潘,帶...
    沈念sama閱讀 35,569評論 5 345
  • 正文 年R本政府宣布体斩,位于F島的核電站,受9級特大地震影響颖低,放射性物質(zhì)發(fā)生泄漏硕勿。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,168評論 3 328
  • 文/蒙蒙 一枫甲、第九天 我趴在偏房一處隱蔽的房頂上張望源武。 院中可真熱鬧,春花似錦想幻、人聲如沸粱栖。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,783評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽闹究。三九已至,卻和暖如春食店,著一層夾襖步出監(jiān)牢的瞬間渣淤,已是汗流浹背。 一陣腳步聲響...
    開封第一講書人閱讀 32,918評論 1 269
  • 我被黑心中介騙來泰國打工吉嫩, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留价认,地道東北人。 一個月前我還...
    沈念sama閱讀 47,962評論 2 370
  • 正文 我出身青樓自娩,卻偏偏與公主長得像用踩,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 44,781評論 2 354