3 source /var/onap/functions
7 export RANCHER_URL=http://localhost:$RANCHER_PORT
8 export RANCHER_ACCESS_KEY='access_key'
9 export RANCHER_SECRET_KEY='secret_key'
11 # _install_docker() - Function that installs Docker version for Rancher
12 function _install_docker {
13 if ! $(docker version &>/dev/null); then
14 curl https://releases.rancher.com/install-docker/1.12.sh | sh
15 _configure_docker_settings 15
19 # _pull_rancher_images() - Function that retrieves Rancher images required for k8s
20 function _pull_rancher_images {
21 for image in "net:v0.13.5" "k8s:v1.8.5-rancher3" \
22 "lb-service-rancher:v0.7.17" "network-manager:v0.7.18" "metadata:v0.9.5" \
23 "kubectld:v0.8.5" "kubernetes-agent:v0.6.6" "dns:v0.15.3" \
24 "kubernetes-auth:v0.0.8" "healthcheck:v0.3.3" "etcd:v2.3.7-13" \
25 "etc-host-updater:v0.0.3" "net:holder"; do
26 pull_docker_image rancher/$image &
30 # _pull_k8s_images() - Function that retrieves Google k8s images
31 function _pull_k8s_images {
32 for image in "kubernetes-dashboard-amd64:v1.7.1" \
33 "k8s-dns-sidecar-amd64:1.14.5" "k8s-dns-kube-dns-amd64:1.14.5" \
34 "k8s-dns-dnsmasq-nanny-amd64:1.14.5" "heapster-influxdb-amd64:v1.3.3" \
35 "heapster-grafana-amd64:v4.4.3" "heapster-amd64:v1.4.0" "pause-amd64:3.0"; do
36 pull_docker_image gcr.io/google_containers/$image &
40 # _install_rancher() - Function that installs Rancher CLI and container
41 function _install_rancher {
42 local rancher_version=v0.6.5
43 local rancher_server_version=v1.6.10
44 local rancher_server=rancher/server:$rancher_server_version
46 if [ ! -d /opt/rancher/current ]; then
47 mkdir -p /opt/rancher/current
48 wget https://github.com/rancher/cli/releases/download/$rancher_version/rancher-linux-amd64-$rancher_version.tar.gz
49 tar -xzf rancher-linux-amd64-$rancher_version.tar.gz -C /tmp
50 mv /tmp/rancher-$rancher_version/rancher /opt/rancher/current/
54 pull_docker_image $rancher_server
55 run_docker_image -d --restart=unless-stopped -p $RANCHER_PORT:8080 $rancher_server
57 if curl --fail -X GET $RANCHER_URL; then
60 echo "waiting for racher"
65 # _install_kubernetes() - Function that deploys kubernetes via RancherOS host registration
66 function _install_kubernetes {
67 local rancher_agent_version=v1.2.7
68 local rancher_agent=rancher/agent:$rancher_agent_version
74 pull_docker_image $rancher_agent
77 pushd /opt/rancher/current/
78 export RANCHER_ENVIRONMENT=`./rancher env create -t kubernetes onap_on_kubernetes`
81 install_python_package rancher-agent-registration
82 export no_proxy=$no_proxy,$IP_ADDRESS
83 rancher-agent-registration --host-ip $IP_ADDRESS --url http://$IP_ADDRESS:$RANCHER_PORT --environment $RANCHER_ENVIRONMENT --key $RANCHER_ACCESS_KEY --secret $RANCHER_SECRET_KEY
86 # _install_kubectl() - Function that installs kubectl as client for kubernetes
87 function _install_kubectl {
88 if ! $(kubectl version &>/dev/null); then
90 curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
92 mv ./kubectl /usr/local/bin/kubectl
95 python /var/onap/files/kubectl_config_generator.py
100 # _install_helm() - Function that install Kubernetes Package Manager
101 function _install_helm {
102 local helm_version=v2.3.0
104 if ! $(helm version &>/dev/null); then
105 wget http://storage.googleapis.com/kubernetes-helm/helm-${helm_version}-linux-amd64.tar.gz
106 tar -zxvf helm-${helm_version}-linux-amd64.tar.gz -C /tmp
107 mv /tmp/linux-amd64/helm /usr/local/bin/helm
112 # _pull_images_from_yaml() - Function that parses a yaml file and pull their images
113 function _pull_images_from_yaml_file {
116 local s='[[:space:]]*'
117 local w='[a-zA-Z0-9_]*'
118 fs=`echo @|tr @ '\034'`
120 for line in $(sed -ne "s|^\($s\):|\1|" \
121 -e "s|^\($s\)\($w\)$s:$s[\"']\(.*\)[\"']$s\$|\1$fs\2$fs\3|p" \
122 -e "s|^\($s\)\($w\)$s:$s\(.*\)$s\$|\1$fs\2$fs\3|p" $values_file |
124 indent = length($1)/2;
130 if (length($3) > 0) {
131 vn=""; for (i=0; i<indent; i++) {vn=(vn)(vname[i])(".")}
132 printf("%s%s%s=%s\n", "'$prefix'",vn, $2, $3);
136 if echo $line | grep -q Version ; then
137 pull_docker_image "$image_name:$(echo $line | awk -F "=" '{print $2}')" &
139 image_name=`echo ${line#*=}`
140 if [[ ${image_name#*${nexus_docker_repo:-nexus3.onap.org:10001}} == *:* ]]; then
141 pull_docker_image $image_name &
143 pull_docker_image $image_name:latest
149 # get_oom_images() - Function that retrieves ONAP images from official hub
150 function get_oom_images {
151 if [[ "$build_image" == "True" ]]; then
152 # TODO(electrocucaracha): Create a function for calling the build docker function of every ONAP project
153 echo "Not Implemented"
155 if [[ "$clone_repo" != "True" ]]; then
159 docker_openecomp_login
160 for values_file in `find ${src_folders[oom]}/kubernetes -name values.yaml -type f`; do
161 _pull_images_from_yaml_file $values_file
168 # _install_oom() - Function that clones OOM and deploys ONAP
169 function install_oom {
170 if [[ "$clone_repo" != "True" ]]; then
173 pushd ${src_folders[oom]}/kubernetes/oneclick
176 pushd ${src_folders[oom]}/kubernetes/config
177 cp onap-parameters-sample.yaml onap-parameters.yaml
178 ./createConfig.sh -n onap
181 for app in consul msb mso message-router sdnc vid robot portal policy appc aai sdc dcaegen2 log cli multicloud clamp vnfsdk uui aaf vfc kube2msb; do
182 ./createAll.bash -n onap -a $app
187 # init_oom() - Function that deploys ONAP using OOM
189 mount_external_partition sda /var/lib/docker/
193 if [[ "$clone_repo" == "True" ]]; then
197 if [[ "$skip_get_images" == "False" ]]; then
199 if [[ "$skip_install" == "False" ]]; then
200 until kubectl cluster-info; do
201 echo "waiting for kubernetes host"