From f947fc8a93f3a3363d2b300bfabbdf51240d4e26 Mon Sep 17 00:00:00 2001 From: Alok Bhatt Date: Wed, 11 Nov 2020 04:32:33 +0000 Subject: [PATCH] helm3 and K8 1.18 support added helm3 and k8 1.18 are supported now. helm2 would be working fine. Also fixed some helm charts to work these with both helm versions Issue-Id: RIC-677 Signed-off-by: Alok Bhatt Change-Id: Icad9a8c079139b65157f0c87cadf2274290aea32 --- bin/install | 23 +++++++++++++++++++---- bin/uninstall | 12 +++++++++++- helm/alarmadapter/templates/deployment.yaml | 2 +- helm/appmgr/templates/deployment.yaml | 2 +- helm/appmgr/templates/serviceaccount.yaml | 23 ++++++++++++----------- helm/jaegeradapter/templates/deployment.yaml | 2 +- helm/xapp-onboarder/templates/deployment.yaml | 8 ++++---- 7 files changed, 49 insertions(+), 23 deletions(-) diff --git a/bin/install b/bin/install index eb95d93..2607acc 100755 --- a/bin/install +++ b/bin/install @@ -62,6 +62,7 @@ function wait_for_cats() { } KERNEL_OPTIMIZATION=false +IS_HELM3=$(helm version --short|grep -e "^v3") while [ -n "$1" ]; do # while loop starts @@ -92,7 +93,12 @@ if [ -z "$OVERRIDEYAML" ];then exit 1 fi -HAS_COMMON_PACKAGE=$(helm search local/ric-common | grep ric-common) +if [ -z $IS_HELM3 ] +then + HAS_COMMON_PACKAGE=$(helm search local/ric-common | grep ric-common) +else + HAS_COMMON_PACKAGE=$(helm search repo local/ric-common | grep ric-common) +fi if [ -z "$HAS_COMMON_PACKAGE" ];then echo "****************************************************************************************************************" @@ -218,8 +224,12 @@ subjects: name: tiller namespace: kube-system EOF -kubectl apply -f ricplt-role.yaml -rm ricplt-role.yaml + +if [ -z $IS_HELM3 ] +then + kubectl apply -f ricplt-role.yaml + rm ricplt-role.yaml +fi # Add kernel optimization for radis services @@ -278,7 +288,12 @@ fi for component in $COMPONENTS; do helm dep up $DIR/../helm/$component - helm install -f $OVERRIDEYAML --namespace "${PLTNAMESPACE:-ricplt}" --name "${RELEASE_PREFIX}-$component" $DIR/../helm/$component + COMPONENT="${RELEASE_PREFIX}-$component" + if [ -z $IS_HELM3 ] + then + COMPONENT=" --name $COMPONENT" + fi + helm install -f $OVERRIDEYAML --namespace "${PLTNAMESPACE:-ricplt}" $COMPONENT $DIR/../helm/$component sleep 8 done diff --git a/bin/uninstall b/bin/uninstall index 51db408..fa8fc0a 100755 --- a/bin/uninstall +++ b/bin/uninstall @@ -32,12 +32,22 @@ INFRANAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *infra:/{print $2}') XAPPNAMESPACE=$(echo "$NAMESPACE_BLOCK" | awk '/^ *xapp:/{print $2}') RELEASE_PREFIX=$(echo "$COMMON_BLOCK" | awk '/^ *releasePrefix:/{print $2}') +IS_HELM3=$(helm version --short|grep -e "^v3") echo "Undeploying RIC platform components [$COMPONENTS]" +HELM_FLAG='' +if [ $IS_HELM3 ] +then + HELM_FLAG=' -n '${PLTNAMESPACE:-ricplt} +else + HELM_FLAG='--purge' +fi + + for component in $COMPONENTS; do - helm delete --purge ${RELEASE_PREFIX}-$component + helm delete $HELM_FLAG ${RELEASE_PREFIX}-$component done kubectl delete cm -n ${PLTNAMESPACE:-ricplt} ricplt-recipe diff --git a/helm/alarmadapter/templates/deployment.yaml b/helm/alarmadapter/templates/deployment.yaml index 9b82ff3..8d02070 100644 --- a/helm/alarmadapter/templates/deployment.yaml +++ b/helm/alarmadapter/templates/deployment.yaml @@ -64,7 +64,7 @@ spec: volumeMounts: - mountPath: /alarmadaptercfg name: appconfig-file - subpath: config-file.json + subPath: config-file.json ports: - name: "http" containerPort: {{ include "common.serviceport.alarmadapter.http" . }} diff --git a/helm/appmgr/templates/deployment.yaml b/helm/appmgr/templates/deployment.yaml index f1c38e3..9fb698e 100644 --- a/helm/appmgr/templates/deployment.yaml +++ b/helm/appmgr/templates/deployment.yaml @@ -131,11 +131,11 @@ spec: # httpGet: # path: / # port: http - restartPolicy: Always securityContext: # ubuntu #runAsUser: 1000 #allowPrivilegeEscalation: false + restartPolicy: Always volumes: - name: config-volume configMap: diff --git a/helm/appmgr/templates/serviceaccount.yaml b/helm/appmgr/templates/serviceaccount.yaml index 407fb1f..13d1c39 100644 --- a/helm/appmgr/templates/serviceaccount.yaml +++ b/helm/appmgr/templates/serviceaccount.yaml @@ -26,10 +26,9 @@ metadata: namespace: {{ include "common.namespace.platform" . }} --- apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: Role +kind: ClusterRole metadata: name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.tillerNameSpace" $ctx }}-access - namespace: {{ include "common.tillerDeployNameSpace" $ctx }} rules: - apiGroups: [""] resources: ["pods/portforward"] @@ -40,18 +39,18 @@ rules: {{- if or (eq (include "common.tillerTLSVerify" $ctx) "true" ) (eq (include "common.tillerTLSAuthenticate" $ctx) "true") }} - apiGroups: [""] resources: ["secrets"] - resourceNames: [ {{ include "common.tillerHelmClientTLSSecret" $ctx | quote }} ] - verbs: ["get"] + #resourceNames: [ {{ include "common.tillerHelmClientTLSSecret" $ctx | quote }} ] + verbs: ["get","list"] {{- end }} --- apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: RoleBinding +kind: ClusterRoleBinding metadata: name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.tillerNameSpace" $ctx }}-access - namespace: {{ include "common.tillerDeployNameSpace" $ctx }} + namespace: {{ include "common.namespace.platform" . }} roleRef: apiGroup: rbac.authorization.k8s.io - kind: Role + kind: ClusterRole name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.tillerNameSpace" $ctx }}-access subjects: - kind: ServiceAccount @@ -59,23 +58,25 @@ subjects: namespace: {{ include "common.namespace.platform" . }} --- apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: Role +kind: ClusterRole metadata: name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.tillerNameSpace" $ctx }}-getappconfig - namespace: {{ include "common.tillerNameSpace" $ctx }} + #namespace: {{ include "common.tillerNameSpace" $ctx }} + #namespace: {{ include "common.namespace.platform" . }} rules: - apiGroups: [""] resources: ["configmaps", "endpoints", "services"] verbs: ["get", "list", "create", "update", "delete"] --- apiVersion: rbac.authorization.k8s.io/v1beta1 -kind: RoleBinding +kind: ClusterRoleBinding metadata: name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.namespace.xapp" . }}-getappconfig namespace: {{ include "common.tillerNameSpace" $ctx }} + #namespace: {{ include "common.namespace.platform" . }} roleRef: apiGroup: rbac.authorization.k8s.io - kind: Role + kind: ClusterRole name: {{ include "common.serviceaccountname.appmgr" . }}-{{ include "common.tillerNameSpace" $ctx }}-getappconfig subjects: - kind: ServiceAccount diff --git a/helm/jaegeradapter/templates/deployment.yaml b/helm/jaegeradapter/templates/deployment.yaml index ef319dd..9cdedfd 100644 --- a/helm/jaegeradapter/templates/deployment.yaml +++ b/helm/jaegeradapter/templates/deployment.yaml @@ -82,4 +82,4 @@ spec: httpGet: path: / port: {{ include "common.serviceport.jaegeradapter.httpquery" . }} - initialDelaySeconds: 5 + initialDelaySeconds: 5 diff --git a/helm/xapp-onboarder/templates/deployment.yaml b/helm/xapp-onboarder/templates/deployment.yaml index d43c730..cd8e2f7 100644 --- a/helm/xapp-onboarder/templates/deployment.yaml +++ b/helm/xapp-onboarder/templates/deployment.yaml @@ -41,6 +41,10 @@ spec: release: {{ .Release.Name }} spec: hostname: {{ include "common.name.xapp-onboarder" . }} + securityContext: + fsGroup: 0 + runAsUser: 0 + restartPolicy: Always imagePullSecrets: {{- $newctx := dict "ctx" $ "defaultregistry" .Values.xapponboarder.image.xapponboarder.registry }} - name: {{ include "common.dockerregistry.credential" $newctx }} @@ -50,9 +54,6 @@ spec: image: {{ include "common.dockerregistry.url" $newctx }}/{{ .Values.xapponboarder.image.chartmuseum.name }}:{{ .Values.xapponboarder.image.chartmuseum.tag }} {{- $newctx := dict "ctx" $ "defaultpullpolicy" .Values.xapponboarder.imagePullPolicy }} imagePullPolicy: {{ include "common.dockerregistry.pullpolicy" $newctx }} - securityContext: - fsGroup: 0 - runAsUser: 0 envFrom: - configMapRef: name: {{ include "common.configmapname.xapp-onboarder" . }}-chartmuseum-env @@ -86,4 +87,3 @@ spec: # httpGet: # path: / # port: http - restartPolicy: Always -- 2.16.6