diff --git a/bootstrap/README.md b/bootstrap/README.md index 3a644bb..f0c798e 100644 --- a/bootstrap/README.md +++ b/bootstrap/README.md @@ -1,23 +1,57 @@ # Bootstrap -The following lines document hwo to initalize a fresh cluster. On a real cluster, or using Vagrant. It therefore assumes to clone kubespray to this folder. It will be excluded in *.gitignore* and all files are in this folder. +The following lines document how to initalize a fresh cluster. On a real cluster, or using Vagrant. It therefore assumes to clone kubespray to this folder. It will be excluded in *.gitignore* and all files are in this folder. + +## Vagrant ```sh -git clone https://github.com/kubernetes-sigs/kubespray.git -#git clone git@github.com:iptizer/kubespray.git -./init_kubespray.sh +./init.sh cd kubespray vagrant up # up and abkle to ssh 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 +## Prod -## Done steps - -The following steps have been done while first setup and are not required to be redone: +Prepare server: ```sh -cp ./kubespray/Vagrantfile . +ssh centos@ +# auth via pw +sudo su - root +adduser moritz +visudo # add as sudo user +sudo yum -y install vim python3 +ssh-keygen +vim .ssh/authorized_users # paste key +chmod 644 .ssh/authorized_users +# check whether login works with ssh key +sudo vim /etc/ssh/sshd_config # remove pw auth & root login +sudo yum upgrade -y && sudo reboot ``` + +Install Kubernetes: + +```sh +$ ./init.sh +$ # follow instructions from output, sth like: +$ cd kubespray │nginx-ingress-default-backend-5b967cf596-sk7p7 1/1 Running 0 22h +$ ansible-playbook -i inventory/prod/inventory.ini cluster.yml +``` + +And get credentials: + +```sh +ssh +sudo su - root +cd +cp -r .kube /home/moritz/ +chown -R moritz. /home/moritz/.kube +#ctrl + d +kubectl get ns # test connection +#ctrl + d +scp haumdaucher.de:/home/moritz/.kube/config .kube/config +``` + +Foreward in k8s-directory. \ No newline at end of file diff --git a/bootstrap/init.sh b/bootstrap/init.sh index c4f0cd4..600ff15 100755 --- a/bootstrap/init.sh +++ b/bootstrap/init.sh @@ -40,6 +40,5 @@ echo "## Preparing real prod environment" cp -r kubespray/inventory/sample kubespray/inventory/prod rm kubespray/inventory/prod/inventory.ini cp ./prod.ini kubespray/inventory/prod/inventory.ini -echo "to deploy execute:" -echo "$ cd kubespray" -echo "$ ansible-playbook -i inventory/prod/inventory.ini cluster.yml" \ No newline at end of file +gsed -i "s/kube_network_plugin: .*/kube_network_plugin: flannel/" ./kubespray/inventory/prod/group_vars/k8s-cluster/k8s-cluster.yml +gsed -i "s/metrics_server_enabled: .*/metrics_server_enabled: true/" ./kubespray/inventory/prod/group_vars/k8s-cluster/addons.yml \ No newline at end of file