Docker安裝
1.修改apt源
vim /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ xenial-security main restricted universe multiverse
2.安裝依賴包
sudo apt-get update
sudo apt-get install -y\
linux-image-extra-$(uname -r) \
linux-image-extra-virtual
sudo apt-get install -y\
apt-transport-https \
ca-certificates \
curl \
software-properties-common
3.添加docker庫
sudo add-apt-repository \
"deb [arch=amd64] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(lsb_release -cs) \
stable"
4.安裝docker
sudo apt-get update
sudo apt-get install -y docker-ce
#如需指定版本安裝堡牡,可通過apt-cache madison查看可安裝版本
#apt-cache madison docker-ce
#本文使用18.09.5版本
#apt-get install -y docker-ce=5:18.09.5~3-0~ubuntu-xenial
5.配置docker及加速
#設(shè)置開機啟動
systemctl enable docker
#改為阿里源
vim /etc/docker/daemon.json
{
"registry-mirrors": ["https://alzgoonw.mirror.aliyuncs.com"],
"live-restore": true
}
systemctl daemon-reload
systemctl restart docker
K8s安裝
1.添加秘鑰
curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -
2.添加K8s軟件源并安裝
#添加K8s庫
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet=1.13.5-00 kubeadm=1.13.5-00 kubectl=1.13.5-00
systemctl enable kubelet
#master節(jié)點運行
#修改apiserver-advertise-address為Master ip
kubeadm init --kubernetes-version=1.13.5 \
--apiserver-advertise-address=10.21.19.208 \
--image-repository registry.aliyuncs.com/google_containers \
--service-cidr=10.1.0.0/16 \
--pod-network-cidr=10.244.0.0/16
#記錄init結(jié)束后的輸出的信息:
kubeadm join 10.21.19.208:6443 --token ulc55u.di1av5mc6bjyu92k \
--discovery-token-ca-cert-hash sha256:c3c6e4653dbebb94fd57e625afafccf394e3251879df500acc8e184ad8c87e06
#worker節(jié)點執(zhí)行上述kubeadm join xxx
3.配置Mstaer節(jié)點
vim /etc/profile
export KUBECONFIG=/etc/kubernetes/admin.conf
source /etc/profile
systemctl daemon-reload
systemctl restart kubelet
4.安裝flannel
#Master節(jié)點執(zhí)行
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
kubectl get pod -n kube-system
#出現(xiàn)kube-flannel-ds-amd64-zjksm 0/1 Init:ImagePullBackOff 0 31m時
kubectl edit pod/kube-flannel-ds-amd64-zjksm -n kube-system
#修改兩處image為:
image: quay-mirror.qiniu.com/coreos/flannel:v0.11.0-amd64
#kubectl get node查看各節(jié)點是否加入集群并ready
5.驗證
#驗證
kubectl run httpd-app --image=httpd
kubectl expose deployment httpd-app --port=88 --type=NodePort --target-port=80 --name=http-service
kubectl get svc
curl 10.1.209.113:88
最后編輯于 :2020.01.10 15:36:26
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者