ansible-kubernetes1.8.3
使用ansible一键安装kubernetes高可用集群
git clone
准备
五台CentOS,7.3版本,最小化安装,设置好IP
下载二进制文件,移动到项目里对应的roles/x/files目录里。文章最后有目录列表。 密码:ef8u
编辑hosts和sshkeys.sh ,修改相应IP。除非你和我设置相同的IP
一台ansible主机,最好是新版,我用的2.4,需要安装如下软件
kubectl
cfssl
cfssljson
expect
1.分发公钥(首先你得生成)
expect sshkeys.exp
2.生成证书
bash ssl.sh
3.安装集群
ansible-playbook -i hosts install.yml
测试
etcd
export ETCDCTL_API=3etcdctl --cacert=/etc/etcd/ssl/etcd-root-ca.pem --cert=/etc/etcd/ssl/etcd.pem --key=/etc/etcd/ssl/etcd-key.pem --endpoints=https://192.168.1.121:2379,https://192.168.1.122:2379,https://192.168.1.123:2379 endpoint healthhttps://192.168.1.121:2379 is healthy: successfully committed proposal: took = 3.16568mshttps://192.168.1.122:2379 is healthy: successfully committed proposal: took = 2.934936mshttps://192.168.1.123:2379 is healthy: successfully committed proposal: took = 1.977868ms
Master
[root@kube121 ~]# kubectl get csNAME STATUS MESSAGE ERRORcontroller-manager Healthy ok scheduler Healthy ok etcd-2 Healthy {"health": "true"} etcd-1 Healthy {"health": "true"} etcd-0 Healthy {"health": "true"}
Note
[root@kube121 ~]# kubectl get nodeNAME STATUS ROLES AGE VERSIONkube124 Ready2h v1.8.3kube125 Ready 2h v1.8.3
最终的目录
├── fenfassh.exp├── files│ ├── cfssl│ ├── cfssljson│ ├── etcdssl│ │ ├── etcd-key.pem│ │ ├── etcd.pem│ │ ├── etcd-root-ca-key.pem│ │ └── etcd-root-ca.pem│ ├── images│ │ ├── gcr.io_google_containers_cluster-proportional-autoscaler-amd64_1.1.2-r2.tar│ │ ├── gcr.io_google_containers_pause-amd64_3.0.tar│ │ ├── k8s-dns-dnsmasq-nanny.tar│ │ ├── k8s-dns-dnsmasq.tar│ │ ├── k8s-dns-sidecar.tar│ │ ├── nginx.tar│ │ ├── quay.io_calico_cni_v1.11.0.tar│ │ ├── quay.io_calico_kube-controllers_v1.0.0.tar│ │ └── quay.io_calico_node_v2.6.1.tar│ ├── k8ssl│ │ ├── admin-key.pem│ │ ├── admin.pem│ │ ├── k8s-root-ca-key.pem│ │ ├── k8s-root-ca.pem│ │ ├── kube-proxy-key.pem│ │ ├── kube-proxy.kubeconfig│ │ ├── kube-proxy.pem│ │ ├── kubernetes-key.pem│ │ └── kubernetes.pem│ └── kube│ ├── audit-policy.yaml│ ├── bootstrap.kubeconfig│ └── token.csv├── group_vars│ └── all├── hosts├── install.retry├── install.yml├── README.md├── roles│ ├── calico│ │ ├── files│ │ │ ├── calico.sh│ │ │ ├── calico.yaml│ │ │ ├── kube-dns.yaml│ │ │ └── rbac.yaml│ │ └── tasks│ │ └── main.yml│ ├── init│ │ ├── files│ │ │ ├── CentOS7-Base-163.repo│ │ │ └── docker-ce.repo│ │ └── tasks│ │ └── main.yml│ ├── Master│ │ ├── files│ │ │ ├── etcd│ │ │ │ ├── etcd│ │ │ │ └── etcdctl│ │ │ └── kube│ │ │ ├── calicoctl│ │ │ ├── kube-apiserver│ │ │ ├── kube-controller-manager│ │ │ ├── kubectl│ │ │ └── kube-scheduler│ │ ├── handlers│ │ ├── tasks│ │ │ └── main.yml│ │ └── templates│ │ ├── apiserver│ │ ├── config│ │ ├── controller-manager│ │ ├── etcd.conf.j2│ │ ├── etcd.service│ │ ├── kube-apiserver.service│ │ ├── kube-controller-manager.service│ │ ├── kube-scheduler.service│ │ └── scheduler│ └── Node│ ├── files│ │ ├── kubectl│ │ ├── kubelet│ │ └── kube-proxy│ ├── handlers│ │ └── main.yml│ ├── tasks│ │ └── main.yml│ └── templates│ ├── calico-node.service│ ├── config│ ├── kubelet│ ├── kubelet.service│ ├── kube-proxy.service│ ├── nginx.conf│ ├── nginx-proxy.service│ └── proxy└── ssl.sh