diff --git a/bootstrap/.gitignore b/bootstrap/.gitignore index 94eba82..d08070b 100644 --- a/bootstrap/.gitignore +++ b/bootstrap/.gitignore @@ -1 +1,2 @@ -kubespray/** +kubespray +venv diff --git a/bootstrap/README.md b/bootstrap/README.md index 2e97c00..d6cb708 100644 --- a/bootstrap/README.md +++ b/bootstrap/README.md @@ -11,6 +11,7 @@ vagrant up vagrant ssh k8s-1 ``` +TODO 16.02.2020: Vagrant up works but no k8s is installed. Maybe due to wrong ansible playbook or because from here on kubespray should kick in ## Done steps diff --git a/bootstrap/config.rb b/bootstrap/config.rb deleted file mode 100644 index d1e8e40..0000000 --- a/bootstrap/config.rb +++ /dev/null @@ -1,2 +0,0 @@ -$num_instances = 1 -$os = "centos" diff --git a/bootstrap/dev.inventory b/bootstrap/dev.inventory new file mode 100644 index 0000000..5fdc46c --- /dev/null +++ b/bootstrap/dev.inventory @@ -0,0 +1,36 @@ +# ## Configure 'ip' variable to bind kubernetes services on a +# ## different ip than the default iface +# ## We should set etcd_member_name for etcd cluster. The node that is not a etcd member do not need to set the value, or can set the empty string value. +[all] +# node1 ansible_host=95.54.0.12 # ip=10.3.0.1 etcd_member_name=etcd1 +# node2 ansible_host=95.54.0.13 # ip=10.3.0.2 etcd_member_name=etcd2 +# node3 ansible_host=95.54.0.14 # ip=10.3.0.3 etcd_member_name=etcd3 +# node4 ansible_host=95.54.0.15 # ip=10.3.0.4 etcd_member_name=etcd4 +# node5 ansible_host=95.54.0.16 # ip=10.3.0.5 etcd_member_name=etcd5 +# node6 ansible_host=95.54.0.17 # ip=10.3.0.6 etcd_member_name=etcd6 + +# ## configure a bastion host if your nodes are not directly reachable +# bastion ansible_host=x.x.x.x ansible_user=some_user + +[kube-master] +# node1 +# node2 + +[etcd] +# node1 +# node2 +# node3 + +[kube-node] +# node2 +# node3 +# node4 +# node5 +# node6 + +[calico-rr] + +[k8s-cluster:children] +kube-master +#kube-node +#calico-rr diff --git a/bootstrap/init_kubespray.sh b/bootstrap/init_kubespray.sh index 5bf6ef4..5ad795b 100755 --- a/bootstrap/init_kubespray.sh +++ b/bootstrap/init_kubespray.sh @@ -1,5 +1,32 @@ #!/bin/sh -# Idempotently initializes a fresh kubespray repo clone +# use virtualenv to install all python requirements +VENVDIR=venv +virtualenv --python=/usr/local/bin/python3 $VENVDIR +source $VENVDIR/bin/activate +pip install -r kubespray/requirements.txt + +# prepare an inventory to test with +INV=dev.inventory +rm -rf kubespray/${INV}.bak &> /dev/null +mv kubespray/${INV} kubespray/${INV}.bak &> /dev/null +cp -a kubespray/inventory/sample kubespray/${INV} +rm -f kubespray/${INV}/hosts.ini + +# customize the vagrant environment mkdir -p kubespray/vagrant -cp config.rb kubespray/vagrant/config.rb \ No newline at end of file +cat << EOF > kubespray/vagrant/config.rb +\$instance_name_prefix = "k8s" +\$vm_cpus = 4 +\$num_instances = 1 +\$os = "centos" +\$subnet = "10.0.20" +\$network_plugin = "flannel" +\$inventory = "$INV" +\$shared_folders = { 'temp/docker_rpms' => "/var/cache/yum/x86_64/7/docker-ce/packages" } +EOF + +# make the rpm cache +mkdir -p kubespray/temp/docker_rpms + +echo "Now cd to kubespray and 'vagrant up'" \ No newline at end of file