kubernetes安裝筆記-02 添加node
阿新 • • 發佈:2019-05-08
nta start 拉取 ecs ont 命令 reg ice nag 環境配置 一下配置(node節點都需要安裝)
192.168.1.252 k8s-node02
192.168.1.73 k8s-node01
192.168.1.101 k8s-master
node初始化
參考(https://blog.51cto.com/9025736/2385268)
node安裝docker
[[email protected] ~]# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo [[email protected] ~]# mv docker-ce.repo /etc/yum.repos.d/ [[email protected] yum.repos.d]# scp docker-ce.repo k8s-node01:/etc/yum.repos.d/ [[email protected] yum.repos.d]# yum install -y docker-ce [[email protected] k8s-node02 yum.repos.d]# yum install -y docker-ce
配置docker代理 可忽略
[[email protected] ~]# vim /usr/lib/systemd/system/docker.service Environment="HTTPS_PROXY=http://www.ik8s.io:10070" #設置代理 可忽略 Environment="NO_PROXY=127.0.0.0/8,192.168.1.0/24" #訪問次網絡 不需要代理 可忽略 ExecStart=/usr/bin/dockerd -H fd://containerd=/run/containerd/containerd.sock ExecstartPost=/usr/sbin/iptables -P FORWARD ACCEPT #新增 意思:啟動docker的時候自動執行這個命令
啟動docker
[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# systemctl start docker
[[email protected] yum.repos.d]# ps -ef|grep docker
root 6617 1 1 10:55 ? 00:00:00 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
查看iptables
[[email protected] ~]# iptables -vnL
安裝kuberbetes依賴包 添加阿裏雲的鏡像k8s:
#阿裏雲的開源鏡像站:https://mirrors.aliyun.com/kubernetes/
[[email protected] yum.repos.d]# vim kubernetes.repo
[kubernetes]
name=k8s repo
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
查看repo文件
[[email protected] yum.repos.d]# yum repolist
node安裝 kubeadm kubelet
[[email protected] .ssh]# yum install -y kubeadm kubelet
設置了swap的 需要修改
[[email protected] yum.repos.d]# vim /etc/sysconfig/kubelet
KUBELET_EXTRA_ARGS="--fail-swap-on=false"
node節點拉去k8s的鏡像
[[email protected] ~]# vim /usr/lib/systemd/system/docker.service
#Environment="HTTPS_PROXY=http://www.ik8s.io:10070"
#Environment="NO_PROXY=127.0.0.0/8,192.168.1.0/24"
[[email protected] ~]# systemctl daemon-reload
[[email protected] ~]# systemctl restart docker
拉取鏡像
MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/openthings
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver:v1.14.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.14.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.14.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.14.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-etcd:3.3.10
docker pull ${MY_REGISTRY}/k8s-gcr-io-pause:3.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-coredns:1.3.1
添加Tag
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver:v1.14.1 k8s.gcr.io/kube-ap iserver:v1.14.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.14.1 k8s.gcr.io/kube-scheduler:v1.14.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.14.1 k8s.gcr.io/kube-controller-manager:v1.14.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.14.1 k8s.gcr.io/kube-proxy:v1.14.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-etcd:3.3.10 k8s.gcr.io/etcd:3.3.10
docker tag ${MY_REGISTRY}/k8s-gcr-io-pause:3.1 k8s.gcr.io/pause:3.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-coredns:1.3.1 k8s.gcr.io/coredns:1.3.1
添加節點到master
[[email protected] .ssh]# kubeadm join 192.168.1.101:6443 --token lzc69y.4gapyv735z0stisl --discovery-token-ca-cert-hash sha256:34ef3c3d00123569822285df5d084b3c062249e1a6726364821460d1a3833e1a
如果開啟swap了需要使用
--ignore-preflight-errors=Swap
kubernetes安裝筆記-02 添加node