容器编排利器 k8s-1.10.2安装
标签:
Kubernetes
先看效果
# 查看所有节点信息kubectl get node -o wide
get node.png
# 查看所有容器信息kubectl get po -o wide --all-namespaces
pod.png
一、配置系统
hostnamectl set-hostname k8s-masterexec bash
二、配置yum阿里源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repoyum makecache yum update -y
三、 安装docker
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repoyum install -y docker-ce
四、配置docker加速器
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s [http://f1361db2.m.daocloud.io](http://f1361db2.m.daocloud.io) sudo systemctl restart docker #启动docker-cesystemctl start docker systemctl enable docker
五、拉取镜像
## 拉国内镜像docker pull reg.qiniu.com/k8s/kube-apiserver-amd64:v1.10.2 docker pull reg.qiniu.com/k8s/kube-controller-manager-amd64:v1.10.2 docker pull reg.qiniu.com/k8s/kube-scheduler-amd64:v1.10.2 docker pull reg.qiniu.com/k8s/kube-proxy-amd64:v1.10.2 docker pull reg.qiniu.com/k8s/etcd-amd64:3.1.12 docker pull reg.qiniu.com/k8s/pause-amd64:3.1## 添加Tagdocker tag reg.qiniu.com/k8s/kube-apiserver-amd64:v1.10.2 k8s.gcr.io/kube-apiserver-amd64:v1.10.2 docker tag reg.qiniu.com/k8s/kube-scheduler-amd64:v1.10.2 k8s.gcr.io/kube-scheduler-amd64:v1.10.2 docker tag reg.qiniu.com/k8s/kube-controller-manager-amd64:v1.10.2 k8s.gcr.io/kube-controller-manager-amd64:v1.10.2 docker tag reg.qiniu.com/k8s/kube-proxy-amd64:v1.10.2 k8s.gcr.io/kube-proxy-amd64:v1.10.2 docker tag reg.qiniu.com/k8s/etcd-amd64:3.1.12 k8s.gcr.io/etcd-amd64:3.1.12 docker tag reg.qiniu.com/k8s/pause-amd64:3.1 k8s.gcr.io/pause-amd64:3.1
在Kubernetes 1.10 中,增加了CoreDNS,如果使用CoreDNS(默认关闭),则不需要下面三个镜像。
## 拉国内镜像docker pull reg.qiniu.com/k8s/k8s-dns-sidecar-amd64:1.14.10 docker pull reg.qiniu.com/k8s/k8s-dns-kube-dns-amd64:1.14.10 docker pull reg.qiniu.com/k8s/k8s-dns-dnsmasq-nanny-amd64:1.14.10## 添加Tagdocker tag reg.qiniu.com/k8s/k8s-dns-sidecar-amd64:1.14.10 k8s.gcr.io/k8s-dns-sidecar-amd64:1.14.10 docker tag reg.qiniu.com/k8s/k8s-dns-kube-dns-amd64:1.14.10 k8s.gcr.io/k8s-dns-kube-dns-amd64:1.14.10 docker tag reg.qiniu.com/k8s/k8s-dns-dnsmasq-nanny-amd64:1.14.10 k8s.gcr.io/k8s-dns-dnsmasq-nanny-amd64:1.14.10
六、添加kubernetes源
cat: cat <<EOF > /etc/yum.repos.d/kubernetes.repo [kubernetes] name=Kubernetes baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64enabled=1gpgcheck=0repo_gpgcheck=0gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpgEOF
七、安装三个组件
yum install -y kubelet-1.10.2 kubectl-1.10.2 kubeadm-1.10.2 sed -i "s/cgroup-driver=systemd/cgroup-driver=cgroupfs/g" /etc/systemd/system/kubelet.service.d/10-kubeadm.conf systemctl daemon-reload systemctl start kubelet systemctl enable kubelet journalctl -xe -u kubelet
初始化master节点
sudo kubeadm init --kubernetes-version=v1.10.2 --feature-gates=CoreDNS=true --pod-network-cidr=192.168.0.0/16 --apiserver-advertise-address 118.89.49.158
八、把master加入到部署计划
kubectl taint nodes --all [node-role.kubernetes.io/master-](http://node-role.kubernetes.io/master-)
token会在24小时后过期
# 查看当前是否有可用tokenkubeadm token list# 创建新的tokenkubeadm token create
查看ca证书sha256编码hash值
openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //'
作者:IT科技互联
链接:https://www.jianshu.com/p/29475df67bf3
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦