使用 kubeadmin 离线部署 kubernetes1.9

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

一、环境介绍:

1、操作系统:

    centos7.3  3.10.0-693.el7.x86_64

2、主机名
    node1 192.168.5.251  
    node2 192.168.5.252  
    node3 192.168.5.253  

二:配置基础环境

1、配置node3结点与其他结点互信
[root@node3 ~]# ssh-keyge
[root@node3 ~]# ssh-copy-id node1
[root@node3 ~]# ssh-copy-id node2

2、下载网盘的离线包,解压后复制到所有结点
链接: https://pan.baidu.com/s/1QzA7d86XgNamMR80aTrY9g 密码: ovar

3、安装docker软件包(所有结点)
https://yq.aliyun.com/articles/110806


4、系统路由参数,防止kubeadm报路由警告(所有结点)
echo "
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
" >> /etc/sysctl.conf
sysctl -p

5、导入docker镜像(所有结点)
[root@node3 k8s]# cd /root/k8s/
[root@node3 k8s]# find . -name "*.tar" -exec docker image load -i {} \;

6、安装RPM包(所有结点)
rpm -ivh socat-1.7.3.2-2.el7.x86_64.rpm
rpm -ivh kubernetes-cni-0.6.0-0.x86_64.rpm  kubelet-1.9.9-9.x86_64.rpm  kubectl-1.9.0-0.x86_64.rpm
rpm -ivh kubectl-1.9.0-0.x86_64.rpm
rpm -ivh kubeadm-1.9.0-0.x86_64.rpm

7、修改kubernetes使用docker默认driver(所有结点)
sed -i 's#systemd#cgroupfs#g' /etc/systemd/system/kubelet.service.d/10-kubeadm.conf

8、配置node3结点,使用kubectl命令补全功能
[root@node3 k8s]# echo "source <(kubectl completion bash)" >> ~/.bashrc

三、使用kubeadm生成kubernetes集群

1、node3结点,启动kubelet服务
[root@node3 rpm]# systemctl enable kubelet && sudo systemctl start kubelet

2、node3结点,初始化kubernetes集群
[root@node3 rpm]# kubeadm init --kubernetes-version=v1.9.0 --pod-network-cidr=10.244.0.0/16

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of machines by running the following on each node
as root:

  kubeadm join --token e96cd7.9ffface2d57aa555 192.168.5.253:6443 --discovery-token-ca-cert-hash sha256:aa954aab7600e26dfc4c356a85c7a73a0e4dff264e26fe3a68f380c57f0d8bb6

3、按上述操作,验证加入集群
[root@node3 ~]# kubectl get node
NAME      STATUS     ROLES     AGE       VERSION
node1     NotReady       56m       v1.9.0
node2     NotReady       56m       v1.9.0
node3     NotReady   master    58m       v1.9.0

4、使用calico插件,修改CIDR为初始化使用的网段;
...
            - name: CALICO_IPV4POOL_CIDR
              value: "10.244.0.0/16"  # 原 value: "10.244.0.0/16"
...

[root@node3 k8s]# kubectl create -f calico.yaml

[root@node3 k8s]# kubectl get node
NAME      STATUS    ROLES     AGE       VERSION
node1     Ready         1h        v1.9.0
node2     Ready         1h        v1.9.0
node3     Ready     master    1h        v1.9.0

[root@node3 k8s]# kubectl get pod --all-namespaces
NAMESPACE     NAME                                       READY     STATUS    RESTARTS   AGE
kube-system   calico-etcd-tkmpj                          1/1       Running   0          7m
kube-system   calico-kube-controllers-559b575f97-2zngp   1/1       Running   10         11m
kube-system   calico-node-6gxx8                          2/2       Running   10         11m
kube-system   calico-node-rmd7h                          2/2       Running   11         11m
kube-system   calico-node-tjwct                          2/2       Running   11         11m
kube-system   etcd-node3                                 1/1       Running   1          1h
kube-system   kube-apiserver-node3                       1/1       Running   1          1h
kube-system   kube-controller-manager-node3              1/1       Running   1          1h
kube-system   kube-dns-6f4fd4bdf-5vw7d                   3/3       Running   3          1h
kube-system   kube-proxy-d994x                           1/1       Running   1          1h
kube-system   kube-proxy-k2bdk                           1/1       Running   1          1h
kube-system   kube-proxy-ksp6b                           1/1       Running   1          1h
kube-system   kube-scheduler-node3                       1/1       Running   1          1h

 

转载于:https://my.oschina.net/huangweibin/blog/1634169

你可能感兴趣的:(使用 kubeadmin 离线部署 kubernetes1.9)