rke 安裝k8s集羣
Docker 安裝(略)
如果你的docker配置了proxy,則no_proxy一定要配置好,或者安裝完之後將代理關閉,再重啓docker。否則可能導致意想不到的問題。
配置hosts文件
192.168.0.101 k8s-node1.ctwifi.cn
192.168.0.102 k8s-node2.ctwifi.cn
192.168.0.103 k8s-node3.ctwifi.cn
配置集羣間服務器ssh互信
$ssh-keygen -f ~/.ssh/id_rsa -N ''
$for host in master.ctwifi.cn \
k8s-node1.ctwifi.cn \
k8s-node2.ctwifi.cn \
k8s-node3.ctwifi.cn; \
do ssh-copy-id -i ~/.ssh/id_rsa.pub $host; \
done
如果ssh使用的是非root用戶,則需要將其加入docker組
gpasswd -a username docker
newgrp docker
重新登陸
下載rke https://github.com/rancher/rke/releases
解壓rke_darwin-amd64 並放到/usr/local/bin下
mv ke_darwin-amd64 /usr/local/bin/rke && chmod +x /usr/local/bin/rke && rke --version
生成配置文件
rke config --name cluster.yml
此命令啓動一個嚮導,按你的實際配置輸入,最終生成cluster.yml文件
安裝k8s集羣
rke up
連接集羣
安裝後生成配置文件kube_config_cluster.yml
cp kube_config_cluster.yml ~/.kube/config
安裝kubectl
yum install kubectl
驗證
kubectl get pod --all-namespaces