2 #############################################################################
3 # Copyright © 2019 Bell.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 #############################################################################
18 # This installation is for an RKE install of kubernetes
19 # after this run the standard oom install
20 # this installation can be run on any ubuntu 16.04/18.04 VM, RHEL 7.6 (root only), physical or cloud azure/aws host
21 # https://wiki.onap.org/display/DW/OOM+RKE+Kubernetes+Deployment
22 # source from https://jira.onap.org/browse/OOM-1598
25 # RKE 0.1.16 Kubernetes 1.11.6, kubectl 1.11.6, Helm 2.9.1, Docker 18.06
26 # 20190428 RKE 0.2.1, Kubernetes 1.13.5, kubectl 1.13.5, Helm 2.12.3, Docker 18.09.5
27 # single node install, HA pending
33 sudo ./rke_setup.sh -b dublin -s rke.onap.cloud -e onap -l amdocs -v true
35 -b [branch] : branch = master or dublin (required)
36 -s [server] : server = IP or DNS name (required)
37 -e [environment] : use the default (onap)
38 -k [key] : ssh key name
39 -l [username] : login username account (use ubuntu for example)
48 KUBECTL_VERSION=1.13.5
52 # copy your private ssh key and cluster.yml file to the vm
54 #sudo cp ~/.ssh/onap_rsa .
55 #sudo chmod 777 onap_rsa
56 #scp onap_rsa ubuntu@192.168.241.132:~/
58 #sudo chmod 400 onap_rsa
59 #sudo cp onap_rsa ~/.ssh
60 # make sure public key is insetup correctly in
61 # sudo vi ~/.ssh/authorized_keys
63 echo "please supply your ssh key as provided by the -k keyname - it must be be chmod 400 and chown user:user in ~/.ssh/"
64 echo "The RKE version specific cluster.yaml is already integrated in this script for 0.2.1 no need for below generation..."
65 echo "rke config --name cluster.yml"
67 echo "address: $SERVER"
68 echo "user: $USERNAME"
69 echo "ssh_key_path: $SSHPATH_PREFIX/$SSHKEY"
75 HYPERCUBE=1.13.5-rancher1
76 POD_INFRA_CONTAINER=rancher/pause:3.1
78 cat > cluster.yml <<EOF
79 # generated from rke_setup.sh
90 docker_socket: /var/run/docker.sock
92 ssh_key_path: $SSHPATH_PREFIX/$SSHKEY
116 service_cluster_ip_range: 10.43.0.0/16
117 service_node_port_range: ""
118 pod_security_policy: false
119 always_pull_images: false
125 cluster_cidr: 10.42.0.0/16
126 service_cluster_ip_range: 10.43.0.0/16
138 cluster_domain: cluster.local
139 infra_container_image: ""
140 cluster_dns_server: 10.43.0.10
155 etcd: rancher/coreos-etcd:v3.2.24-rancher1
156 alpine: rancher/rke-tools:v$RKETOOLS
157 nginx_proxy: rancher/rke-tools:v$RKETOOLS
158 cert_downloader: rancher/rke-tools:v$RKETOOLS
159 kubernetes_services_sidecar: rancher/rke-tools:v$RKETOOLS
160 kubedns: rancher/k8s-dns-kube-dns:1.15.0
161 dnsmasq: rancher/k8s-dns-dnsmasq-nanny:1.15.0
162 kubedns_sidecar: rancher/k8s-dns-sidecar:1.15.0
163 kubedns_autoscaler: rancher/cluster-proportional-autoscaler:1.0.0
164 kubernetes: rancher/hyperkube:v$HYPERCUBE
165 flannel: rancher/coreos-flannel:v0.10.0-rancher1
166 flannel_cni: rancher/flannel-cni:v0.3.0-rancher1
167 calico_node: rancher/calico-node:v3.4.0
168 calico_cni: rancher/calico-cni:v3.4.0
169 calico_controllers: ""
170 calico_ctl: rancher/calico-ctl:v2.0.0
171 canal_node: rancher/calico-node:v3.4.0
172 canal_cni: rancher/calico-cni:v3.4.0
173 canal_flannel: rancher/coreos-flannel:v0.10.0
174 wave_node: weaveworks/weave-kube:2.5.0
175 weave_cni: weaveworks/weave-npc:2.5.0
176 pod_infra_container: $POD_INFRA_CONTAINER
177 ingress: rancher/nginx-ingress-controller:0.21.0-rancher3
178 ingress_backend: rancher/nginx-ingress-controller-defaultbackend:1.4-rancher1
179 metrics_server: rancher/metrics-server:v0.3.1
180 ssh_key_path: $SSHPATH
182 ssh_agent_auth: false
186 ignore_docker_version: false
187 kubernetes_version: "$KUBERNETES_VERSION"
188 private_registries: []
218 echo "Installing on ${SERVER} for ${BRANCH}: RKE: ${RKE_VERSION} Kubectl: ${KUBECTL_VERSION} Helm: ${HELM_VERSION} Docker: ${DOCKER_VERSION} username: ${USERNAME}"
219 sudo echo "127.0.0.1 ${SERVER}" >> /etc/hosts
220 echo "Install docker - If you must install as non-root - comment out the docker install below - run it separately, run the user mod, logout/login and continue this script"
221 curl https://releases.rancher.com/install-docker/$DOCKER_VERSION.sh | sh
222 sudo usermod -aG docker $USERNAME
225 sudo wget https://github.com/rancher/rke/releases/download/v$RKE_VERSION/rke_linux-amd64
226 mv rke_linux-amd64 rke
228 sudo mv ./rke /usr/local/bin/rke
230 echo "Install make - required for beijing+ - installed via yum groupinstall Development Tools in RHEL"
232 sudo apt-get install make -y
234 sudo curl -LO https://storage.googleapis.com/kubernetes-release/release/v$KUBECTL_VERSION/bin/linux/amd64/kubectl
235 sudo chmod +x ./kubectl
236 sudo mv ./kubectl /usr/local/bin/kubectl
238 wget http://storage.googleapis.com/kubernetes-helm/helm-v${HELM_VERSION}-linux-amd64.tar.gz
239 sudo tar -zxvf helm-v${HELM_VERSION}-linux-amd64.tar.gz
240 sudo mv linux-amd64/helm /usr/local/bin/helm
242 echo "Bringing RKE up - using supplied cluster.yml"
244 echo "wait 2 extra min for the cluster"
248 echo "copy kube_config_cluter.yaml generated - to ~/.kube/config"
249 sudo cp kube_config_cluster.yml ~/.kube/config
250 # avoid using sudo for kubectl
251 sudo chmod 777 ~/.kube/config
252 echo "Verify all pods up on the kubernetes system - will return localhost:8080 until a host is added"
253 echo "kubectl get pods --all-namespaces"
254 kubectl get pods --all-namespaces
255 echo "install tiller/helm"
256 kubectl -n kube-system create serviceaccount tiller
257 kubectl create clusterrolebinding tiller --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
258 helm init --service-account tiller
259 kubectl -n kube-system rollout status deploy/tiller-deploy
260 echo "upgrade server side of helm in kubernetes"
261 if [ "$USERNAME" == "root" ]; then
268 if [ "$USERNAME" == "root" ]; then
271 sudo helm init --upgrade
275 echo "verify both versions are the same below"
276 if [ "$USERNAME" == "root" ]; then
281 echo "start helm server"
282 if [ "$USERNAME" == "root" ]; then
289 echo "add local helm repo"
290 if [ "$USERNAME" == "root" ]; then
291 helm repo add local http://127.0.0.1:8879
294 sudo helm repo add local http://127.0.0.1:8879
297 echo "To enable grafana dashboard - do this after running cd.sh which brings up onap - or you may get a 302xx port conflict"
298 echo "kubectl expose -n kube-system deployment monitoring-grafana --type=LoadBalancer --name monitoring-grafana-client"
299 echo "to get the nodeport for a specific VM running grafana"
300 echo "kubectl get services --all-namespaces | grep graf"
304 kubectl get services --all-namespaces
305 kubectl get pods --all-namespaces
314 SSHPATH_PREFIX=~/.ssh
316 while getopts ":b:s:e:u:l:k:v" PARAM; do
347 if [[ -z $BRANCH ]]; then
352 install_onap $BRANCH $SERVER $ENVIRON $USERNAME $SSHPATH_PREFIX $SSHKEY $VALIDATE