Kubernetes Installation / Using kubespray / Ubuntu 18.04, OpenStack Environment
1. Installation Environment
![[Figure 1] Kubernetes Installation Environment](/blog-software/docs/record/kubernetes-installation-kubespray-ubuntu-18.04-openstack/images/environment.png)
[Figure 1] Kubernetes Installation Environment
[Figure 1] shows the Kubernetes installation environment. The installation environment is as follows.
- VM: Ubuntu 18.04, 4 vCPU, 4GB Memory
- ETCD Node * 3
- Master Node * 2
- Slave Node * 3
- Deploy Node * 1
- Network
- NAT Network: 192.168.0.0/24
- Octavia Network: 20.0.0.0/24
- Tenant Network: 30.0.0.0/24
- OpenStack: Stein
- API Server: 192.168.0.40:5000
- Octavia
- Kubernetes
- CNI: Cilium Plugin
- kubespray: 2.10.4
2. Ubuntu Package Installation
(All)$ apt-get update
(All)$ apt-get install python-pip python3-pipInstall Python and Pip on all nodes.
3. Ansible Configuration
(Deploy)$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id-rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id-rsa.
Your public key has been saved in /root/.ssh/id-rsa.pub.
The key fingerprint is:
SHA256:Sp0SUDPNKxTIYVObstB0QQPoG/csF9qe/v5+S5e8hf4 root@kube02
The key's randomart image is:
+---[RSA 2048]----+
| oBB@= |
| .+o+.*o |
| .. o.+ . |
| o..ooo.. |
| +.=ooS |
| . o.=o . o |
| +.. . = .|
| o ..o o |
| ..oooo...o.E|
+----[SHA256]-----+Generate an SSH key on the Deploy Node. Enter a blank for passphrase (Password) to not set it. If set, you must enter the passphrase every time accessing Managed Nodes via SSH from the Deploy Node.
(Deploy)$ ssh-copy-id root@30.0.0.11
(Deploy)$ ssh-copy-id root@30.0.0.12
(Deploy)$ ssh-copy-id root@30.0.0.13Use the ssh-copy-id command from the Deploy Node to copy the generated SSH public key to the ~/.ssh/authorized-keys file of the remaining nodes.
4. kubespray Configuration and Execution
(Deploy)$ ~
(Deploy)$ git clone -b v2.10.4 https://github.com/kubernetes-sigs/kubespray.git
(Deploy)$ cd kubespray
(Deploy)$ pip3 install -r requirements.txt
(Deploy)$ cp -rfp inventory/sample inventory/myclusterInstall kubespray and copy the sample inventory.
| |
Store information and roles for each VM in the inventory/mycluster/inventory.ini file on the Deploy Node.
| |
Set the Cloud Provider to OpenStack in the inventory/mycluster/group-vars/all/all.yml file on the Deploy Node.
| |
Configure the Octavia Load Balancer for Kubernetes LoadBalancer Service in the inventory/mycluster/group-vars/all/openstack.yml file on the Deploy Node. Check and set the External Network ID and External Network Subnet ID.
| |
Configure the CNI plugin to use cilium and enable Persistent Volume in the inventory/mycluster/group-vars/k8s-cluster/k8s-cluster.yml file on the Deploy Node to configure Kubernetes to use OpenStack’s Cinder.
| |
Configure the roles/bootstrap-os/defaults/main.yml file on the Deploy Node to not override the hostname where Kubernetes is installed.
| |
Create the openstack-rc file based on the OpenStack RC file information.
(Deploy)$ source ~/kubespray/openstack-rc
(Deploy)$ ansible-playbook -i ~/kubespray/inventory/mycluster/inventory.ini --become --become-user=root cluster.ymlConfigure the Kubernetes Cluster from the Deploy Node.
5. Kubernetes Cluster Reset
(Deploy)$ source openstack-rc
(Deploy)$ ansible-playbook -i ~/kubespray/inventory/mycluster/inventory.ini --become --become-user=root reset.ymlReset the Kubernetes Cluster from the Deploy Node.