Upgrade VNFSDK to use common Postgres charts 47/63547/5
authorjasmineWen <jasmine.wen@amdocs.com>
Wed, 29 Aug 2018 15:55:28 +0000 (15:55 +0000)
committerjasmineWen <jasmine.wen@amdocs.com>
Fri, 14 Sep 2018 17:49:13 +0000 (17:49 +0000)
Issue-ID: OOM-1185

Change-Id: Ie011e87bc9322149076ec62cab3a8b3315e1d817
Signed-off-by: jasmineWen <jasmine.wen@amdocs.com>
kubernetes/vnfsdk/charts/vnfsdk-postgres/templates/deployment.yaml [deleted file]
kubernetes/vnfsdk/charts/vnfsdk-postgres/templates/service.yaml [deleted file]
kubernetes/vnfsdk/charts/vnfsdk-postgres/values.yaml [deleted file]
kubernetes/vnfsdk/requirements.yaml
kubernetes/vnfsdk/resources/config/marketplace_tables_postgres.sql [new file with mode: 0644]
kubernetes/vnfsdk/templates/configmap.yaml [moved from kubernetes/vnfsdk/charts/vnfsdk-postgres/Chart.yaml with 73% similarity]
kubernetes/vnfsdk/templates/deployment.yaml
kubernetes/vnfsdk/templates/job.yaml [new file with mode: 0644]
kubernetes/vnfsdk/values.yaml

diff --git a/kubernetes/vnfsdk/charts/vnfsdk-postgres/templates/deployment.yaml b/kubernetes/vnfsdk/charts/vnfsdk-postgres/templates/deployment.yaml
deleted file mode 100644 (file)
index 88d6238..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright © 2017 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 }}
-  selector:
-    matchLabels:
-      app: {{ include "common.name" . }}
-  template:
-    metadata:
-      labels:
-        app: {{ include "common.name" . }}
-        release: {{ .Release.Name }}
-      name: {{ include "common.name" . }}
-    spec:
-      hostname: {{ include "common.name" . }}
-      containers:
-      - args:
-        image: "{{ include "common.repository" . }}/{{ .Values.image }}"
-        imagePullPolicy: {{ .Values.pullPolicy | default .Values.global.pullPolicy }}
-        name: {{ include "common.name" . }}
-      imagePullSecrets:
-      - name: "{{ include "common.namespace" . }}-docker-registry-key"
diff --git a/kubernetes/vnfsdk/charts/vnfsdk-postgres/templates/service.yaml b/kubernetes/vnfsdk/charts/vnfsdk-postgres/templates/service.yaml
deleted file mode 100644 (file)
index f6208cf..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright © 2017 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 }}
-spec:
-  type: {{ .Values.service.type }}
-  ports:
-    {{if eq .Values.service.type "NodePort" -}}
-    - port: {{ .Values.service.internalPort }}
-      nodePort: {{ .Values.global.nodePortPrefix | default "302" }}{{ .Values.service.nodePort }}
-    {{- else -}}
-    - port: {{ .Values.service.externalPort }}
-      targetPort: {{ .Values.service.internalPort }}
-    {{- end}}
-      name: {{ .Values.service.portName | default "http" }}
-  selector:
-    app: {{ include "common.name" . }}
-    release: {{ .Release.Name }}
diff --git a/kubernetes/vnfsdk/charts/vnfsdk-postgres/values.yaml b/kubernetes/vnfsdk/charts/vnfsdk-postgres/values.yaml
deleted file mode 100644 (file)
index 8582593..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright © 2018 ZTE
-# Modifications Copyright © 2018 AT&T, 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:
-  nodePortPrefix: 302
-  repository: nexus3.onap.org:10001
-  readinessRepository: oomk8s
-  readinessImage: readiness-check:2.0.0
-  loggingRepository: docker.elastic.co
-  loggingImage: beats/filebeat:5.5.0
-
-#################################################################
-# Application configuration defaults.
-#################################################################
-# application image
-repository: nexus3.onap.org:10001
-image: onap/vnfsdk/refrepo/postgres:1.1.1
-pullPolicy: Always
-
-# flag to enable debugging - application support required
-debugEnabled: false
-
-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
-  name: vnfsdk-postgres
-  portName: vnfsdk-postgres
-  internalPort: 5432
-  externalPort: 5432
-
-ingress:
-  enabled: false
index ce82a2f..3b2a02a 100644 (file)
@@ -16,3 +16,6 @@ dependencies:
   - name: common
     version: ~2.0.0
     repository: '@local'
+  - name: postgres
+    version: ~2.0.0
+    repository: '@local'
diff --git a/kubernetes/vnfsdk/resources/config/marketplace_tables_postgres.sql b/kubernetes/vnfsdk/resources/config/marketplace_tables_postgres.sql
new file mode 100644 (file)
index 0000000..c05d7f2
--- /dev/null
@@ -0,0 +1,25 @@
+CREATE DATABASE "marketplaceDB";
+
+\c marketplaceDB;
+
+DROP TABLE IF EXISTS CSAR_PACKAGE_TABLE;
+
+CREATE TABLE CSAR_PACKAGE_TABLE (
+        CSARID                   VARCHAR(200)       NOT NULL,
+        DOWNLOADURI              VARCHAR(200)       NULL,
+        REPORT                       VARCHAR(200)       NULL,
+        SIZE                     VARCHAR(100)       NULL,
+        FORMAT                   VARCHAR(100)       NULL,
+        CREATETIME               VARCHAR(100)       NULL,
+        DELETIONPENDING          VARCHAR(100)       NULL,
+        MODIFYTIME               VARCHAR(100)       NULL,
+        SHORTDESC                    TEXT                       NULL,
+        NAME                     VARCHAR(100)       NULL,
+        VERSION                  VARCHAR(20)        NULL,
+        PROVIDER                 VARCHAR(300)       NULL,
+        TYPE                     VARCHAR(300)       NULL,
+        DETAILS                      TEXT                           NULL,
+        REMARKS                      TEXT                           NULL,
+        DOWNLOADCOUNT            INT                NULL,
+        CONSTRAINT csar_package_table_pkey PRIMARY KEY (CSARID)
+);
@@ -13,6 +13,9 @@
 # limitations under the License.
 
 apiVersion: v1
-description: ONAP VNFSDK Postgres Database
-name: vnfsdk-postgres
-version: 2.0.0
+kind: ConfigMap
+metadata:
+  name: {{ include "common.fullname" . }}
+  namespace: {{ include "common.namespace" . }}
+data:
+{{ tpl (.Files.Glob "resources/config/marketplace_tables_postgres.sql").AsConfig . | indent 2 }}
index 8220553..5b6f923 100644 (file)
@@ -38,7 +38,7 @@ spec:
         - /root/ready.py
         args:
         - --container-name
-        - "{{ .Values.vnfsdkpostgres.nameOverride }}"
+        - "{{ .Values.postgres.nameOverride }}"
         env:
         - name: NAMESPACE
           valueFrom:
@@ -54,7 +54,7 @@ spec:
         name: {{ include "common.name" . }}
         env:
         - name: POSTGRES_SERVICE_HOST
-          value: "$(VNFSDK_POSTGRES_SERVICE_HOST)"
+          value: "$(VNFSDK_DBSET_SERVICE_HOST)"
         readinessProbe:
           tcpSocket:
             port: {{ .Values.service.internalPort }}
diff --git a/kubernetes/vnfsdk/templates/job.yaml b/kubernetes/vnfsdk/templates/job.yaml
new file mode 100644 (file)
index 0000000..08d3107
--- /dev/null
@@ -0,0 +1,70 @@
+# Copyright © 2017 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: batch/v1
+kind: Job
+metadata:
+  name: {{ include "common.fullname" . }}-init-postgres
+  namespace: {{ include "common.namespace" . }}
+  labels:
+    app: {{ include "common.name" . }}-job
+    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+    release: {{ .Release.Name }}
+    heritage: {{ .Release.Service }}
+spec:
+  backoffLimit: 20
+  template:
+    metadata:
+      labels:
+        app: {{ include "common.name" . }}-job
+        release: {{ .Release.Name }}
+    spec:
+      restartPolicy: Never
+      initContainers:
+      - command:
+        - /root/ready.py
+        args:
+        - --container-name
+        - "{{ .Values.postgres.nameOverride }}"
+        env:
+        - name: NAMESPACE
+          valueFrom:
+            fieldRef:
+              apiVersion: v1
+              fieldPath: metadata.namespace
+        image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
+        imagePullPolicy: {{ .Values.global.pullPolicy}}
+        name: {{ include "common.name" . }}-readiness
+      containers:
+      - name: {{ include "common.name" . }}-job
+        image: "{{ .Values.postgresRepository }}/{{ .Values.postgresImage }}"
+        imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+        env:
+        - name: PGPASSWORD
+          value: "{{ .Values.postgres.config.pgUserPassword }}"
+        command:
+        - /bin/sh
+        - -c
+        - |
+          psql -U {{ .Values.postgres.config.pgUserName }} -h $(VNFSDK_DBPRI_SERVICE_HOST) -f /aaa/init/marketplace_tables_postgres.sql
+        volumeMounts:
+        - name: init-data
+          mountPath: /aaa/init/marketplace_tables_postgres.sql
+          subPath: marketplace_tables_postgres.sql
+      imagePullSecrets:
+      - name: "{{ include "common.namespace" . }}-docker-registry-key"
+      volumes:
+      - name: init-data
+        configMap:
+          name: {{ include "common.fullname" . }}
index edca2ec..0db7744 100644 (file)
@@ -29,11 +29,30 @@ global:
 # application image
 repository: nexus3.onap.org:10001
 image: onap/vnfsdk/refrepo:1.1.1
+postgresRepository: crunchydata
+postgresImage: crunchy-postgres:centos7-10.3-1.8.2
 pullPolicy: Always
 
-#subchart name
-vnfsdkpostgres:
+# application configuration override for postgres
+postgres:
   nameOverride: vnfsdk-postgres
+  service:
+    name: vnfsdk-dbset
+    name2: vnfsdk-dbpri
+    name3: vnfsdk-dbrep
+  container:
+    name:
+      primary: vnfsdk-dbpri
+      replica: vnfsdk-dbrep
+  persistence:
+    mountSubPath: vnfsdk/data
+    mountInitPath: vnfsdk
+  config:
+    pgUserName: postgres
+    pgDatabase: postgres
+    pgPrimaryPassword: postgres
+    pgUserPassword: postgres
+    pgRootPassword: postgres
 
 # flag to enable debugging - application support required
 debugEnabled: false