From: Lusheng Ji Date: Tue, 12 May 2020 02:27:09 +0000 (-0400) Subject: Fix for Helm init not able to find correct k8s server X-Git-Tag: f-release~110 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=ef5e8a36f7ae076da4d6bcf7ec383bc1817517b1;p=it%2Fdep.git Fix for Helm init not able to find correct k8s server Change-Id: Ia035f2665e2cf2f350079c89c4f0e8bfa60d7698 Signed-off-by: Lusheng Ji --- diff --git a/tools/k8s/heat/scripts/k8s_vm_install.sh b/tools/k8s/heat/scripts/k8s_vm_install.sh index 77641fa3..8b8f62de 100644 --- a/tools/k8s/heat/scripts/k8s_vm_install.sh +++ b/tools/k8s/heat/scripts/k8s_vm_install.sh @@ -1,6 +1,6 @@ #!/bin/bash -x ################################################################################ -# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019,2020 AT&T Intellectual Property. # # # # Licensed under the Apache License, Version 2.0 (the "License"); # # you may not use this file except in compliance with the License. # @@ -149,7 +149,7 @@ echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries # install low latency kernel, docker.io, and kubernetes apt-get update -RES=$(apt-get install -y virt-what curl jq netcat 2>&1) +RES=$(apt-get install -y virt-what curl jq netcat make 2>&1) if [[ $RES == */var/lib/dpkg/lock* ]]; then echo "Fail to get dpkg lock. Wait for any other package installation" echo "process to finish, then rerun this script" @@ -314,6 +314,7 @@ EOF mkdir -p .kube cp -i /etc/kubernetes/admin.conf /root/.kube/config chown root:root /root/.kube/config + export KUBECONFIG=/root/.kube/config # at this point we should be able to use kubectl kubectl get pods --all-namespaces @@ -328,10 +329,6 @@ EOF # if running a single node cluster, need to enable master node to run pods kubectl taint nodes --all node-role.kubernetes.io/master- - cd /root - # install RBAC for Helm - kubectl create -f rbac-config.yaml - # install Helm HELMV=$(cat /opt/config/helm_version.txt) HELMVERSION=${HELMV} @@ -342,13 +339,17 @@ EOF tar -xvf ../helm-v${HELMVERSION}-linux-amd64.tar.gz mv linux-amd64/helm /usr/local/bin/helm + cd /root + # install RBAC for Helm + kubectl create -f rbac-config.yaml + rm -rf /root/.helm if [[ ${KUBEV} == 1.16.* ]]; then # helm init uses API extensions/v1beta1 which is depreciated by Kubernetes # 1.16.0. Until upstream (helm) provides a fix, this is the work-around. - helm init --service-account tiller --override spec.selector.matchLabels.'name'='tiller',spec.selector.matchLabels.'app'='helm' --output yaml > helm-init.yaml - sed 's@apiVersion: extensions/v1beta1@apiVersion: apps/v1@' ./helm-init.yaml > helm-init-patched.yaml - kubectl apply -f ./helm-init-patched.yaml + helm init --service-account tiller --override spec.selector.matchLabels.'name'='tiller',spec.selector.matchLabels.'app'='helm' --output yaml > /tmp/helm-init.yaml + sed 's@apiVersion: extensions/v1beta1@apiVersion: apps/v1@' /tmp/helm-init.yaml > /tmp/helm-init-patched.yaml + kubectl apply -f /tmp/helm-init-patched.yaml else helm init --service-account tiller fi