From b3224eb09c12148efea60ed3ad190907a2615484 Mon Sep 17 00:00:00 2001 From: Omar Abdelkader Date: Tue, 6 Jul 2021 11:42:45 -0700 Subject: [PATCH] Add fb-kpimon-xapp helm charts --- fb-kpimon-xapp/Chart.yaml | 20 +++++ fb-kpimon-xapp/files/certs/README.md | 20 +++++ fb-kpimon-xapp/files/certs/tls.cacrt | 21 ++++++ fb-kpimon-xapp/files/certs/tls.crt | 21 ++++++ fb-kpimon-xapp/files/certs/tls.key | 28 +++++++ fb-kpimon-xapp/files/configs/config.json | 6 ++ fb-kpimon-xapp/templates/_helpers.tpl | 52 +++++++++++++ fb-kpimon-xapp/templates/configmap.yaml | 16 ++++ fb-kpimon-xapp/templates/deployment.yaml | 95 ++++++++++++++++++++++++ fb-kpimon-xapp/templates/secret.yaml | 18 +++++ fb-kpimon-xapp/templates/service.yaml | 26 +++++++ fb-kpimon-xapp/values.yaml | 43 +++++++++++ 12 files changed, 366 insertions(+) create mode 100644 fb-kpimon-xapp/Chart.yaml create mode 100644 fb-kpimon-xapp/files/certs/README.md create mode 100644 fb-kpimon-xapp/files/certs/tls.cacrt create mode 100644 fb-kpimon-xapp/files/certs/tls.crt create mode 100644 fb-kpimon-xapp/files/certs/tls.key create mode 100644 fb-kpimon-xapp/files/configs/config.json create mode 100644 fb-kpimon-xapp/templates/_helpers.tpl create mode 100644 fb-kpimon-xapp/templates/configmap.yaml create mode 100644 fb-kpimon-xapp/templates/deployment.yaml create mode 100644 fb-kpimon-xapp/templates/secret.yaml create mode 100644 fb-kpimon-xapp/templates/service.yaml create mode 100644 fb-kpimon-xapp/values.yaml diff --git a/fb-kpimon-xapp/Chart.yaml b/fb-kpimon-xapp/Chart.yaml new file mode 100644 index 00000000..828f8087 --- /dev/null +++ b/fb-kpimon-xapp/Chart.yaml @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2020-present Open Networking Foundation +# +# SPDX-License-Identifier: LicenseRef-ONF-Member-1.0 + +apiVersion: v2 +name: fb-kpimon-xapp +description: FB kpimon python xApp +kubeVersion: ">=1.17.0" +type: application +version: 0.0.1 +appVersion: 0.0.1 +keywords: + - onos + - sdn + - ric + - fb +home: https://connectivity.fb.com/ +maintainers: + - name: Maveric Team + email: fbc_maveric@fb.com diff --git a/fb-kpimon-xapp/files/certs/README.md b/fb-kpimon-xapp/files/certs/README.md new file mode 100644 index 00000000..51abfd54 --- /dev/null +++ b/fb-kpimon-xapp/files/certs/README.md @@ -0,0 +1,20 @@ +This folder contains self-signed certificates for use in testing. _DO NOT USE THESE +CERTIFICATES IN PRODUCTION!_ + +The certificates were generated with the +https://github.com/onosproject/simulators/blob/master/pkg/certs/generate_certs.sh +script as +```bash +generate-certs.sh onos-ric.opennetworking.org +``` + +In this folder they **must** be (re)named +* tls.cacrt +* tls.crt +* tls.key + +Use +```bash +openssl x509 -in deployments/helm/onos-ric/files/certs/tls.crt -text -noout +``` +to verify the contents (especially the subject). diff --git a/fb-kpimon-xapp/files/certs/tls.cacrt b/fb-kpimon-xapp/files/certs/tls.cacrt new file mode 100644 index 00000000..d4440bdf --- /dev/null +++ b/fb-kpimon-xapp/files/certs/tls.cacrt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDYDCCAkgCCQDe99fSN9qxSTANBgkqhkiG9w0BAQsFADByMQswCQYDVQQGEwJV +UzELMAkGA1UECAwCQ0ExEjAQBgNVBAcMCU1lbmxvUGFyazEMMAoGA1UECgwDT05G +MRQwEgYDVQQLDAtFbmdpbmVlcmluZzEeMBwGA1UEAwwVY2Eub3Blbm5ldHdvcmtp +bmcub3JnMB4XDTE5MDQxMTA5MDYxM1oXDTI5MDQwODA5MDYxM1owcjELMAkGA1UE +BhMCVVMxCzAJBgNVBAgMAkNBMRIwEAYDVQQHDAlNZW5sb1BhcmsxDDAKBgNVBAoM +A09ORjEUMBIGA1UECwwLRW5naW5lZXJpbmcxHjAcBgNVBAMMFWNhLm9wZW5uZXR3 +b3JraW5nLm9yZzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMEg7CZR +X8Y+syKHaQCh6mNIL1D065trwX8RnuKM2kBwSu034zefQAPloWugSoJgJnf5fe0j +nUD8gN3Sm8XRhCkvf67pzfabgw4n8eJmHScyL/ugyExB6Kahwzn37bt3oT3gSqhr +6PUznWJ8fvfVuCHZZkv/HPRp4eyAcGzbJ4TuB0go4s6VE0WU5OCxCSlAiK3lvpVr +3DOLdYLVoCa5q8Ctl3wXDrfTLw5/Bpfrg9fF9ED2/YKIdV8KZ2ki/gwEOQqWcKp8 +0LkTlfOWsdGjp4opPuPT7njMBGXMJzJ8/J1e1aJvIsoB7n8XrfvkNiWL5U3fM4N7 +UZN9jfcl7ULmm7cCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEAIh6FjkQuTfXddmZY +FYpoTen/VD5iu2Xxc1TexwmKeH+YtaKp1Zk8PTgbCtMEwEiyslfeHTMtODfnpUIk +DwvtB4W0PAnreRsqh9MBzdU6YZmzGyZ92vSUB3yukkHaYzyjeKM0AwgVl9yRNEZw +Y/OM070hJXXzJh3eJpLl9dlUbMKzaoAh2bZx6y3ZJIZFs/zrpGfg4lvBAvfO/59i +mxJ9bQBSN3U2Hwp6ioOQzP0LpllfXtx9N5LanWpB0cu/HN9vAgtp3kRTBZD0M1XI +Ctit8bXV7Mz+1iGqoyUhfCYcCSjuWTgAxzir+hrdn7uO67Hv4ndCoSj4SQaGka3W +eEfVeA== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/fb-kpimon-xapp/files/certs/tls.crt b/fb-kpimon-xapp/files/certs/tls.crt new file mode 100644 index 00000000..82f38922 --- /dev/null +++ b/fb-kpimon-xapp/files/certs/tls.crt @@ -0,0 +1,21 @@ +-----BEGIN CERTIFICATE----- +MIIDdDCCAlwCFBveh0tyYQtXayQPaXgW+5dLuK8DMA0GCSqGSIb3DQEBCwUAMHIx +CzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTESMBAGA1UEBwwJTWVubG9QYXJrMQww +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IRjj +-----END CERTIFICATE----- diff --git a/fb-kpimon-xapp/files/certs/tls.key b/fb-kpimon-xapp/files/certs/tls.key new file mode 100644 index 00000000..55af346c --- /dev/null +++ b/fb-kpimon-xapp/files/certs/tls.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCzURH8Ub0I7Bif +IM7HE8gYlvyn2Xn0Yuph2dvc8fkQjrIB+GkkOGn5n9E3y/782Efok9iq4/FEpaYe +FFebAQeBhER+Sor4eKRO/zoflOr9fPMGpp0eSikzP5DrpajgugPcz5WX/XWBRT2z +tIhYGZwmXL0RNA3md114Zr6/4yD1ChJb/wIrtjWIKC67eHYViO745Dscn2E7lpuz +deK4kkk32E8lGvU7VS2BTOVVuPZAtxMEOe0jE8pRzf8zkinOAu3a+Adb1Uw7m8U5 +eyv5TJB3+UHJVdPFApLlrDSTAxQlJ029qxXcUDPi6w/0gHHk+rczAxAXW47nMnxe +jbK2WwjTAgMBAAECggEBALE57iHIk6Hu3wLfhR9DUN/k0r/+dMdywB6IGQKNcVHJ +BuxlnV08GJmsODcCevlhteiLv3hfI4Vqhv1xs4gygz2iAaQkfqfHbPXa0ZKHN53j +0bqAEAfw2jmZmN0edQPvNYQW8s4upuVmDu6+/oa8gRV1UTRgk2B2Fz65pcu3a0pi +yVeZzeAO/vD7WNP3uM7Yuv0AQTKKLvOqZmKLeDwPeC+2sbi03opYbIaEl+OJ94DX +9hCm1/vqojlzw+BHrxGS8bqXMnJnqxLep/gmbvL0Iy92SJgEBk6l8t7xzpBqSjDW ++DjDLqpda6r/Dy9b5hBZ0a/4V+fRJPz4S/k+qjp9DyECgYEA7KMQur7QZcSAWPPM +ZV5TM6+SDYn6TP9csbyB4IbOfeLdIkVKY+svVz2m7FynfQb4whtxERbMy0QjYEgc +us3p/QVjHBs/JZIdtIg5ff6qgOFAkuaCXEJKyH4wcEA091cr6HWslWCHzop2SD+T +dpvSgXJXpx1RYP/6X3sUf1mKAOMCgYEAwf1K4fOYZwyT44VPurxhmzgDWW2PKm6I +gCOZN9EN2Mvt0J5zKKoHw8ORHGN9zxLMyB11803Uwm7nceApM3FUacmLHP05Q1Vo +ukHVLoFQYwXLQzSWiZbtxcbMK3P1EU2Sg5+yfoRf6usmRIWDlr4+TIzT3a20nhV0 +olOj3xFtC1ECgYBHyeiHXuAGH6j4U24MyqLfKUJbzSIcPdQ3L4MPRJZcZnjDrtW0 +nmLMSq3bQvik23qYGI8iqhITEGbTDM16doGn+vxoSHPNyBgu7qzSZnH/i1Z1umyN +5KafUHkNdM0cxFtTuG9VGeXZaPQdUvw/nWItVyz0S9amYMHqOYKsZ9OQFQKBgQC6 +tfYq//CBzqNQ63DPxJ0VbpYars6LApQy8RB5nqb7MVyV3MvuKakLjOHQNxpSAkBD +o8dxBEpxUZlGC4DcWInsv+U7Y6aH3l7MVqy+9AvRIzR+XNE/YJs+Lpc4g4UuwEDy +mvSLvREs5GOStAbxQe5oc2tAA/7B4Ni/nE0vWHBh4QKBgDUukLjK4i+AqCm6Z4iu +/FcKtNC2+BLxZ2sjaRVn78aQ2DXWaKWVaKwSBJOtLghOyjAzvH8VDOtvp92rQgDk +ltnoTp09B9B80dNOVqIi113Inr89N/QDNVYctqPbzizbWHlf3ENwVklwAXhmOIbN +1l0Cge8ERKGcAIl9SsTl+5Se +-----END PRIVATE KEY----- diff --git a/fb-kpimon-xapp/files/configs/config.json b/fb-kpimon-xapp/files/configs/config.json new file mode 100644 index 00000000..32f25070 --- /dev/null +++ b/fb-kpimon-xapp/files/configs/config.json @@ -0,0 +1,6 @@ +{ + "report_period": { + "interval": 1000, + "granularity": 1000 + } +} diff --git a/fb-kpimon-xapp/templates/_helpers.tpl b/fb-kpimon-xapp/templates/_helpers.tpl new file mode 100644 index 00000000..4cd3bb85 --- /dev/null +++ b/fb-kpimon-xapp/templates/_helpers.tpl @@ -0,0 +1,52 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "fb-kpimon-xapp.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 "fb-kpimon-xapp.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 "fb-kpimon-xapp.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "fb-kpimon-xapp.labels" -}} +helm.sh/chart: {{ include "fb-kpimon-xapp.chart" . }} +{{ include "fb-kpimon-xapp.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "fb-kpimon-xapp.selectorLabels" -}} +app.kubernetes.io/name: {{ include "fb-kpimon-xapp.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} diff --git a/fb-kpimon-xapp/templates/configmap.yaml b/fb-kpimon-xapp/templates/configmap.yaml new file mode 100644 index 00000000..e712a2df --- /dev/null +++ b/fb-kpimon-xapp/templates/configmap.yaml @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2020-present Open Networking Foundation +# +# SPDX-License-Identifier: LicenseRef-ONF-Member-1.0 + +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ template "fb-kpimon-xapp.fullname" . }}-config + labels: + app: {{ template "fb-kpimon-xapp.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +data: + config.json: |- +{{ .Files.Get "files/configs/config.json" | indent 4}} diff --git a/fb-kpimon-xapp/templates/deployment.yaml b/fb-kpimon-xapp/templates/deployment.yaml new file mode 100644 index 00000000..dfd9b4ba --- /dev/null +++ b/fb-kpimon-xapp/templates/deployment.yaml @@ -0,0 +1,95 @@ +# SPDX-FileCopyrightText: 2020-present Open Networking Foundation +# +# SPDX-License-Identifier: LicenseRef-ONF-Member-1.0 + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "fb-kpimon-xapp.fullname" . }} + labels: + {{- include "fb-kpimon-xapp.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + name: {{ template "fb-kpimon-xapp.fullname" . }} + app: facebook + type: kpimon + resource: {{ template "fb-kpimon-xapp.fullname" . }} + {{- include "fb-kpimon-xapp.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + name: {{ template "fb-kpimon-xapp.fullname" . }} + app: facebook + type: kpimon + resource: {{ template "fb-kpimon-xapp.fullname" . }} + {{- include "fb-kpimon-xapp.selectorLabels" . | nindent 8 }} + spec: + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "kpimon/main.py" + - "--ca-path=/etc/onos/certs/tls.cacrt" + - "--key-path=/etc/onos/certs/tls.key" + - "--cert-path=/etc/onos/certs/tls.crt" + - "--e2t-endpoint={{ .Values.config.ric.e2tEndpoint }}" + - "--path={{ .Values.config.servicePath }}" + - "--topo-endpoint={{ .Values.config.ric.topoEndpoint }}" + ports: + - name: http + containerPort: 8080 + startupProbe: + httpGet: + path: /status + port: 8080 + periodSeconds: 5 + failureThreshold: 60 + readinessProbe: + httpGet: + path: /status + port: 8080 + initialDelaySeconds: 10 + periodSeconds: 10 + livenessProbe: + httpGet: + path: /status + port: 8080 + initialDelaySeconds: 10 + periodSeconds: 10 + volumeMounts: + - name: secret + mountPath: /etc/onos/certs + readOnly: true + - name: config + mountPath: {{ .Values.config.servicePath }} + readOnly: false + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumes: + - name: secret + secret: + secretName: {{ template "fb-kpimon-xapp.fullname" . }}-secret + - name: config + configMap: + name: {{ template "fb-kpimon-xapp.fullname" . }}-config + {{- 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/fb-kpimon-xapp/templates/secret.yaml b/fb-kpimon-xapp/templates/secret.yaml new file mode 100644 index 00000000..024bac8e --- /dev/null +++ b/fb-kpimon-xapp/templates/secret.yaml @@ -0,0 +1,18 @@ +# SPDX-FileCopyrightText: 2020-present Open Networking Foundation +# +# SPDX-License-Identifier: LicenseRef-ONF-Member-1.0 + +apiVersion: v1 +kind: Secret +metadata: + name: {{ template "fb-kpimon-xapp.fullname" . }}-secret + labels: + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" +data: + {{ $root := . }} + {{ range $path, $bytes := .Files.Glob "files/certs/tls.*" }} + {{ base $path }}: '{{ $root.Files.Get $path | b64enc }}' + {{ end }} +type: Opaque diff --git a/fb-kpimon-xapp/templates/service.yaml b/fb-kpimon-xapp/templates/service.yaml new file mode 100644 index 00000000..62b84944 --- /dev/null +++ b/fb-kpimon-xapp/templates/service.yaml @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2020-present Open Networking Foundation +# +# SPDX-License-Identifier: LicenseRef-ONF-Member-1.0 + +--- +apiVersion: v1 +kind: Service +metadata: + name: {{ template "fb-kpimon-xapp.fullname" . }} + labels: + app: {{ template "fb-kpimon-xapp.fullname" . }} + chart: "{{ .Chart.Name }}-{{ .Chart.Version }}" + release: "{{ .Release.Name }}" + heritage: "{{ .Release.Service }}" + {{- include "fb-kpimon-xapp.labels" . | nindent 4 }} +spec: + type: ClusterIP + selector: + name: {{ template "fb-kpimon-xapp.fullname" . }} + app: facebook + type: kpimon + resource: {{ template "fb-kpimon-xapp.fullname" . }} + {{- include "fb-kpimon-xapp.selectorLabels" . | nindent 4 }} + ports: + - name: http + port: 8080 diff --git a/fb-kpimon-xapp/values.yaml b/fb-kpimon-xapp/values.yaml new file mode 100644 index 00000000..fe3cb575 --- /dev/null +++ b/fb-kpimon-xapp/values.yaml @@ -0,0 +1,43 @@ +# SPDX-FileCopyrightText: 2020-present Open Networking Foundation +# +# SPDX-License-Identifier: LicenseRef-ONF-Member-1.0 + +# Default values for fb-kpimon-xapp. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: onosproject/fb-kpimon-xapp + tag: 0.0.1 + pullPolicy: IfNotPresent + pullSecrets: [] + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "fb-kpimon-xapp" + +config: + servicePath: "/etc/onos/config" + ric: + e2tEndpoint: "onos-e2t:5150" + topoEndpoint: "onos-topo:5150" + +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: {}