Add script with commands to create ONAP in single VM
[infra/tools.git] / misc_onap_scripts / setup_onap_inonevm.sh
1 # This is a set commands that can install an ONAP in a HUGE VM.
2 # they were assembeled by jan.j.martensson@ericsson.com and tested to run in the environment made available by
3 # https://etherpad.opnfv.org/p/laas-access
4 #
5 # They will probably not work "out of the box" but form the basis of a set of commands that can work
6
7 # Turn off firewall and allow all incoming HTTP connections through IPTABLES
8
9 ufw disable
10
11 iptables -I INPUT -j ACCEPT
12
13
14
15 # Install git
16
17 apt-get install -y git
18
19
20
21 # Install needed utilities
22
23 apt-get install -y apt-transport-https ca-certificates curl software-properties-common
24
25
26
27 # Install Docker
28
29 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
30
31 add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
32
33 apt-get update
34
35 apt-get install -y docker-ce=17.03.3~ce-0~ubuntu-xenial
36
37
38
39 # Install Kubernetes
40
41 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
42
43 add-apt-repository "deb [arch=amd64] https://apt.kubernetes.io/ kubernetes-xenial main"
44
45 apt-get update
46
47 apt-get install -y kubelet=1.11.2-00
48
49 apt-get install -y kubectl=1.11.2-00
50
51 apt-get install -y kubeadm=1.11.2-00
52
53 git clone https://github.com/kubernetes-incubator/metrics-server.git
54 #cd metrics-server/
55 #kubectl create -f metrics-server/deploy/1.8+/
56
57
58 # Install Helm
59
60 wget http://storage.googleapis.com/kubernetes-helm/helm-v2.9.1-linux-amd64.tar.gz
61
62 tar -zxvf helm-v2.9.1-linux-amd64.tar.gz
63
64 mv linux-amd64/helm /usr/local/bin/helm
65
66
67
68 # Install jq
69
70 apt-get install -y jq
71
72
73
74 # Install make
75
76 apt-get install -y make
77
78
79
80 # Create a yaml file to change the default value of maxpods from 110 to 300
81
82 cat > maxpods.yaml << EOF
83
84 apiVersion: kubeadm.k8s.io/v1alpha2
85
86 kubeletConfiguration:
87
88   baseConfig:
89     maxPods: 300
90     serializeImagePulls: false
91 EOF
92
93
94
95 # Initialize the kubernetes cluster. If needed, disable swap (swapoff -a) before running kubeadm
96
97 kubeadm init --config maxpods.yaml | tee ~/kubeadm_init.log
98
99
100
101 # Execute the following snippet to get kubectl to work
102
103 mkdir -p $HOME/.kube
104
105 cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
106
107 chown $(id -u):$(id -g) $HOME/.kube/config
108
109
110
111 # Install the Weaver pod network
112
113 kubectl apply -f https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')
114
115
116
117 # Check status
118
119 kubectl get pods --all-namespaces -o wide
120
121
122
123 # Untaint the cluster
124
125 kubectl taint nodes --all node-role.kubernetes.io/master-
126
127
128
129 # Create a yaml file to define the Tiller service account and cluster role binding
130
131 cat > tiller-serviceaccount.yaml << EOF
132
133 apiVersion: v1
134
135 kind: ServiceAccount
136
137 metadata:
138
139   name: tiller
140
141   namespace: kube-system
142
143 ---
144
145 kind: ClusterRoleBinding
146
147 apiVersion: rbac.authorization.k8s.io/v1beta1
148
149 metadata:
150
151   name: tiller-clusterrolebinding
152
153 subjects:
154
155 - kind: ServiceAccount
156
157   name: tiller
158
159   namespace: kube-system
160
161 roleRef:
162
163   kind: ClusterRole
164
165   name: cluster-admin
166
167   apiGroup: ""
168
169 EOF
170
171
172
173 # Create a ServiceAccount and ClusterRoleBinding based on the created file.
174
175 kubectl create -f tiller-serviceaccount.yaml
176
177 kubectl create -f metrics-server/deploy/1.8+/
178
179
180 # Initialize Helm to install Tiller
181
182 helm init --service-account tiller --upgrade
183
184
185
186 # Check status
187
188 kubectl get pods --all-namespaces -o wide
189
190
191
192 # Clone the OOM project
193
194 git clone https://gerrit.onap.org/r/oom
195
196 cd oom/kubernetes
197
198
199
200 # Copy oom/kubernetes/helm/plugins directory into your local ~/.helm/ folder
201
202 cp -R ~/oom/kubernetes/helm/plugins/ ~/.helm
203
204
205
206 # Create Helm repository
207
208 make repo
209
210
211
212 # Create Helm charts
213
214 make; make onap
215
216
217
218 # Deploy ONAP from the OOM codebase using local Helm Chart Repository (default configuration values defined in onap/values.yaml)
219
220 helm deploy demo local/onap --namespace onap
221
222
223
224 # Check status. It will take more than 60 minutes before ONAP is installed. There will be several failing pods. Several of the failing pods can be healed by deleting the pods. The failing pods that cannot be healed need deeper analysis.
225
226 kubectl get pods --all-namespaces -o wide
227
228 #kubectl delete -n onap pod <pod name>
229
230
231
232 # After the failing Portal pods have been deleted and healed, check status of the portal-app service
233
234 #kubectl get services -n onap | grep portal-app
235
236 #portal-app  LoadBalancer   10.108.87.95   <pending>    8989:30215/TCP,8006:30213/TCP,8010:30214/TCP,8443:30225/TCP   22h
237
238
239
240 # Workaround to avoid the pending EXTERNAL-IP for portal-app
241
242 #kubectl -n onap expose deployment demo-portal-portal-app --type=LoadBalancer --name=portal-wa --external-ip=<host IP address> --port=8443 --target-port=8443
243
244
245
246 # Check status of the portal-wa service. The EXTERNAL-IP should be present
247
248 #kubectl get services -n onap | grep portal-wa
249
250 #portal-wa  LoadBalancer   10.105.168.224   10.10.100.32    8443:30997/TCP        16s
251
252
253
254 # Update /etc/hosts with “<host IP address>   portal.api.simpledemo.onap.org sdc.api.simpledemo.onap.org sdc.api.fe.simpledemo.onap.org vid.api.simpledemo.onap.org cli.api.simpledemo.onap.org aai.api.sparky.simpledemo.onap.org aai.onap portal-app.onap”
255
256 #vim /etc/hosts
257
258
259
260 # Access the ONAP Portal with curl or web browser
261
262 #curl -k https://portal.api.simpledemo.onap.org:8443/ONAPPORTAL/login.htm
263
264
265
266 # Install firefox. Ignore the warnings
267
268 apt-get install -y firefox
269
270 #firefox&