From 37cae2542ba41720da3179f5955401fc0ed66184 Mon Sep 17 00:00:00 2001 From: Mike Elliott Date: Wed, 12 Sep 2018 14:45:40 -0400 Subject: Add controller blueprints This is a common Helm Chart for deploying the new Controller Blurprints miscroservice as part of the CDS work being done to enable self service. Change-Id: I435fb4d2b269e230c3149fb39b3632d3eac93878 Issue-ID: CCSDK-523 Signed-off-by: Mike Elliott --- .../common/controller-blueprints/.helmignore | 21 ++++ kubernetes/common/controller-blueprints/Chart.yaml | 18 +++ .../common/controller-blueprints/requirements.yaml | 21 ++++ .../resources/config/application.properties | 59 ++++++++++ .../resources/config/logback.xml | 43 +++++++ .../controller-blueprints/templates/configmap.yaml | 22 ++++ .../templates/deployment.yaml | 124 +++++++++++++++++++++ .../controller-blueprints/templates/secrets.yaml | 27 +++++ .../controller-blueprints/templates/service.yaml | 52 +++++++++ .../common/controller-blueprints/values.yaml | 120 ++++++++++++++++++++ 10 files changed, 507 insertions(+) create mode 100644 kubernetes/common/controller-blueprints/.helmignore create mode 100644 kubernetes/common/controller-blueprints/Chart.yaml create mode 100644 kubernetes/common/controller-blueprints/requirements.yaml create mode 100644 kubernetes/common/controller-blueprints/resources/config/application.properties create mode 100644 kubernetes/common/controller-blueprints/resources/config/logback.xml create mode 100644 kubernetes/common/controller-blueprints/templates/configmap.yaml create mode 100644 kubernetes/common/controller-blueprints/templates/deployment.yaml create mode 100644 kubernetes/common/controller-blueprints/templates/secrets.yaml create mode 100644 kubernetes/common/controller-blueprints/templates/service.yaml create mode 100644 kubernetes/common/controller-blueprints/values.yaml (limited to 'kubernetes') diff --git a/kubernetes/common/controller-blueprints/.helmignore b/kubernetes/common/controller-blueprints/.helmignore new file mode 100644 index 0000000000..f0c1319444 --- /dev/null +++ b/kubernetes/common/controller-blueprints/.helmignore @@ -0,0 +1,21 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj diff --git a/kubernetes/common/controller-blueprints/Chart.yaml b/kubernetes/common/controller-blueprints/Chart.yaml new file mode 100644 index 0000000000..28c22a37f5 --- /dev/null +++ b/kubernetes/common/controller-blueprints/Chart.yaml @@ -0,0 +1,18 @@ +# Copyright (c) 2018 Amdocs, Bell Canada +# +# 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. + +apiVersion: v1 +description: Controller Blueprints Micro Service +name: controller-blueprints +version: 3.0.0 \ No newline at end of file diff --git a/kubernetes/common/controller-blueprints/requirements.yaml b/kubernetes/common/controller-blueprints/requirements.yaml new file mode 100644 index 0000000000..b9ecec7a02 --- /dev/null +++ b/kubernetes/common/controller-blueprints/requirements.yaml @@ -0,0 +1,21 @@ +# Copyright (c) 2018 Amdocs, Bell Canada +# +# 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. + +dependencies: + - name: mariadb-galera + version: ~2.0.0 + repository: file://../mariadb-galera/ + - name: common + version: ~2.0.0 + repository: '@local' \ No newline at end of file diff --git a/kubernetes/common/controller-blueprints/resources/config/application.properties b/kubernetes/common/controller-blueprints/resources/config/application.properties new file mode 100644 index 0000000000..ec3a1ffce7 --- /dev/null +++ b/kubernetes/common/controller-blueprints/resources/config/application.properties @@ -0,0 +1,59 @@ +# +# Copyright (c) 2017-2018 AT&T Intellectual Property. +# Modifications Copyright (c) 2018 IBM. +# +# 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. +# +appName=ControllerBluePrints +ms_name=org.onap.ccsdk.apps.controllerblueprints +appVersion=1.0.0 + +#logging.pattern.console=%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(%5p) %clr($ threadId: {PID:- }){magenta} %clr(---){faint} %clr([ hostname: %X{hostname} serviceName: %X{serviceName} version: %X{version} transactionId: %X{transactionId} requestTimeStamp: %X{requestTimestamp} responseTimeStamp: %X{responseTimestamp} duration: %X{duration}]){yellow} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n%wex + +logging.level.org.springframework.web=INFO +logging.level.org.hibernate.SQL=warn +logging.level.org.hibernate.type.descriptor.sql=debug + +#To Remove Null in JSON API Response +spring.jackson.default-property-inclusion=non_null + +#Swagger Configuration +swagger.contact.name=Brinda Santh Muthuramalingam +swagger.contact.url=www.onap.com +swagger.contact.email=brindasanth@onap.com + +spring.jpa.properties.hibernate.show_sql=true +spring.jpa.properties.hibernate.use_sql_comments=true +spring.jpa.properties.hibernate.format_sql=true + +# spring.datasource.url, spring.datasource.username,spring.datasource.password may be overridden by ENV variables +spring.datasource.url=jdbc:mysql://controller-blueprints-db:3306/sdnctl +spring.datasource.username=sdnctl +spring.datasource.password=sdnctl +spring.datasource.driver-class-name=org.mariadb.jdbc.Driver +spring.jpa.show-sql = true +spring.jpa.hibernate.ddl-auto = none +spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy +spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect + +#Load Blueprints +# blueprints.load.initial-data may be overridden by ENV variables +blueprints.load.initial-data=true +load.dataTypePath=load/model_type/data_type +load.nodeTypePath=load/model_type/node_type +load.artifactTypePath=load/model_type/artifact_type +load.resourceDictionaryPath=load/resource_dictionary +load.blueprintsPath=load/blueprints + +# Load Resource Source Mappings +resourceSourceMappings=db=source-db,input=source-input,default=source-default,mdsal=source-rest diff --git a/kubernetes/common/controller-blueprints/resources/config/logback.xml b/kubernetes/common/controller-blueprints/resources/config/logback.xml new file mode 100644 index 0000000000..9129fcf150 --- /dev/null +++ b/kubernetes/common/controller-blueprints/resources/config/logback.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + ${defaultPattern} + + + + + + + + + + + + + + \ No newline at end of file diff --git a/kubernetes/common/controller-blueprints/templates/configmap.yaml b/kubernetes/common/controller-blueprints/templates/configmap.yaml new file mode 100644 index 0000000000..1f194b6984 --- /dev/null +++ b/kubernetes/common/controller-blueprints/templates/configmap.yaml @@ -0,0 +1,22 @@ +# Copyright (c) 2018 Amdocs, Bell Canada +# Modifications Copyright © 2018 AT&T, ZTE +# +# 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. + +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "common.fullname" . }}-configmap + namespace: {{ include "common.namespace" . }} +data: +{{ tpl (.Files.Glob "resources/config/*").AsConfig . | indent 2 }} diff --git a/kubernetes/common/controller-blueprints/templates/deployment.yaml b/kubernetes/common/controller-blueprints/templates/deployment.yaml new file mode 100644 index 0000000000..fc7329cf9f --- /dev/null +++ b/kubernetes/common/controller-blueprints/templates/deployment.yaml @@ -0,0 +1,124 @@ +# Copyright (c) 2018 Amdocs, Bell Canada +# +# 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. + +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: {{ include "common.fullname" . }} + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + template: + metadata: + labels: + app: {{ include "common.name" . }} + release: {{ .Release.Name }} + spec: + initContainers: + - command: + - /root/ready.py + args: + - --container-name + - {{ index .Values "mariadb-galera" "nameOverride" }} + env: + - name: NAMESPACE + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.namespace + image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}" + imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} + name: {{ include "common.name" . }}-readiness + containers: + - name: {{ include "common.name" . }} + image: "{{ include "common.repository" . }}/{{ .Values.image }}" + imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }} + ports: + - containerPort: {{ .Values.service.internalPort }} + # disable liveness probe when breakpoints set in debugger + # so K8s doesn't restart unresponsive container + {{ if .Values.liveness.enabled }} + livenessProbe: + tcpSocket: + port: {{ .Values.service.internalPort }} + initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }} + periodSeconds: {{ .Values.liveness.periodSeconds }} + {{ end }} + readinessProbe: + tcpSocket: + port: {{ .Values.service.internalPort }} + initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }} + periodSeconds: {{ .Values.readiness.periodSeconds }} + env: + - name: APPLICATIONNAME + value: {{ .Values.config.applicationName }} + - name: BUNDLEVERSION + value: {{ .Values.config.bundleVersion }} + - name: APP_CONFIG_HOME + value: {{ .Values.config.appConfigDir }} + - name: DB_URL + value: {{ .Values.config.dbUrl }} + - name: DB_USER + value: {{ index .Values "mariadb-galera" "config" "userName" }} + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ template "common.fullname" . }} + key: db-root-password + - name: INIT_DATA_LOAD + value: {{ .Values.config.initDataLoad | quote }} + - name: STICKYSELECTORKEY + value: {{ .Values.config.stickySelectorKey | quote }} + - name: ENVCONTEXT + value: {{ .Values.config.envContext }} + volumeMounts: + - mountPath: /etc/localtime + name: localtime + readOnly: true + - mountPath: {{ .Values.config.appConfigDir }}/application.properties + name: {{ include "common.fullname" . }}-config + subPath: application.properties + - mountPath: {{ .Values.config.appConfigDir }}/logback.xml + name: {{ include "common.fullname" . }}-config + subPath: logback.xml + resources: +{{ toYaml .Values.resources | indent 12 }} + {{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 10 }} + {{- end -}} + {{- if .Values.affinity }} + affinity: +{{ toYaml .Values.affinity | indent 10 }} + {{- end }} + + volumes: + - name: localtime + hostPath: + path: /etc/localtime + - name: {{ include "common.fullname" . }}-config + configMap: + name: {{ include "common.fullname" . }}-configmap + items: + - key: application.properties + path: application.properties + - key: logback.xml + path: logback.xml + imagePullSecrets: + - name: "{{ include "common.namespace" . }}-docker-registry-key" diff --git a/kubernetes/common/controller-blueprints/templates/secrets.yaml b/kubernetes/common/controller-blueprints/templates/secrets.yaml new file mode 100644 index 0000000000..4b11188429 --- /dev/null +++ b/kubernetes/common/controller-blueprints/templates/secrets.yaml @@ -0,0 +1,27 @@ +# Copyright (c) 2018 Amdocs, Bell Canada +# +# 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. + +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "common.fullname" . }} + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.fullname" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} +type: Opaque +data: + db-root-password: {{ index .Values "mariadb-galera" "config" "mariadbRootPassword" | b64enc | quote }} diff --git a/kubernetes/common/controller-blueprints/templates/service.yaml b/kubernetes/common/controller-blueprints/templates/service.yaml new file mode 100644 index 0000000000..438ca19699 --- /dev/null +++ b/kubernetes/common/controller-blueprints/templates/service.yaml @@ -0,0 +1,52 @@ +# Copyright (c) 2018 Amdocs, Bell Canada +# +# 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. + +apiVersion: v1 +kind: Service +metadata: + name: {{ include "common.servicename" . }} + namespace: {{ include "common.namespace" . }} + labels: + app: {{ include "common.name" . }} + chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }} + release: {{ .Release.Name }} + heritage: {{ .Release.Service }} + annotations: +# Example MSB registration annotation +# msb.onap.org/service-info: '[ +# { +# "serviceName": "controller-blueprints", +# "version": "v1", +# "url": "/ecomp/mso/infra", +# "protocol": "REST" +# "port": "8080", +# "visualRange":"1" +# } +# ]' +spec: + type: {{ .Values.service.type }} + ports: + {{if eq .Values.service.type "NodePort" -}} + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.nodePort }} + name: {{ .Values.service.portName | default "http" }} + {{- else -}} + - port: {{ .Values.service.externalPort }} + targetPort: {{ .Values.service.internalPort }} + name: {{ .Values.service.portName | default "http" }} + {{- end}} + selector: + app: {{ include "common.name" . }} + release: {{ .Release.Name }} \ No newline at end of file diff --git a/kubernetes/common/controller-blueprints/values.yaml b/kubernetes/common/controller-blueprints/values.yaml new file mode 100644 index 0000000000..a08ab121ee --- /dev/null +++ b/kubernetes/common/controller-blueprints/values.yaml @@ -0,0 +1,120 @@ +# Copyright (c) 2018 Amdocs, Bell Canada +# +# 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. + +################################################################# +# Global configuration defaults. +################################################################# +global: + # Change to an unused port prefix range to prevent port conflicts + # with other instances running within the same k8s cluster + nodePortPrefix: 302 + + # image repositories + repository: nexus3.onap.org:10001 + + # readiness check + readinessRepository: oomk8s + readinessImage: readiness-check:2.0.0 + + # image pull policy + pullPolicy: Always + + persistence: + mountPath: /dockerdata-nfs + +################################################################# +# Application configuration defaults. +################################################################# +# application image +repository: nexus3.onap.org:10001 +image: onap/ccsdk-controllerblueprints:latest +pullPolicy: Always + +# flag to enable debugging - application support required +debugEnabled: false + +# application configuration +config: + applicationName: ControllerBluePrints + bundleVersion: 1.0.0 + appConfigDir: /opt/app/onap/config + dbUrl: jdbc:mysql://controller-blueprints-db:3306/sdnctl + initDataLoad: true + stickySelectorKey: + envContext: DEV + +mariadb-galera: + config: + userName: sdnctl + userPassword: sdnctl + mariadbRootPassword: sdnctl + mysqlDatabase: sdnctl + nameOverride: controller-blueprints-db + service: + name: controller-blueprints-db + portName: cb-db + replicaCount: 1 + persistence: + enabled: true + mountSubPath: controller-blueprints/data + +# default number of instances +replicaCount: 1 + +nodeSelector: {} + +affinity: {} + +# probe configuration parameters +liveness: + initialDelaySeconds: 10 + periodSeconds: 10 + # necessary to disable liveness probe when setting breakpoints + # in debugger so K8s doesn't restart unresponsive container + enabled: true + +readiness: + initialDelaySeconds: 10 + periodSeconds: 10 + +service: + type: ClusterIP + portName: controller-blueprints + internalPort: 8080 + externalPort: 8080 + +persistence: + enabled: true + +ingress: + enabled: false + +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:'. + # + # Example: + # Configure resource requests and limits + # ref: http://kubernetes.io/docs/user-guide/compute-resources/ + # Minimum memory for development is 2 CPU cores and 4GB memory + # Minimum memory for production is 4 CPU cores and 8GB memory +#resources: +# limits: +# cpu: 2 +# memory: 4Gi +# requests: +# cpu: 2 +# memory: 4Gi -- cgit 1.2.3-korg