前提條件
-
系統(tǒng)要求
- Ubuntu 16.04+
- Debian 9
- CentOS 7
- RHEL 7
- Fedora 25/26 (best-effort)
- HypriotOS v1.0.1+
- Container Linux (tested with 1800.6.0)
2GB內(nèi)存+
2核CPU+
端口要求
- Master node(s)
Protocol | Direction | Port Range | Purpose | Used By |
---|---|---|---|---|
TCP | Inbound | 6443* | Kubernetes API server | All |
TCP | Inbound | 2379-2380 | etcd server client API | kube-apiserver, etcd |
TCP | Inbound | 10250 | Kubelet API | Self, Control plane |
TCP | Inbound | 10251 | kube-scheduler | Self |
TCP | Inbound | 10252 | kube-controller-manager | Self |
- Worker node(s)
Protocol | Direction | Port Range | Purpose | Used By |
---|---|---|---|---|
TCP | Inbound | 10250 | Kubelet API | Self, Control plane |
TCP | Inbound | 30000-32767 | NodePort Services** | All |
安裝docker
- Docker Engine改為Docker CE(社區(qū)版)
- 它包含了CLI客戶端梦抢、后臺進(jìn)程/服務(wù)以及API葫松。用戶像以前以同樣的方式獲取玷禽。
- Docker Data Center改為Docker EE(企業(yè)版)
- 在Docker三個定價層增加了額外的支付產(chǎn)品和支持
- 這些修改并不影響Docker Compose以及Docker Machine
- Docker版本現(xiàn)在基于YY.MM
- 使用基于月份的發(fā)行版本渤闷,17.03 的第一版就指向17.03.0省古,如果有bug/安全修復(fù)需要發(fā)布疏唾,那么將會指向17.03.1等等辫樱。
- "Edge"與"Stable"兩個版本發(fā)行
- Edge版本每月發(fā)布弧满,提供一個月支持。
- Stable版本每季度發(fā)布吧享,提供4個月支持魏割。
[root@manage01 /]# yum list docker-ce --showduplicates | sort -r
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
* updates: mirrors.163.com
Loading mirror speeds from cached hostfile
Loaded plugins: fastestmirror
* extras: mirrors.cn99.com
* epel: mirror01.idc.hinet.net
* elrepo: hkg.mirror.rackspace.com
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.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.x86_64 18.03.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.12.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.09.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.03.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
* base: mirrors.aliyun.com
Available Packages
這里選擇了18.06.3.ce
這個版本
[root@manage01 /]# yum install docker-ce-18.06.3.ce
安裝 kubeadm, kubelet and kubectl
- kubeadm: 引導(dǎo)工具
- kubelet: 在群集中的所有計算機(jī)上運(yùn)行的組件,并執(zhí)行諸如啟動pod和容器之類的操作钢颂。
- kubectl: 命令行與群集通信钞它。
kubeadm不會為您安裝或管理kubelet或kubectl,需要獨(dú)立安裝殊鞭。但是要確保這些組件之間的版本兼容遭垛。
Kubernetes version and version-skew policy [https://kubernetes.io/docs/setup/version-skew-policy/]
Kubeadm-specific version skew policy [https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/#version-skew-policy]
開始安裝
迫于qiang,這里是阿里源
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
# Set SELinux in permissive mode (effectively disabling it)
setenforce 0
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes
systemctl enable --now kubelet
安裝網(wǎng)絡(luò)策略
# 創(chuàng)建kube-router目錄下載相關(guān)文件
mkdir kube-router && cd kube-router
wget https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter.yaml
wget https://raw.githubusercontent.com/cloudnativelabs/kube-router/master/daemonset/kubeadm-kuberouter-all-features.yaml
# 以下兩種部署方式任選其一
# 1. 只啟用 pod網(wǎng)絡(luò)通信,網(wǎng)絡(luò)隔離策略 功能
kubectl apply -f kubeadm-kuberouter.yaml
# 2. 啟用 pod網(wǎng)絡(luò)通信操灿,網(wǎng)絡(luò)隔離策略锯仪,服務(wù)代理 所有功能
# 刪除kube-proxy和其之前配置的服務(wù)代理
kubectl apply -f kubeadm-kuberouter-all-features.yaml
kubectl -n kube-system delete ds kube-proxy
# 在每個節(jié)點(diǎn)上執(zhí)行
docker run --privileged --net=host registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy-amd64:v1.10.2 kube-proxy --cleanup
# 查看
kubectl get pods --namespace kube-system
kubectl get svc --namespace kube-system
問題匯總
- master無法運(yùn)行pod
0/1 nodes are available: 1 node(s) had taints that the pod didn't tolerate.
解決:kubectl taint nodes --all node-role.kubernetes.io/master-