Merge "Testcases shouldn't run prematurely from installer script"
[multicloud/k8s.git] / kud / hosting_providers / containerized / README.md
1 # Multi cluster installation
2
3 ## Introduction
4
5 Multi Cluster installation is an important features for production deployments.
6
7 Most of the project are using the Kubernetes as undercloud orchestration. So deploying multi cluster for the multi cloud region should be maintained by Kubernetes
8
9 This section explains how to deploy the Multi cluster of Kubernetes from a containerized KUD running as a Kubernetes Job.
10
11 ## How it works
12
13 KUD installation installer is divided into two regions with args - `--install-pkg` and `--cluster <cluster-name>`
14
15 ### Args
16 **--install-pkg** - Installs packages required to run installer script itself inside a container and kubespray packages
17
18 **--cluster < cluster-name >** - Installs k8s cluster, addons and plugins and store the artifacts in the host machine
19
20 ### Internal Mechanism
21
22 * Container image is build using the `installer --install-pkg` arg and Kubernetes job is used to install the cluster using `installer --cluster <cluster-name>`. Installer will invoke the kubespray cluster.yml, kud-addsons and plugins ansible cluster.
23
24 Installer script finds the `hosts.init` for each cluster in `/opt/multi-cluster/<cluster-name>`
25
26 Kubernetes jobs(a cluster per job) are used to install multiple clusters and logs of each cluster deployments are stored in the `/opt/kud/multi-cluster/<cluster-name>/logs` and artifacts are stored as follows `/opt/kud/multi-cluster/<cluster-name>/artifacts`
27
28 ## Quickstart Installation Guide
29
30 Build the kud docker images as follows:
31
32 ```
33 $ git clone https://github.com/onap/multicloud-k8s.git && cd multicloud-k8s
34 $  docker build  --rm \
35         --build-arg http_proxy=${http_proxy} \
36         --build-arg HTTP_PROXY=${HTTP_PROXY} \
37         --build-arg https_proxy=${https_proxy} \
38         --build-arg HTTPS_PROXY=${HTTPS_PROXY} \
39         --build-arg no_proxy=${no_proxy} \
40         --build-arg NO_PROXY=${NO_PROXY} \
41         -t github.com/onap/multicloud-k8s:latest . -f build/Dockerfile
42 ```
43 Let's create a cluster-101 and cluster-102 hosts.ini as follows
44
45 ```
46 $ mkdir -p /opt/kud/multi-cluster/{cluster-101,cluster-102}
47 ```
48
49 Create hosts.ini as follows in the direcotry cluster-101(c01 IP address 10.10.10.3) and cluster-102(c02 IP address 10.10.10.5)
50
51 ```
52 /opt/kud/multi-cluster/cluster-101/hosts.ini
53 [all]
54 c01 ansible_ssh_host=10.10.10.5 ansible_ssh_port=22
55
56 [kube-master]
57 c01
58
59 [kube-node]
60 c01
61
62 [etcd]
63 c01
64
65 [ovn-central]
66 c01
67
68 [ovn-controller]
69 c01
70
71 [virtlet]
72 c01
73
74 [k8s-cluster:children]
75 kube-node
76 kube-master
77 ```
78 Do the same for the cluster-102 with c01 and IP address 10.10.10.5.
79
80 Create the ssh secret for Baremetal or VM based on your deployment. and Launch the kubernetes job as follows
81 ```
82 $ kubectl create secret generic ssh-key-secret --from-file=id_rsa=/root/.ssh/id_rsa --from-file=id_rsa.pub=/root/.ssh/id_rsa.pub
83 $ CLUSTER_NAME=cluster-101
84 $ cat <<EOF | kubectl create -f -
85 apiVersion: batch/v1
86 kind: Job
87 metadata:
88   name: kud-$CLUSTER_NAME
89 spec:
90   template:
91     spec:
92       hostNetwork: true
93       containers:
94         - name: kud
95           image: github.com/onap/multicloud-k8s:latest
96           imagePullPolicy: IfNotPresent
97           volumeMounts:
98           - name: multi-cluster
99             mountPath: /opt/kud/multi-cluster
100           - name: secret-volume
101             mountPath: "/.ssh"
102           command: ["/bin/sh","-c"]
103           args: ["cp -r /.ssh /root/; chmod -R 600 /root/.ssh; ./installer --cluster $CLUSTER_NAME"]
104           securityContext:
105             privileged: true
106       volumes:
107       - name: multi-cluster
108         hostPath:
109           path: /opt/kud/multi-cluster
110       - name: secret-volume
111         secret:
112           secretName: ssh-key-secret
113       restartPolicy: Never
114   backoffLimit: 0
115
116 EOF
117 ```
118
119 Multi - cluster information from the host machine;
120
121 ```
122 $ kubectl --kubeconfig=/opt/kud/multi-cluster/cluster-101/artifacts/admin.conf cluster-info
123 Kubernetes master is running at https://192.168.121.2:6443
124 coredns is running at https://192.168.121.2:6443/api/v1/namespaces/kube-system/services/coredns:dns/proxy
125 kubernetes-dashboard is running at https://192.168.121.2:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
126
127 To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
128 $ kubectl --kubeconfig=/opt/kud/multi-cluster/cluster-102/artifacts/admin.conf cluster-info
129 Kubernetes master is running at https://192.168.121.6:6443
130 coredns is running at https://192.168.121.6:6443/api/v1/namespaces/kube-system/services/coredns:dns/proxy
131 kubernetes-dashboard is running at https://192.168.121.6:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy
132
133 To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
134 ```
135
136
137 ## License
138
139 Apache-2.0