From 4af2ac38d2fb26d5efd0887b2eff9f90314b4c0c Mon Sep 17 00:00:00 2001 From: Zhe Huang Date: Wed, 26 Jun 2019 16:47:44 -0400 Subject: [PATCH] Integrate appmgr with common template. Add ingress controller entries in the common templates. Signed-off-by: Zhe Huang Change-Id: I257d2eba71002ea5d0c3ee553b22298ef41aa804 --- .../helm/a1mediator/templates/service.yaml | 10 +- .../helm/appmgr/resources/appenv.yaml | 4 +- .../helm/appmgr/templates/appconfig.yaml | 3 +- .../helm/appmgr/templates/appenv.yaml | 6 +- .../helm/appmgr/templates/deployment.yaml | 12 +- .../helm/appmgr/templates/service.yaml | 2 +- .../50-RIC-Platform/helm/appmgr/values.yaml | 2 +- .../_helpers.tpl => common/templates/_chart.tpl} | 31 +--- .../helm/common/templates/_configmapname.tpl | 17 +- .../helm/common/templates/_deploymentname.tpl | 14 +- .../helm/common/templates/_ingresscontroller.tpl | 189 +++++++++++++++++++++ .../helm/common/templates/_name.tpl | 17 ++ .../helm/common/templates/_servicename.tpl | 14 +- 13 files changed, 254 insertions(+), 67 deletions(-) rename ric-platform/50-RIC-Platform/helm/{appmgr/templates/_helpers.tpl => common/templates/_chart.tpl} (60%) create mode 100644 ric-platform/50-RIC-Platform/helm/common/templates/_ingresscontroller.tpl diff --git a/ric-platform/50-RIC-Platform/helm/a1mediator/templates/service.yaml b/ric-platform/50-RIC-Platform/helm/a1mediator/templates/service.yaml index 3321aa61..9f61e861 100644 --- a/ric-platform/50-RIC-Platform/helm/a1mediator/templates/service.yaml +++ b/ric-platform/50-RIC-Platform/helm/a1mediator/templates/service.yaml @@ -2,9 +2,15 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "a1mediator.fullname" . }} + name: {{ include "common.servicename.a1mediator" . }} labels: -{{ include "a1mediator.labels" . | indent 4 }} + app.kubernetes.io/name: {{ include "common.fullname.a1mediator" . }} + helm.sh/chart: {{ include "common.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + {{- if .Chart.AppVersion }} + app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} + {{- end }} + app.kubernetes.io/managed-by: {{ .Release.Service }} spec: type: {{ .Values.httpservice.type }} diff --git a/ric-platform/50-RIC-Platform/helm/appmgr/resources/appenv.yaml b/ric-platform/50-RIC-Platform/helm/appmgr/resources/appenv.yaml index c52bf15d..733bf073 100644 --- a/ric-platform/50-RIC-Platform/helm/appmgr/resources/appenv.yaml +++ b/ric-platform/50-RIC-Platform/helm/appmgr/resources/appenv.yaml @@ -1,5 +1,5 @@ NAME: xappmgr -DBAAS_SERVICE_HOST: "r0-dbaas-redis-standalone" +DBAAS_SERVICE_HOST: __DBAAS_SERVICE_HOST__ DBAAS_SERVICE_PORT: "6379" -DBAAS_PORT_6379_TCP_ADDR: "r0-dbaas-redis-standalone" +DBAAS_PORT_6379_TCP_ADDR: __DBAAS_SERVICE_HOST__ DBAAS_PORT_6379_TCP_PORT: "6379" diff --git a/ric-platform/50-RIC-Platform/helm/appmgr/templates/appconfig.yaml b/ric-platform/50-RIC-Platform/helm/appmgr/templates/appconfig.yaml index 79f334d5..7c6efb89 100644 --- a/ric-platform/50-RIC-Platform/helm/appmgr/templates/appconfig.yaml +++ b/ric-platform/50-RIC-Platform/helm/appmgr/templates/appconfig.yaml @@ -18,9 +18,8 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "appmgr.fullname" . }}-appconfig + name: {{ include "common.configmapname.appmgr" . }}-appconfig data: - appmgr.yaml: | {{- $restport := default ":8080" (printf ":%.0f" .Values.appmgr.containerPort) | quote -}} {{- $helmrepo := include "common.helmrepository" . | quote -}} {{- $reponame := default "helm-repo" .Values.appmgr.reponame | quote -}} diff --git a/ric-platform/50-RIC-Platform/helm/appmgr/templates/appenv.yaml b/ric-platform/50-RIC-Platform/helm/appmgr/templates/appenv.yaml index 5f6c8e7a..c0382642 100644 --- a/ric-platform/50-RIC-Platform/helm/appmgr/templates/appenv.yaml +++ b/ric-platform/50-RIC-Platform/helm/appmgr/templates/appenv.yaml @@ -18,7 +18,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "appmgr.fullname" . }}-appenv + name: {{ include "common.configmapname.appmgr" . }}-appenv data: - {{- (.Files.Get "resources/appenv.yaml") | nindent 2 }} - + {{- $dbaasservicehost := include "common.servicename.dbaas" . | quote -}} + {{- (.Files.Get "resources/appenv.yaml") | replace "__DBAAS_SERVICE_HOST__" $dbaasservicehost | nindent 2 }} diff --git a/ric-platform/50-RIC-Platform/helm/appmgr/templates/deployment.yaml b/ric-platform/50-RIC-Platform/helm/appmgr/templates/deployment.yaml index b6711523..dbcd3152 100644 --- a/ric-platform/50-RIC-Platform/helm/appmgr/templates/deployment.yaml +++ b/ric-platform/50-RIC-Platform/helm/appmgr/templates/deployment.yaml @@ -18,7 +18,7 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: {{ include "appmgr.fullname" . }} + name: {{ include "common.deploymentname.appmgr" . }} namespace: {{ include "common.namespace" . }} labels: app: {{ include "common.namespace" . }}-{{ include "common.name" . }} @@ -31,8 +31,6 @@ spec: matchLabels: app: {{ include "common.namespace" . }}-{{ include "common.name" . }} release: {{ .Release.Name }} - #app.kubernetes.io/name: {{ include "appmgr.name" . }} - #app.kubernetes.io/instance: {{ .Release.Name }} template: metadata: labels: @@ -40,10 +38,6 @@ spec: release: {{ .Release.Name }} spec: hostname: {{ .Chart.Name }} - hostAliases: - - ip: "135.207.143.86" - hostnames: - - "helm.ricinfra.local" imagePullSecrets: - name: {{ include "common.repositoryCred" . }} containers: @@ -64,7 +58,7 @@ spec: mountPath: {{ .Values.appmgr.appcertpath }} envFrom: - configMapRef: - name: {{ include "appmgr.fullname" . }}-appenv + name: {{ include "common.configmapname.appmgr" . }}-appenv livenessProbe: #exec: # command: @@ -85,7 +79,7 @@ spec: volumes: - name: config-volume configMap: - name: {{ include "appmgr.fullname" . }}-appconfig + name: {{ include "common.configmapname.appmgr" . }}-appconfig - name: secret-volume secret: secretName: {{ include "common.helmrepositorycred" . }} diff --git a/ric-platform/50-RIC-Platform/helm/appmgr/templates/service.yaml b/ric-platform/50-RIC-Platform/helm/appmgr/templates/service.yaml index f7d73614..6c1241a0 100644 --- a/ric-platform/50-RIC-Platform/helm/appmgr/templates/service.yaml +++ b/ric-platform/50-RIC-Platform/helm/appmgr/templates/service.yaml @@ -18,7 +18,7 @@ apiVersion: v1 kind: Service metadata: - name: {{ include "appmgr.fullname" . }} + name: {{ include "common.servicename.appmgr" . }} namespace: {{ include "common.namespace" . }} labels: app: {{ include "common.namespace" . }}-{{ include "common.name" . }} diff --git a/ric-platform/50-RIC-Platform/helm/appmgr/values.yaml b/ric-platform/50-RIC-Platform/helm/appmgr/values.yaml index 2bb470b4..fe22ec4b 100644 --- a/ric-platform/50-RIC-Platform/helm/appmgr/values.yaml +++ b/ric-platform/50-RIC-Platform/helm/appmgr/values.yaml @@ -50,7 +50,7 @@ helmRepositoryTillerNamespace: "kube-system" # Helm Tiller port for xApp # The global setting will override this default value # You can further override using helmRepositoryTillerPortOverride: "" -helmRepositoryTillerPort: "44134" +helmRepositoryTillerPort: 44134 # Uncomment the following line to override the docker registry #repositoryOverride: "" diff --git a/ric-platform/50-RIC-Platform/helm/appmgr/templates/_helpers.tpl b/ric-platform/50-RIC-Platform/helm/common/templates/_chart.tpl similarity index 60% rename from ric-platform/50-RIC-Platform/helm/appmgr/templates/_helpers.tpl rename to ric-platform/50-RIC-Platform/helm/common/templates/_chart.tpl index b65d7fa0..1236b4b3 100644 --- a/ric-platform/50-RIC-Platform/helm/appmgr/templates/_helpers.tpl +++ b/ric-platform/50-RIC-Platform/helm/common/templates/_chart.tpl @@ -15,36 +15,7 @@ # limitations under the License. # ################################################################################ -{{/* vim: set filetype=mustache: */}} -{{/* -Expand the name of the chart. -*/}} -{{- define "appmgr.name" -}} -{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} -{{- end -}} - -{{/* -Create a default fully qualified app name. -We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). -If release name contains chart name it will be used as a full name. -*/}} -{{- define "appmgr.fullname" -}} -{{- if .Values.fullnameOverride -}} -{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- $name := default .Chart.Name .Values.nameOverride -}} -{{- if contains $name .Release.Name -}} -{{- .Release.Name | trunc 63 | trimSuffix "-" -}} -{{- else -}} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} -{{- end -}} -{{- end -}} -{{/* -Create chart name and version as used by the chart label. -*/}} -{{- define "appmgr.chart" -}} +{{- define "common.chart" -}} {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} {{- end -}} - diff --git a/ric-platform/50-RIC-Platform/helm/common/templates/_configmapname.tpl b/ric-platform/50-RIC-Platform/helm/common/templates/_configmapname.tpl index 2e13e060..671b620a 100644 --- a/ric-platform/50-RIC-Platform/helm/common/templates/_configmapname.tpl +++ b/ric-platform/50-RIC-Platform/helm/common/templates/_configmapname.tpl @@ -22,30 +22,33 @@ {{- define "common.configmapname.appmgr" -}} - {{- $name := ( include "common.name.appmgr" . ) -}} + {{- $name := ( include "common.fullname.appmgr" . ) -}} {{- printf "configmap-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "common.configmapname.dbaas" -}} - {{- $name := ( include "common.name.dbaas" . ) -}} + {{- $name := ( include "common.fullname.dbaas" . ) -}} {{- printf "configmap-%s" $name | trunc 63 | trimSuffix "-" -}} -{{- end -}} +{{- end -}}: {{- define "common.configmapname.e2mgr" -}} - {{- $name := ( include "common.name.e2mgr" . ) -}} + {{- $name := ( include "common.fullname.e2mgr" . ) -}} {{- printf "configmap-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "common.configmapname.e2term" -}} - {{- $name := ( include "common.name.e2term" . ) -}} + {{- $name := ( include "common.fullname.e2term" . ) -}} {{- printf "configmap-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "common.configmapname.rtmgr" -}} - {{- $name := ( include "common.name.rtmgr" . ) -}} + {{- $name := ( include "common.fullname.rtmgr" . ) -}} {{- printf "configmap-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} - +{{- define "common.configmapname.a1mediator" -}} + {{- $name := ( include "common.fullname.a1mediator" . ) -}} + {{- printf "configmap-%s" $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/ric-platform/50-RIC-Platform/helm/common/templates/_deploymentname.tpl b/ric-platform/50-RIC-Platform/helm/common/templates/_deploymentname.tpl index 7a43edca..2571a5cb 100644 --- a/ric-platform/50-RIC-Platform/helm/common/templates/_deploymentname.tpl +++ b/ric-platform/50-RIC-Platform/helm/common/templates/_deploymentname.tpl @@ -21,30 +21,34 @@ {{- define "common.deploymentname.appmgr" -}} - {{- $name := ( include "common.name.appmgr" . ) -}} + {{- $name := ( include "common.fullname.appmgr" . ) -}} {{- printf "deployment-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "common.deploymentname.dbaas" -}} - {{- $name := ( include "common.name.dbaas" . ) -}} + {{- $name := ( include "common.fullname.dbaas" . ) -}} {{- printf "deployment-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "common.deploymentname.e2mgr" -}} - {{- $name := ( include "common.name.e2mgr" . ) -}} + {{- $name := ( include "common.fullname.e2mgr" . ) -}} {{- printf "deployment-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "common.deploymentname.e2term" -}} - {{- $name := ( include "common.name.e2term" . ) -}} + {{- $name := ( include "common.fullname.e2term" . ) -}} {{- printf "deployment-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "common.deploymentname.rtmgr" -}} - {{- $name := ( include "common.name.rtmgr" . ) -}} + {{- $name := ( include "common.fullname.rtmgr" . ) -}} {{- printf "deployment-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{- define "common.deploymentname.a1mediator" -}} + {{- $name := ( include "common.fullname.a1mediator" . ) -}} + {{- printf "deployment-%s" $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/ric-platform/50-RIC-Platform/helm/common/templates/_ingresscontroller.tpl b/ric-platform/50-RIC-Platform/helm/common/templates/_ingresscontroller.tpl new file mode 100644 index 00000000..7ebbcd1a --- /dev/null +++ b/ric-platform/50-RIC-Platform/helm/common/templates/_ingresscontroller.tpl @@ -0,0 +1,189 @@ +################################################################################ +# Copyright (c) 2019 AT&T Intellectual Property. # +# Copyright (c) 2019 Nokia. # +# # +# 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 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +################################################################################ + +{{/* + Resolve the ingress controller addresses. +*/}} +{{- define "common.ingressurl.ricplt" -}} + {{- if .Values.kongplatform -}} + {{- if .Values.kongplatform.ingressurlOverride -}} + {{- printf "%s" .Values.kongplatform.ingressurlOverride -}} + {{- else -}} + {{- printf "ricplt-entry" -}} + {{- end -}} + {{- else -}} + {{- printf "ricplt-entry" -}} + {{- end -}} +{{- end -}} + + + +{{- define "common.ingresshttpport.ricplt" -}} + {{- if .Values.kongplatform -}} + {{- if .Values.kongplatform.ingresshttpportOverride -}} + {{- printf "%.0f" .Values.kongplatform.ingresshttpportOverride -}} + {{- else -}} + {{- printf "30080" -}} + {{- end -}} + {{- else -}} + {{- printf "30080" -}} + {{- end -}} +{{- end -}} + + + +{{- define "common.ingresshttpsport.ricplt" -}} + {{- if .Values.kongplatform -}} + {{- if .Values.kongplatform.ingresshttpsportOverride -}} + {{- printf "%.0f" .Values.kongplatform.ingresshttpsportOverride -}} + {{- else -}} + {{- printf "30443" -}} + {{- end -}} + {{- else -}} + {{- printf "30443" -}} + {{- end -}} +{{- end -}} + + + + + + + + + + + + + + + + +{{- define "common.ingressurl.ricxapp" -}} + {{- if .Values.kongxapp -}} + {{- if .Values.kongxapp.ingressurlOverride -}} + {{- printf "%s" .Values.kongxapp.ingressurlOverride -}} + {{- else -}} + {{- printf "ricxapp-entry" -}} + {{- end -}} + {{- else -}} + {{- printf "ricxapp-entry" -}} + {{- end -}} +{{- end -}} + + + +{{- define "common.ingresshttpport.ricxapp" -}} + {{- if .Values.kongxapp -}} + {{- if .Values.kongxapp.ingresshttpportOverride -}} + {{- printf "%.0f" .Values.kongxapp.ingresshttpportOverride -}} + {{- else -}} + {{- printf "31080" -}} + {{- end -}} + {{- else -}} + {{- printf "31080" -}} + {{- end -}} +{{- end -}} + + + +{{- define "common.ingresshttpsport.ricxapp" -}} + {{- if .Values.kongxapp -}} + {{- if .Values.kongxapp.ingresshttpsportOverride -}} + {{- printf "%.0f" .Values.kongxapp.ingresshttpsportOverride -}} + {{- else -}} + {{- printf "31443" -}} + {{- end -}} + {{- else -}} + {{- printf "31443" -}} + {{- end -}} +{{- end -}} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +{{- define "common.ingressurl.ricaux" -}} + {{- if .Values.kongaux -}} + {{- if .Values.kongaux.ingressurlOverride -}} + {{- printf "%s" .Values.kongaux.ingressurlOverride -}} + {{- else -}} + {{- printf "ricaux-entry" -}} + {{- end -}} + {{- else -}} + {{- printf "ricaux-entry" -}} + {{- end -}} +{{- end -}} + + + + + +{{- define "common.ingresshttpport.ricaux" -}} + {{- if .Values.kongaux -}} + {{- if .Values.kongaux.ingresshttpportOverride -}} + {{- printf "%.0f" .Values.kongaux.ingresshttpportOverride -}} + {{- else -}} + {{- printf "32080" -}} + {{- end -}} + {{- else -}} + {{- printf "32080" -}} + {{- end -}} +{{- end -}} + + + +{{- define "common.ingresshttpsport.ricaux" -}} + {{- if .Values.kongaux -}} + {{- if .Values.kongaux.ingresshttpsportOverride -}} + {{- printf "%.0f" .Values.kongaux.ingresshttpsportOverride -}} + {{- else -}} + {{- printf "32443" -}} + {{- end -}} + {{- else -}} + {{- printf "32443" -}} + {{- end -}} +{{- end -}} + diff --git a/ric-platform/50-RIC-Platform/helm/common/templates/_name.tpl b/ric-platform/50-RIC-Platform/helm/common/templates/_name.tpl index 7951a6d3..f9a553e0 100644 --- a/ric-platform/50-RIC-Platform/helm/common/templates/_name.tpl +++ b/ric-platform/50-RIC-Platform/helm/common/templates/_name.tpl @@ -133,6 +133,23 @@ +{{- define "common.name.a1mediator" -}} + {{- if .Values.a1mediator -}} + {{- if .Values.a1mediator.nameOverride -}} + {{- printf "%s" .Values.a1mediator.nameOverride -}} + {{- else -}} + {{- printf "a1mediator" -}} + {{- end -}} + {{- else -}} + {{- printf "a1mediator" -}} + {{- end -}} +{{- end -}} + + +{{- define "common.fullname.a1mediator" -}} + {{- $name := ( include "common.name.a1mediator" . ) -}} + {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} diff --git a/ric-platform/50-RIC-Platform/helm/common/templates/_servicename.tpl b/ric-platform/50-RIC-Platform/helm/common/templates/_servicename.tpl index f6ed74fb..20e381af 100644 --- a/ric-platform/50-RIC-Platform/helm/common/templates/_servicename.tpl +++ b/ric-platform/50-RIC-Platform/helm/common/templates/_servicename.tpl @@ -29,30 +29,34 @@ {{- define "common.servicename.appmgr" -}} - {{- $name := ( include "common.name.appmgr" . ) -}} + {{- $name := ( include "common.fullname.appmgr" . ) -}} {{- printf "service-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "common.servicename.dbaas" -}} - {{- $name := ( include "common.name.dbaas" . ) -}} + {{- $name := ( include "common.fullname.dbaas" . ) -}} {{- printf "service-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "common.servicename.e2mgr" -}} - {{- $name := ( include "common.name.e2mgr" . ) -}} + {{- $name := ( include "common.fullname.e2mgr" . ) -}} {{- printf "service-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "common.servicename.e2term" -}} - {{- $name := ( include "common.name.e2term" . ) -}} + {{- $name := ( include "common.fullname.e2term" . ) -}} {{- printf "service-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} {{- define "common.servicename.rtmgr" -}} - {{- $name := ( include "common.name.rtmgr" . ) -}} + {{- $name := ( include "common.fullname.rtmgr" . ) -}} {{- printf "service-%s" $name | trunc 63 | trimSuffix "-" -}} {{- end -}} +{{- define "common.servicename.a1mediator" -}} + {{- $name := ( include "common.fullname.a1mediator" . ) -}} + {{- printf "service-%s" $name | trunc 63 | trimSuffix "-" -}} +{{- end -}} -- 2.16.6