安装完成后可以查看下状态:
[root@master ~]# kubectl get nodes NAME STATUS AGE master Ready,master 6m minion01 Ready 2m minion02 Ready 2m 7 安装Calico网络网络组件选择很多,可以根据自己的需要选择calico、weave、flannel,calico性能最好,weave和flannel差不多。Addons中有配置好的yaml,部署环境使用的阿里云的VPC,官方提供的flannel.yaml创建的flannel网络有问题,所以本文中尝试calico网络,。
kubectl apply -f 0/getting-started/kubernetes/installation/hosted/kubeadm/calico.yaml如果使用了外部etcd,去掉其中以下内容,并修改etcd_endpoints: [ETCD_ENDPOINTS]:
--- # This manifest installs the Calico etcd on the kubeadm master. This uses a DaemonSet # to force it to run on the master even when the master isn't schedulable, and uses # nodeSelector to ensure it only runs on the master. apiVersion: extensions/v1beta1 kind: DaemonSet metadata: name: calico-etcd namespace: kube-system labels: k8s-app: calico-etcd spec: template: metadata: labels: k8s-app: calico-etcd annotations: scheduler.alpha.kubernetes.io/critical-pod: '' scheduler.alpha.kubernetes.io/tolerations: | [{"key": "dedicated", "value": "master", "effect": "NoSchedule" }, {"key":"CriticalAddonsOnly", "operator":"Exists"}] spec: # Only run this pod on the master. nodeSelector: kubeadm.alpha.kubernetes.io/role: master hostNetwork: true containers: - name: calico-etcd image: gcr.io/google_containers/etcd:2.2.1 env: - name: CALICO_ETCD_IP valueFrom: fieldRef: fieldPath: status.podIP command: ["/bin/sh","-c"] args: ["/usr/local/bin/etcd --name=calico --data-dir=/var/etcd/calico-data --advertise-client-urls=http://$CALICO_ETCD_IP:6666 --listen-client-urls=http://0.0.0.0:6666 --listen-peer-urls=http://0.0.0.0:6667"] volumeMounts: - name: var-etcd mountPath: /var/etcd volumes: - name: var-etcd hostPath: path: /var/etcd --- # This manfiest installs the Service which gets traffic to the Calico # etcd. apiVersion: v1 kind: Service metadata: labels: k8s-app: calico-etcd name: calico-etcd namespace: kube-system spec: # Select the calico-etcd pod running on the master. selector: k8s-app: calico-etcd # This ClusterIP needs to be known in advance, since we cannot rely # on DNS to get access to etcd. clusterIP: 10.96.232.136 ports: - port: 6666检查各节点组件运行状态:
[root@master work]# kubectl get po -n=kube-system -o wide NAME READY STATUS RESTARTS AGE IP NODE calico-node-0jkjn 2/2 Running 0 25m 172.16.1.101 master calico-node-w1kmx 2/2 Running 2 25m 172.16.1.106 minion01 calico-node-xqch6 2/2 Running 0 25m 172.16.1.107 minion02 calico-policy-controller-807063459-d7z47 1/1 Running 0 11m 172.16.1.107 minion02 dummy-2088944543-qw3vr 1/1 Running 0 29m 172.16.1.101 master kube-apiserver-master 1/1 Running 0 28m 172.16.1.101 master kube-controller-manager-master 1/1 Running 0 29m 172.16.1.101 master kube-discovery-1769846148-lzlff 1/1 Running 0 29m 172.16.1.101 master kube-dns-2924299975-jfvrd 4/4 Running 0 29m 192.168.228.193 master kube-proxy-6bk7n 1/1 Running 0 28m 172.16.1.107 minion02 kube-proxy-6pgqz 1/1 Running 1 29m 172.16.1.106 minion01 kube-proxy-7ms6m 1/1 Running 0 29m 172.16.1.101 master kube-scheduler-master 1/1 Running 0 28m 172.16.1.101 master说明:kube-dns需要等calico配置完成后才是running状态。
8 部署Dashboard下载kubernetes-dashboard.yaml
curl -O https://rawgit.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml