From ffb2596ed79a32128f45f6e5a12eb8d5904c420e Mon Sep 17 00:00:00 2001 From: ktimoney Date: Fri, 1 Jul 2022 14:00:57 +0100 Subject: [PATCH] Add helm chart for script version use case Issue-ID: NONRTRIC-749 Signed-off-by: ktimoney Change-Id: Id087c6c0cbac27d76cc457dbf1d114941933d4d1 --- .../scriptversion/helm/healthcheck/.helmignore | 23 +++++++ .../scriptversion/helm/healthcheck/Chart.yaml | 39 +++++++++++ .../helm/healthcheck/templates/_helpers.tpl | 79 ++++++++++++++++++++++ .../helm/healthcheck/templates/deployment.yaml | 74 ++++++++++++++++++++ .../helm/healthcheck/templates/service.yaml | 30 ++++++++ .../scriptversion/helm/healthcheck/values.yaml | 78 +++++++++++++++++++++ 6 files changed, 323 insertions(+) create mode 100644 test/usecases/healthcheck/scriptversion/helm/healthcheck/.helmignore create mode 100644 test/usecases/healthcheck/scriptversion/helm/healthcheck/Chart.yaml create mode 100644 test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/_helpers.tpl create mode 100644 test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/deployment.yaml create mode 100644 test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/service.yaml create mode 100644 test/usecases/healthcheck/scriptversion/helm/healthcheck/values.yaml diff --git a/test/usecases/healthcheck/scriptversion/helm/healthcheck/.helmignore b/test/usecases/healthcheck/scriptversion/helm/healthcheck/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/test/usecases/healthcheck/scriptversion/helm/healthcheck/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/test/usecases/healthcheck/scriptversion/helm/healthcheck/Chart.yaml b/test/usecases/healthcheck/scriptversion/helm/healthcheck/Chart.yaml new file mode 100644 index 0000000..254c44c --- /dev/null +++ b/test/usecases/healthcheck/scriptversion/helm/healthcheck/Chart.yaml @@ -0,0 +1,39 @@ +# Copyright (C) 2021 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= + +apiVersion: v2 +name: healthcheck +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/_helpers.tpl b/test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/_helpers.tpl new file mode 100644 index 0000000..5b07866 --- /dev/null +++ b/test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/_helpers.tpl @@ -0,0 +1,79 @@ +{{/* +# Copyright (C) 2021 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= +*/}} + +{{/* +Expand the name of the chart. +*/}} +{{- define "healthcheck.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 "healthcheck.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 "healthcheck.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "healthcheck.labels" -}} +helm.sh/chart: {{ include "healthcheck.chart" . }} +{{ include "healthcheck.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "healthcheck.selectorLabels" -}} +app.kubernetes.io/name: {{ include "healthcheck.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "healthcheck.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "healthcheck.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/deployment.yaml b/test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/deployment.yaml new file mode 100644 index 0000000..e98b6e5 --- /dev/null +++ b/test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/deployment.yaml @@ -0,0 +1,74 @@ +# Copyright (C) 2021 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "healthcheck.fullname" . }} + labels: + {{- include "healthcheck.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "healthcheck.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "healthcheck.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: PMS_HOST + value: {{ .Values.policymanagementservice.pmsHost }} + - name: POLICY_BODY_PATH + value: {{ .Values.policymanagementservice.policyBodyPath | toJson | quote }} + command: [ "python3", "main.py" ] + args: [ + "--pmsHost", "$(PMS_HOST)" + ] + ports: + - name: http + containerPort: 80 + protocol: TCP + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/service.yaml b/test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/service.yaml new file mode 100644 index 0000000..90212ac --- /dev/null +++ b/test/usecases/healthcheck/scriptversion/helm/healthcheck/templates/service.yaml @@ -0,0 +1,30 @@ +# Copyright (C) 2021 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= + +apiVersion: v1 +kind: Service +metadata: + name: {{ include "healthcheck.fullname" . }} + labels: + {{- include "healthcheck.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + selector: + {{- include "healthcheck.selectorLabels" . | nindent 4 }} diff --git a/test/usecases/healthcheck/scriptversion/helm/healthcheck/values.yaml b/test/usecases/healthcheck/scriptversion/helm/healthcheck/values.yaml new file mode 100644 index 0000000..a138802 --- /dev/null +++ b/test/usecases/healthcheck/scriptversion/helm/healthcheck/values.yaml @@ -0,0 +1,78 @@ +# Copyright (C) 2021 Nordix Foundation. All rights reserved. +# ======================================================================== +# 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. +# ============LICENSE_END================================================= + +# Default values for healthcheck. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: nexus3.o-ran-sc.org:10004/o-ran-sc/nonrtric-rapp-healthcheck + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "1.0.0" + +policymanagementservice: + pmsHost: "http://a1policymanagement.onap:8081" + policyBodyPath: + { + "scope": { + "ueId": "XXX", + "qosId": "XXX" + }, + "qosObjectives": { + "priorityLevel": 622.75 + } + } + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {} -- 2.16.6