From c60bed072004dd9071824704ed8a3718fbcaed6c Mon Sep 17 00:00:00 2001 From: Mohamed Abukar Date: Tue, 11 Jun 2019 07:57:10 +0300 Subject: [PATCH] Update standard xApp helm chart Change-Id: I29f24be18771a93ecda7a388daf6bb1c52179dbe Signed-off-by: Mohamed Abukar --- .../90-xApps/helm/xapp-std/config/config-file.json | 20 +++ .../90-xApps/helm/xapp-std/descriptors/schema.json | 147 +++++++++++++++++++++ .../helm/xapp-std/templates/appconfig.yaml | 31 ++--- .../helm/xapp-std/templates/deployment.yaml | 81 +++++------- .../90-xApps/helm/xapp-std/templates/service.yaml | 6 +- ric-xapps/90-xApps/helm/xapp-std/values.yaml | 66 ++++----- ric-xapps/90-xApps/scripts/localize.sh | 46 +++++++ ric-xapps/90-xApps/scripts/ric_env.sh | 24 ++++ 8 files changed, 308 insertions(+), 113 deletions(-) create mode 100755 ric-xapps/90-xApps/helm/xapp-std/config/config-file.json create mode 100755 ric-xapps/90-xApps/helm/xapp-std/descriptors/schema.json create mode 100755 ric-xapps/90-xApps/scripts/localize.sh create mode 100755 ric-xapps/90-xApps/scripts/ric_env.sh diff --git a/ric-xapps/90-xApps/helm/xapp-std/config/config-file.json b/ric-xapps/90-xApps/helm/xapp-std/config/config-file.json new file mode 100755 index 00000000..33c5f207 --- /dev/null +++ b/ric-xapps/90-xApps/helm/xapp-std/config/config-file.json @@ -0,0 +1,20 @@ +{ + "local": { + "host": ":8080" + }, + "logger": { + "level": 3 + }, + "rmr": { + "protPort": "tcp:4560", + "maxSize": 2072, + "numWorkers": 1, + "txMessages": ["RIC_X2_LOAD_INFORMATION"], + "rxMessages": ["RIC_X2_LOAD_INFORMATION"] + }, + "db": { + "namespace": "ricxapp", + "host": "dbaas", + "port": 6379 + } +} diff --git a/ric-xapps/90-xApps/helm/xapp-std/descriptors/schema.json b/ric-xapps/90-xApps/helm/xapp-std/descriptors/schema.json new file mode 100755 index 00000000..5fd3b23c --- /dev/null +++ b/ric-xapps/90-xApps/helm/xapp-std/descriptors/schema.json @@ -0,0 +1,147 @@ +{ + "definitions": {}, + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "http://example.com/root.json", + "type": "object", + "title": "The Root Schema", + "required": [ + "local", + "logger", + "rmr", + "db" + ], + "properties": { + "local": { + "$id": "#/properties/local", + "type": "object", + "title": "The Local Schema", + "required": [ + "host" + ], + "properties": { + "host": { + "$id": "#/properties/local/properties/host", + "type": "string", + "title": "The Host Schema", + "default": "", + "examples": [ + ":8080" + ], + "pattern": "^(.*)$" + } + } + }, + "logger": { + "$id": "#/properties/logger", + "type": "object", + "title": "The Logger Schema", + "required": [ + "level" + ], + "properties": { + "level": { + "$id": "#/properties/logger/properties/level", + "type": "integer", + "title": "The Level Schema", + "default": 0, + "examples": [ + 3 + ] + } + } + }, + "rmr": { + "$id": "#/properties/rmr", + "type": "object", + "title": "The Rmr Schema", + "required": [ + "protPort", + "maxSize", + "numWorkers", + "txMessages", + "rxMessages" + ], + "properties": { + "protPort": { + "$id": "#/properties/rmr/properties/protPort", + "type": "string", + "title": "The Protport Schema", + "default": "", + "examples": [ + "tcp:4560" + ], + "pattern": "^(.*)$" + }, + "maxSize": { + "$id": "#/properties/rmr/properties/maxSize", + "type": "integer", + "title": "The Maxsize Schema", + "default": 0, + "examples": [ + 2072 + ] + }, + "numWorkers": { + "$id": "#/properties/rmr/properties/numWorkers", + "type": "integer", + "title": "The Numworkers Schema", + "default": 0, + "examples": [ + 1 + ] + }, + "txMessages": { + "$id": "#/properties/rmr/properties/txMessages", + "type": "array", + "title": "The Txmessages Schema" + }, + "rxMessages": { + "$id": "#/properties/rmr/properties/rxMessages", + "type": "array", + "title": "The Rxmessages Schema" + } + } + }, + "db": { + "$id": "#/properties/db", + "type": "object", + "title": "The Db Schema", + "required": [ + "host", + "namespace", + "port" + ], + "properties": { + "host": { + "$id": "#/properties/db/properties/host", + "type": "string", + "title": "The Host Schema", + "default": "", + "examples": [ + "dbaas" + ], + "pattern": "^(.*)$" + }, + "namespace": { + "$id": "#/properties/db/properties/namespace", + "type": "string", + "title": "The Namespace Schema", + "default": "", + "examples": [ + "ricxapp" + ], + "pattern": "^(.*)$" + }, + "port": { + "$id": "#/properties/db/properties/port", + "type": "integer", + "title": "The Port Schema", + "default": 0, + "examples": [ + 6379 + ] + } + } + } + } +} \ No newline at end of file diff --git a/ric-xapps/90-xApps/helm/xapp-std/templates/appconfig.yaml b/ric-xapps/90-xApps/helm/xapp-std/templates/appconfig.yaml index ce0dc0a6..fc6e6229 100644 --- a/ric-xapps/90-xApps/helm/xapp-std/templates/appconfig.yaml +++ b/ric-xapps/90-xApps/helm/xapp-std/templates/appconfig.yaml @@ -1,25 +1,14 @@ -################################################################################ -# 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. # -################################################################################ +# +# ================================================================================== +# Copyright (c) 2019 Nokia +# ================================================================================== +# + +{{ if (eq .Values.ricapp.appconfig.override "") }} apiVersion: v1 kind: ConfigMap metadata: - name: {{ .Release.Name }}-appconfig + name: {{ if .Values.ricapp.appconfig.override }}{{ .Values.ricapp.appconfig.override }}{{ else }}{{ .Release.Name }}-appconfig{{ end }} data: - {{- with .Values.ricapp.appconfig }} - {{- toYaml . | nindent 2 }} - {{- end }} - +{{ (.Files.Glob "config/*").AsConfig | indent 2 }} +{{ end }} diff --git a/ric-xapps/90-xApps/helm/xapp-std/templates/deployment.yaml b/ric-xapps/90-xApps/helm/xapp-std/templates/deployment.yaml index 295747ba..1e82e942 100644 --- a/ric-xapps/90-xApps/helm/xapp-std/templates/deployment.yaml +++ b/ric-xapps/90-xApps/helm/xapp-std/templates/deployment.yaml @@ -1,19 +1,9 @@ -################################################################################ -# 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. # -################################################################################ +# +# ================================================================================== +# Copyright (c) 2019 Nokia +# ================================================================================== +# + apiVersion: apps/v1 kind: Deployment metadata: @@ -35,57 +25,51 @@ spec: app.kubernetes.io/name: {{ include "ricapp.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} spec: - imagePullSecrets: - - name: {{ .Release.Name }}-docker-registry-key + hostname: {{ .Values.ricapp.hostname }} containers: - name: {{ .Chart.Name }} image: "{{ .Values.global.repository }}/{{ .Values.ricapp.image.name }}:{{ .Values.ricapp.image.tag }}" imagePullPolicy: {{ .Values.global.image.pullPolicy }} - # enable the next two elements if wanting to test pod bypassing its own entrypoint - #command: ["sh"] - #args: - # - -c - # - "while sleep 2; do echo thinking; done" ports: - name: http - containerPort: 8080 + containerPort: {{ .Values.ricapp.service.port }} + protocol: TCP + - name: rmr + containerPort: {{ .Values.ricapp.service.rmrPort }} protocol: TCP volumeMounts: - name: config-volume - mountPath: {{ .Values.ricapp.appconfigpath }} - - name: secret-volume - mountPath: {{ .Values.ricapp.appsecretpath }} - envFrom: - - configMapRef: - name: {{ .Release.Name }}-appenv + mountPath: {{ .Values.ricapp.appconfig.path }} + - name: cert-volume + mountPath: {{ .Values.ricapp.cert.path }} livenessProbe: - exec: - command: - - /bin/bash - - -c - - ps -ef | grep {{ .Values.ricapp.livenessprocessname }}| grep -v "grep" - initialDelaySeconds: 120 - periodSeconds: 30 + httpGet: + path: {{ .Values.ricapp.probes.healthAliveCheckEndpoint }} + port: 8080 + initialDelaySeconds: 5 + periodSeconds: 15 readinessProbe: httpGet: - path: / - port: http + path: {{ .Values.ricapp.probes.healthReadyCheckEndpoint }} + port: 8080 + initialDelaySeconds: 5 + periodSeconds: 15 restartPolicy: Always resources: - {{- toYaml .Values.resources | nindent 12 }} + {{- toYaml .Values.ricapp.resources | nindent 12 }} securityContext: # ubuntu - runAsUser: 1000 - allowPrivilegeEscalation: false - {{- with .Values.nodeSelector }} + #runAsUser: 1000 + #allowPrivilegeEscalation: false + {{- with .Values.ricapp.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.affinity }} + {{- with .Values.ricapp.affinity }} affinity: {{- toYaml . | nindent 8 }} {{- end }} - {{- with .Values.tolerations }} + {{- with .Values.ricapp.tolerations }} tolerations: {{- toYaml . | nindent 8 }} {{- end }} @@ -93,7 +77,6 @@ spec: volumes: - name: config-volume configMap: - name: {{ .Release.Name }}-appconfig - - name: secret-volume - secret: - secretName: {{ .Release.Name }}-appsecret + name: {{ if .Values.ricapp.appconfig.override }}{{ .Values.ricapp.appconfig.override }}{{ else }}{{ .Release.Name }}-appconfig{{ end }} + - name: cert-volume + emptyDir: {} diff --git a/ric-xapps/90-xApps/helm/xapp-std/templates/service.yaml b/ric-xapps/90-xApps/helm/xapp-std/templates/service.yaml index a76c9749..5e8c15fb 100644 --- a/ric-xapps/90-xApps/helm/xapp-std/templates/service.yaml +++ b/ric-xapps/90-xApps/helm/xapp-std/templates/service.yaml @@ -15,11 +15,11 @@ # limitations under the License. # ################################################################################ -{{- if .Values.ricapp.enabled }} +{{ if .Values.ricapp.service.enabled }} apiVersion: v1 kind: Service metadata: - name: {{ include "ricapp.fullname" . }} + name: {{ include "ricapp.name" . }} labels: app.kubernetes.io/name: {{ include "ricapp.name" . }} helm.sh/chart: {{ include "ricapp.chart" . }} @@ -35,4 +35,4 @@ spec: selector: app.kubernetes.io/name: {{ include "ricapp.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} -{{ end }} +{{ end }} \ No newline at end of file diff --git a/ric-xapps/90-xApps/helm/xapp-std/values.yaml b/ric-xapps/90-xApps/helm/xapp-std/values.yaml index 59541947..4d95ef1a 100644 --- a/ric-xapps/90-xApps/helm/xapp-std/values.yaml +++ b/ric-xapps/90-xApps/helm/xapp-std/values.yaml @@ -19,67 +19,53 @@ global: # modify this section to point to your local testing settings - repository: "snapshot.docker.ranco-dev-tools.eastus.cloudapp.azure.com:10001" + repository: "${__RUNRICENV_DOCKER_HOST__}:${__RUNRICENV_DOCKER_PORT__}" repositoryCred: - user: docker - password: docker + user: "${__RUNRICENV_DOCKER_USER__}" + password: "${__RUNRICENV_DOCKER_PASS__}" image: pullPolicy: IfNotPresent ricplt: # This section is reserved for values imported from RIC Platform charts - ricapp: - # This section is for xapp. Templates to be resolved from xApp descriptor + # This section is for xapp. Templates to be resolved from xApp descriptor replicaCount: 1 - xappname: &anchor-xappname xapp-std + name: xapp-std + fullname: xapp-std + nameOverride: "" + fullnameOverride: "" - # the name of the process that indicates the liveness of the component - liveness-process-name: xapp-std + # The name of the process that indicates the liveness of the component + livenessprocessname: xapp-std image: - name: whoami - tag: 0.0.1 - - nameOverride: "" - fullnameOverride: "" + name: xapp-std + tag: latest service: - enabled: false + enabled: true + type: ClusterIP + name: xapp-std-service + port: 8080 + rmrPort: 4560 + probes: + healthAliveCheckEndpoint: ric/v1/health/alive + healthReadyCheckEndpoint: ric/v1/health/ready - # to be provided as property file - appconfigpath: /opt/etc/xapp appconfig: - # to be present as file propfile1 under appconfigpath - propfile1: | - prop1.v1="propvalue1.1" - prop1.v2="propvalue1.2" - # to be present as file propfile2 under appconfigpath - propfile2: "prop2" + path: /opt/ric/config + override: "" - # to be provided as env variables - appenv: - NAME: *anchor-xappname - ENV1: "envvalue1" - ENV2: "envvalue2" + cert: + path: /opt/ric/certificates + object: {} - # secret - appsecretpath: /opt/etc/kube - appsecret: - # to be present as files under path appsecretpath - username: myusername - password: mypassword - + hostname: xapp-std resources: {} - # limits: - # cpu: 100m - # memory: 128Mi - # requests: - # cpu: 100m - # memory: 128Mi nodeSelector: {} diff --git a/ric-xapps/90-xApps/scripts/localize.sh b/ric-xapps/90-xApps/scripts/localize.sh new file mode 100755 index 00000000..90f90384 --- /dev/null +++ b/ric-xapps/90-xApps/scripts/localize.sh @@ -0,0 +1,46 @@ +#!/bin/bash +################################################################################ +# 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. # +################################################################################ + +if (( $# != 1 )); then + echo "Missing parameters: " + exit +fi + +source ./scripts/ric_env.sh +if [ -z $__RICENV_SET__ ]; then + echo "Edit your ric_env.sh for first!" + exit +fi + +# Update the local values +RESULT_DIR=./generated +rm -rf $RESULT_DIR && mkdir -p $RESULT_DIR && cp -rf ./helm $RESULT_DIR + +FILELIST=$(find ./helm \( -name "*.tpl" -o -name "*.yaml" \)) +for f in $FILELIST; do + envsubst '${__RUNRICENV_DOCKER_HOST__} ${__RUNRICENV_DOCKER_PORT__}' < $f > "$RESULT_DIR/$f"; +done + +# Rename the helm chart folder +mv $RESULT_DIR/helm/xapp-std $RESULT_DIR/helm/$1 +find $RESULT_DIR/helm/$1 -type f | xargs sed -i -e "s/xapp-std/$1/g" + +# Push to helm chart repo +helm package generated/helm/$1 | awk '{ print $NF }' | xargs mv -t $__RUNRICENV_HELMREPO_DIR__ +helm repo index $__RUNRICENV_HELMREPO_DIR__ +helm repo update diff --git a/ric-xapps/90-xApps/scripts/ric_env.sh b/ric-xapps/90-xApps/scripts/ric_env.sh new file mode 100755 index 00000000..ea960c19 --- /dev/null +++ b/ric-xapps/90-xApps/scripts/ric_env.sh @@ -0,0 +1,24 @@ +#!/bin/bash +################################################################################ +# 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. # +################################################################################ + + +# customize the following repo info to local environment +export __RICENV_SET__='true' +export __RUNRICENV_DOCKER_HOST__='192.168.0.6' +export __RUNRICENV_DOCKER_PORT__='5000' +export __RUNRICENV_HELMREPO_DIR__='/var/www/html/charts/' \ No newline at end of file -- 2.16.6