From b718998b544f4922bbace252477f74f1e3c76763 Mon Sep 17 00:00:00 2001 From: Gary Wu Date: Wed, 14 Nov 2018 10:01:37 -0800 Subject: Refactor k8s VM init script to use cloud-init Refactor k8s VM init script to use cloud-init to do apt dist-upgrade and reboot first before installing rancher agent. Change-Id: Id3d58d276673aff1d0d14bee103d1cdd9f7a3d3e Issue-ID: INT-586 Signed-off-by: Gary Wu --- deployment/heat/onap-oom/k8s_vm_install.sh | 60 ++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 deployment/heat/onap-oom/k8s_vm_install.sh (limited to 'deployment/heat/onap-oom/k8s_vm_install.sh') diff --git a/deployment/heat/onap-oom/k8s_vm_install.sh b/deployment/heat/onap-oom/k8s_vm_install.sh new file mode 100644 index 000000000..e5b843e5d --- /dev/null +++ b/deployment/heat/onap-oom/k8s_vm_install.sh @@ -0,0 +1,60 @@ +#!/bin/bash -x +# Copyright 2018 Huawei Technologies Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +export DEBIAN_FRONTEND=noninteractive +echo "__host_private_ip_addr__ $(hostname)" >> /etc/hosts +printenv + +mkdir -p /opt/config +echo "__docker_version__" > /opt/config/docker_version.txt +echo "__rancher_ip_addr__" > /opt/config/rancher_ip_addr.txt +echo "__rancher_private_ip_addr__" > /opt/config/rancher_private_ip_addr.txt +echo "__host_private_ip_addr__" > /opt/config/host_private_ip_addr.txt + +mkdir -p /etc/docker +if [ ! -z "__docker_proxy__" ]; then + cat > /etc/docker/daemon.json < /etc/apt/apt.conf.d/30proxy < /dev/null; do + apt-get -y update + apt-get -y dist-upgrade + apt-get -y install linux-image-extra-$(uname -r) apt-transport-https ca-certificates curl software-properties-common jq nfs-common + sleep 10 +done + +# install docker 17.03 +while ! hash docker &> /dev/null; do + curl -s https://releases.rancher.com/install-docker/__docker_version__.sh | sh + usermod -aG docker ubuntu + sleep 10 +done +apt-mark hold docker-ce + +# Enable autorestart when VM reboots +update-rc.d k8s_vm_init_serv defaults -- cgit 1.2.3-korg