57 lines
1.3 KiB
Markdown
57 lines
1.3 KiB
Markdown
# Bootstrap
|
|
|
|
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
|
|
./init.sh
|
|
cd kubespray
|
|
vagrant up
|
|
# up and abkle to ssh
|
|
vagrant ssh k8s-1
|
|
```
|
|
|
|
## Prod
|
|
|
|
Prepare server:
|
|
|
|
```sh
|
|
ssh centos@<ip>
|
|
# 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 <ip>
|
|
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. |