安裝k8s 1.12.1
參考
http://www.cnblogs.com/benjamin77/p/9783797.html
https://www.cnblogs.com/myzony/p/9298783.html
https://www.cnblogs.com/cocowool/p/kubeadm_install_kubernetes.html
https://juejin.im/post/5b460f506fb9a04fcf59bf73
一抛蚁、操作系統(tǒng)環(huán)境設(shè)置
=====在192.168.56.60和192.168.56.61機(jī)器上執(zhí)行
1.陈醒、關(guān)掉 selinux
$ setenforce 0
$ sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux
2、關(guān)掉防火墻
$ systemctl stop firewalld
$ systemctl disable firewalld
3瞧甩、關(guān)閉 swap
$ swapoff -a
$ sed -i 's/.*swap.*/#&/' /etc/fstab
4钉跷、配置轉(zhuǎn)發(fā)參數(shù)
$ vi? /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
$ sysctl --system
5、安裝一些必備的工具
$ yum install -y epel-release
$ yum install -y net-tools wget vim? ntpdate
6肚逸、設(shè)置國內(nèi) yum 源
$ vi /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=0
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
enabled=1
7爷辙、yum makecache fast
8、修改主機(jī)名稱和hosts
(1)朦促、 修改192.168.56.60 機(jī)器:hostnamectl set-hostname tadm-60
(2)膝晾、修改192.168.56.61 機(jī)器: hostnamectl set-hostname tadm-61
(3)、修改192.168.56.60和192.168.56.61?vi /etc/hosts
192.168.56.60? ?tadm-60
192.168.56.61? ?tadm-61
二务冕、安裝命令組件k8s
1血当、查看可安裝的版本
yum list kubelet --showduplicates | sort -r
2、安裝kubeadm禀忆、kubectl臊旭、kubelet
$ yum install -y kubelet-1.12.1 kubeadm-1.12.1 kubectl-1.12.1 kubernetes-cni-0.6.0
$ systemctl enable kubelet && systemctl start kubelet
3、拉取k8s需要的鏡像
docker pull mirrorgooglecontainers/kube-apiserver:v1.12.1
docker pull mirrorgooglecontainers/kube-controller-manager:v1.12.1
docker pull mirrorgooglecontainers/kube-scheduler:v1.12.1
docker pull mirrorgooglecontainers/kube-proxy:v1.12.1
docker pull mirrorgooglecontainers/etcd-amd64:3.2.24
docker pull mirrorgooglecontainers/pause-amd64:3.1
docker pull mirrorgooglecontainers/etcd:3.2.24
docker pull mirrorgooglecontainers/pause:3.1
docker pull coredns/coredns:1.2.2
docker pull?registry.cn-shanghai.aliyuncs.com/gcr-k8s/flannel:v0.10.0-amd64
4箩退、修改k8s需要的鏡像名稱
docker tag mirrorgooglecontainers/kube-apiserver:v1.12.1 k8s.gcr.io/kube-apiserver:v1.12.1
docker tag mirrorgooglecontainers/kube-controller-manager:v1.12.1 k8s.gcr.io/kube-controller-manager:v1.12.1
docker tag mirrorgooglecontainers/kube-scheduler:v1.12.1 k8s.gcr.io/kube-scheduler:v1.12.1
docker tag mirrorgooglecontainers/kube-proxy:v1.12.1 k8s.gcr.io/kube-proxy:v1.12.1
docker tag mirrorgooglecontainers/etcd-amd64:3.2.24 k8s.gcr.io/etcd-amd64:3.2.24
docker tag mirrorgooglecontainers/pause-amd64:3.1 k8s.gcr.io/pause-amd64:3.1
docker tag mirrorgooglecontainers/etcd:3.2.24 k8s.gcr.io/etcd:3.2.24
docker tag mirrorgooglecontainers/pause:3.1 k8s.gcr.io/pause:3.1
docker tag coredns/coredns:1.2.2 k8s.gcr.io/coredns:1.2.2
docker tag registry.cn-shanghai.aliyuncs.com/gcr-k8s/flannel:v0.10.0-amd64?quay.io/coreos/flannel:v0.10.0-amd64
5离熏、刪除鏡像
docker rmi mirrorgooglecontainers/kube-apiserver:v1.12.1
docker rmi mirrorgooglecontainers/kube-controller-manager:v1.12.1
docker rmi mirrorgooglecontainers/kube-scheduler:v1.12.1
docker rmi mirrorgooglecontainers/kube-proxy:v1.12.1
docker rmi mirrorgooglecontainers/etcd-amd64:3.2.24
docker rmi mirrorgooglecontainers/pause-amd64:3.1
docker rmi mirrorgooglecontainers/etcd:3.2.24
docker rmi mirrorgooglecontainers/pause:3.1
docker rmi coredns/coredns:1.2.2
docker rmi registry.cn-shanghai.aliyuncs.com/gcr-k8s/flannel:v0.10.0-amd64?
6、查看鏡像結(jié)果
docker images | grep k8s
======在192.168.56.60機(jī)器上執(zhí)行
7乏德、開始安裝k8s
kubeadm init --kubernetes-version=v1.12.1 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.56.60
執(zhí)行屏幕打印出的命令
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
8撤奸、創(chuàng)建 flannel 網(wǎng)絡(luò)
(1) sysctl net.bridge.bridge-nf-call-iptables=1
(2) wget? wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
(3)?flannel 默認(rèn)會(huì)使用主機(jī)的第一張網(wǎng)卡吠昭,如果你有多張網(wǎng)卡,需要通過配置單獨(dú)指定胧瓜。修改 kube-flannel.yml 中的以下部分
(4) 安裝網(wǎng)絡(luò)
** 手工先下載
docker pull quay.io/coreos/flannel:v0.10.0-amd64
如果很慢可以下載
docker pull registry.cn-shenzhen.aliyuncs.com/cp_m/flannel:v0.10.0-amd64
docker tag?registry.cn-shenzhen.aliyuncs.com/cp_m/flannel:v0.10.0-amd64?quay.io/coreos/flannel:v0.10.0-amd64
** 創(chuàng)建網(wǎng)絡(luò)? kubectl apply -f?kube-flannel.yml
======在192.168.56.61機(jī)器上執(zhí)行
9矢棚、192.168.56.61加入集群
(1)、同樣的類似192.168.56.60下載鏡像
????????3府喳、拉取k8s需要的鏡像
????????4蒲肋、修改k8s需要的鏡像名稱
? ??????5、刪除鏡像
(2)钝满、使用剛才在192.168.56.60創(chuàng)建master控制臺(tái)提示加入集群命令
kubeadm join 192.168.56.60:6443 --token cgggwd.q5w883rkzbp44v6w --discovery-token-ca-cert-hash sha256:cae67bec80da916c8e140f4e66f2ce3aff2f8be3a8580f757cdfdfd1651337ba
(3)兜粘、在192.168.56.60上驗(yàn)證
springcloud in k8s spring cloud 工程創(chuàng)建 - 簡書
springcloud in k8s 在github上創(chuàng)建配置文件 - 簡書
springcloud in k8s 在centos7下安裝docker - 簡書
springcloud in k8s docker私有倉庫安裝 - 簡書
springcloud in k8s jenkins 之 jdk git maven 安裝 - 簡書
springcloud in k8s jenkins 安裝 - 簡書
springcloud in k8s jenkins 之 jdk maven github 配置 - 簡書
springcloud in k8s jenkins 之 job構(gòu)建項(xiàng)目 - 簡書
springcloud in k8s kubeadm安裝k8s - 簡書