标签:kubernetes
Kubespray 是 Kubernetes incubator 中的项目,目标是提供 Production Ready Kubernetes 部署方案,该项目基础是通过 Ansible Playbook 来定义系统与 Kubernetes 集群部署的任务,具有以下几个特点:可以部署在 AWS, GCE, Azure, OpenStack以及裸机上.
部署 High Available Kubernetes 集群.
可组合性(Composable),可自行选择 Network Plugin (flannel, calico, canal, weave) 来部署.
支持多种 Linux distributions(CoreOS, Debian Jessie, Ubuntu 16.04, CentOS/RHEL7)
宿主机Ubuntu17.10,也是ansible主机
kubernetes v1.8.3
etcd v3.2.4
calico v2.5.0
docker 17.03
Centos 7.4
$ sudo apt-get update
$ sudo apt-get install software-properties-common
$ sudo apt-add-repository ppa:ansible/ansible
$ sudo apt-get update
$ sudo apt-get install ansible python-netaddr python-pbr
git clone https://github.com/bravem/ansible-k8s.git
yum install docker-engine-17.03.1.ce-1.el7.centos -y
kubespray/roles/download/defaults/main.yml 这个文件定义了镜像版本,按照这文件提前下载所需镜像
下载后直接上传至虚拟机
gcr.io/google_containers/kubernetes-dashboard-amd64:v1.8.1
gcr.io/google_containers/hyperkube:v1.8.3
lachlanevenson/k8s-helm:2.7.0
gcr.io/google_containers/k8s-dns-sidecar-amd64:1.14.7
gcr.io/google_containers/k8s-dns-kube-dns-amd64:1.14.7
gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64:1.14.7
andyshinn/dnsmasq:2.78
quay.io/calico/ctl:v1.5.0
quay.io/calico/node:v2.5.0
quay.io/calico/kube-policy-controller:v0.7.0
xueshanf/install-socat:latest
quay.io/calico/cni:v1.10.0
quay.io/calico/routereflector:v0.4.0
quay.io/coreos/etcd:v3.2.4
gcr.io/google_containers/cluster-proportional-autoscaler-amd64:1.1.1
gcr.io/google_containers/fluentd-elasticsearch:1.22
gcr.io/google_containers/elasticsearch:v2.4.1
gcr.io/google_containers/kibana:v4.6.1
nginx:1.11.4-alpine
gcr.io/google_containers/pause-amd64:3.0
[all]
node1 ansible_host=192.168.1.121 ip=192.168.1.121 ansible_user=root
node2 ansible_host=192.168.1.122 ip=192.168.1.122 ansible_user=root
node3 ansible_host=192.168.1.123 ip=192.168.1.123 ansible_user=root
node4 ansible_host=192.168.1.124 ip=192.168.1.124 ansible_user=root
node5 ansible_host=192.168.1.125 ip=192.168.1.125 ansible_user=root
node6 ansible_host=192.168.1.126 ip=192.168.1.126 ansible_user=root
[kube-master]
node1
[kube-node]
node2
node3
[etcd]
node1
node2
node3
[k8s-cluster:children]
kube-node
kube-master
#!/usr/bin/expect -f
set timeout -1
set user root
set passwd "password"
for { set i 121 } { $i < 124 } { incr i } {
spawn ssh-copy-id $user@192.168.1.$i
expect {
"yes/no" { send "yes\r";exp_continue }
"id_rsa" { send "yes\r";exp_continue }
"*assword" { send "$passwd\r" }
}
}
expect eof
expect sshkeys.exp
ansible-playbook -i inventory/inventory.cfg cluster.yml
[all]
node1 ansible_host=192.168.1.121 ip=192.168.1.121 ansible_user=root
node2 ansible_host=192.168.1.122 ip=192.168.1.122 ansible_user=root
node3 ansible_host=192.168.1.123 ip=192.168.1.123 ansible_user=root
node4 ansible_host=192.168.1.124 ip=192.168.1.124 ansible_user=root
node5 ansible_host=192.168.1.125 ip=192.168.1.125 ansible_user=root
node6 ansible_host=192.168.1.126 ip=192.168.1.126 ansible_user=root
[kube-master]
node1
node5
[kube-node]
node2
node3
node4
.....
ansible-playbook -i inventory/inventory.cfg cluster.yml --limit node4,node5
标签:kubernetes
原文地址:http://blog.51cto.com/brave666/2053906