LCM sidecar charm
[osm/devops.git] / installers / install_microk8s_cluster.sh
1 #!/usr/bin/env bash
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 set +eux
16
17 # MicroK8s installation
18 sudo snap install yq
19 sudo snap install microk8s --classic
20 sudo usermod -a -G microk8s ubuntu
21 newgrp microk8s
22 sudo microk8s.status --wait-ready
23 sudo microk8s.enable storage dns
24 # sudo microk8s.enable storage rbac
25 # sudo microk8s.enable storage helm
26 # sudo microk8s.enable storage helm3
27
28 # Enables MetalLB
29 PRIVATE_IP=$(hostname -I | awk '{print $1}')
30 echo ${PRIVATE_IP}
31 sudo microk8s.enable metallb:${PRIVATE_IP}-${PRIVATE_IP}
32
33 # Updates the certificate to allow connections from outside as well (i.e. to the "public" IP).
34 #sudo microk8s.stop
35 sudo sed -i "s/\#MOREIPS/IP.3 = ${NEW_K8S_IP}/g" /var/snap/microk8s/current/certs/csr.conf.template
36 cat /var/snap/microk8s/current/certs/csr.conf.template
37 #sudo microk8s.refresh-certs -i
38 #sudo microk8s.start
39
40 # Retrieves and saves the credentials
41 sudo microk8s.config | sed "s/server: .*/server: https:\/\/${NEW_K8S_IP}:16443/g" \
42 | tee ${HOME}/.kube/config
43 echo
44 echo Credentials saved at ${HOME}/.kube/config
45 echo
46
47 return 0
48