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