[DMaaP BC] Use common.service template 21/103421/5
authorSylvain Desbureaux <sylvain.desbureaux@orange.com>
Tue, 10 Mar 2020 08:57:25 +0000 (09:57 +0100)
committerSylvain Desbureaux <sylvain.desbureaux@orange.com>
Wed, 11 Mar 2020 10:00:47 +0000 (11:00 +0100)
Use the service template from common folder.
Align Deployment with kubernetes v1.9+ stable APIs

Fix case when PG AND AAF are not enabled

Enable liveness and readiness probes.

Issue-ID: OOM-1971
Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com>
Change-Id: Ic6232312ba28effeb8d911001bc05ed7752b2212

kubernetes/dmaap/components/dmaap-bc/templates/deployment.yaml
kubernetes/dmaap/components/dmaap-bc/templates/post-install-job.yaml
kubernetes/dmaap/components/dmaap-bc/templates/service.yaml
kubernetes/dmaap/components/dmaap-bc/values.yaml

index a434439..3e08185 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-apiVersion: extensions/v1beta1
+apiVersion: apps/v1
 kind: Deployment
-metadata:
-  name: {{ include "common.fullname" . }}
-  namespace: {{ include "common.namespace" . }}
-  labels:
-    app: {{ include "common.name" . }}
-    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
-    release: {{ include "common.release" . }}
-    heritage: {{ .Release.Service }}
+metadata: {{- include "common.resourceMetadata" . | nindent 2 }}
 spec:
+  selector: {{- include "common.selectors" . | nindent 4 }}
   replicas: {{ .Values.replicaCount }}
   template:
-    metadata:
-      labels:
-        app: {{ include "common.name" . }}
-        release: {{ include "common.release" . }}
+    metadata: {{- include "common.templateMetadata" . | nindent 6 }}
     spec:
+{{- if or .Values.global.aafEnabled .Values.PG.enabled }}
       initContainers:
 {{- if .Values.global.aafEnabled }}
-      - command:
+      - name: {{ include "common.name" . }}-aaf-readiness
+        command:
         - /root/ready.py
         args:
         - --container-name
         - aaf-locate
+        - --container-name
+        - aaf-cm
+        - --container-name
+        - aaf-service
         env:
         - name: NAMESPACE
           valueFrom:
@@ -45,8 +42,7 @@ spec:
               fieldPath: metadata.namespace
         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
-        name: {{ include "common.name" . }}-aaf-readiness
-      - name: {{ include "common.name" . }}-dbc-aaf-config
+      - name: {{ include "common.name" . }}-aaf-config
         image: "{{ include "common.repository" . }}/{{ .Values.global.aafAgentImage }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
         command: ["bash","-c","exec /opt/app/aaf_config/bin/agent.sh"]
@@ -81,7 +77,8 @@ spec:
           value: "{{ .Values.aafConfig.cadiLatitude }}"
 {{- end }}
 {{- if .Values.PG.enabled }}
-      - command:
+      - name: {{ include "common.name" . }}-postgres-readiness
+        command:
         - /root/ready.py
         args:
         - --container-name
@@ -94,30 +91,29 @@ spec:
               fieldPath: metadata.namespace
         image: "{{ .Values.global.readinessRepository }}/{{ .Values.global.readinessImage }}"
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
-        name: {{ include "common.name" . }}-postgres-readiness
-{{- end}}
+{{- end }}
+{{- end }}
       containers:
         - name: {{ include "common.name" . }}
           image: "{{ include "common.repository" . }}/{{ .Values.image }}"
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
-          ports:
-          - containerPort: {{ .Values.service.internalPort }}
-          - containerPort: {{ .Values.service.internalPort2 }}
+          ports: {{ include "common.containerPorts" . | nindent 10  }}
           {{ if eq .Values.liveness.enabled true -}}
           livenessProbe:
             httpGet:
-              port: {{ .Values.service.internalPort }}
-              path: /webapi/info
+              port: {{ .Values.liveness.port }}
+              path: /webapi/topics
+              scheme: {{ if (include "common.needTLS" .) }}HTTPS{{ else }}HTTP{{ end }}
             initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
             periodSeconds: {{ .Values.liveness.periodSeconds }}
+          {{ end -}}
           readinessProbe:
             httpGet:
-              host: {{ .Values.dmaapMessageRouterService }}
-              port: 3904
-              path: /topics
+              port: {{ .Values.readiness.port }}
+              path: /webapi/topics
+              scheme: {{ if (include "common.needTLS" .) }}HTTPS{{ else }}HTTP{{ end }}
             initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
             periodSeconds: {{ .Values.readiness.periodSeconds }}
-          {{ end -}}
           volumeMounts:
           - mountPath: /etc/localtime
             name: localtime
@@ -129,15 +125,12 @@ spec:
           - name: {{ include "common.name" . }}-aaf-config
             mountPath: /opt/app/dmaapbc/etc/org.onap.dmaap-bc.props
             subPath: org.onap.dmaap-bc.props
-          resources:
-{{ include "common.resources" . }}
+          resources: {{ include "common.resources" . | nindent 12 }}
         {{- if .Values.nodeSelector }}
-        nodeSelector:
-{{ toYaml .Values.nodeSelector | indent 10 }}
+        nodeSelector: {{ toYaml .Values.nodeSelector | nindent 10 }}
         {{- end -}}
         {{- if .Values.affinity }}
-        affinity:
-{{ toYaml .Values.affinity | indent 10 }}
+        affinity: {{ toYaml .Values.affinity | nindent 10 }}
         {{- end }}
       volumes:
         - name: localtime
index a8833c1..c06d4e1 100644 (file)
@@ -2,11 +2,8 @@ apiVersion: batch/v1
 kind: Job
 metadata:
   name: {{ include "common.fullname" . }}-post-install
-  labels:
-    app.kubernetes.io/managed-by: {{.Release.Service | quote }}
-    app.kubernetes.io/instance: {{include "common.release" . | quote }}
-    helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}"
-    release: {{ include "common.release" . }}
+  namespace: {{ include "common.namespace" . }}
+  labels: {{- include "common.labels" . | nindent 4 }}
   annotations:
     # This is what defines this resource as a hook. Without this line, the
     # job is considered part of the release.
@@ -15,16 +12,9 @@ metadata:
     "helm.sh/hook-delete-policy": hook-succeeded
 spec:
   template:
-    metadata:
-      name: {{ include "common.fullname" . }}
-      labels:
-        app.kubernetes.io/managed-by: {{.Release.Service | quote }}
-        app.kubernetes.io/instance: {{include "common.release" . | quote }}
-        helm.sh/chart: "{{.Chart.Name}}-{{.Chart.Version}}"
-        release: {{ include "common.release" . }}
+    metadata: {{- include "common.templateMetadata" . | nindent 6 }}
     spec:
       restartPolicy: Never
-
       containers:
       - name: post-install-job
         image: "{{ include "common.repository" . }}/{{ .Values.global.clientImage }}"
@@ -33,9 +23,15 @@ spec:
         - name: DELAY
           value: "0"
         - name: PROTO
+{{- if (include "common.needTLS" .) }}
           value: "https"
         - name: PORT
           value: "8443"
+{{- else }}
+          value: "http"
+        - name: PORT
+          value: "8080"
+{{- end }}
         - name: REQUESTID
           value: "{{.Chart.Name}}-post-install"
         volumeMounts:
@@ -50,15 +46,12 @@ spec:
           mountPath: /opt/app/config/dmaap/
         - name:  {{ include "common.fullname" . }}-dbc-dcaelocations
           mountPath: /opt/app/config/dcaeLocations/
-        resources:
-{{ include "common.resources" . | indent 10 }}
+        resources: {{ include "common.resources" . | nindent 10 }}
         {{- if .Values.nodeSelector }}
-      nodeSelector:
-{{ toYaml .Values.nodeSelector | indent 8 }}
+      nodeSelector: {{ toYaml .Values.nodeSelector | nindent 8 }}
         {{- end -}}
         {{- if .Values.affinity }}
-      affinity:
-{{ toYaml .Values.affinity | indent 8 }}
+      affinity: {{ toYaml .Values.affinity | nindent 8 }}
         {{- end }}
       volumes:
         - name: localtime
index ea26452..9c9414f 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-apiVersion: v1
-kind: Service
-metadata:
-  name: {{ .Values.service.name }}
-  namespace: {{ include "common.namespace" . }}
-  labels:
-    app: {{ include "common.name" . }}
-    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
-    release: {{ include "common.release" . }}
-    heritage: {{ .Release.Service }}
-spec:
-  type: {{ .Values.service.type }}
-  ports:
-    {{if eq .Values.service.type "NodePort" -}}
-    {{- if .Values.global.allow_http }}
-    - port: {{ .Values.service.externalPort }}
-      targetPort: {{ .Values.service.internalPort }}
-      nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.nodePort }}
-      name: {{ .Values.service.name }}
-    {{- end}}
-    - port: {{ .Values.service.externalPort2 }}
-      targetPort: {{ .Values.service.internalPort2 }}
-      nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.nodePort2 }}
-      name: {{ .Values.service.name }}2
-    {{- else -}}
-    - port: {{ .Values.service.externalPort }}
-      targetPort: {{ .Values.service.internalPort }}
-      name: {{ .Values.service.name }}
-    - port: {{ .Values.service.externalPort2 }}
-      targetPort: {{ .Values.service.internalPort2 }}
-      name: {{ .Values.service.name }}2
-    {{- end}}
-  selector:
-    app: {{ include "common.name" . }}
-    release: {{ include "common.release" . }}
+{{ include "common.service" . }}
index 046f64d..28c77eb 100644 (file)
@@ -79,24 +79,24 @@ liveness:
   periodSeconds: 10
   # necessary to disable liveness probe when setting breakpoints
   # in debugger so K8s doesn't restart unresponsive container
-  enabled: false
+  port: api
+  enabled: true
 
 readiness:
   initialDelaySeconds: 10
   periodSeconds: 10
+  port: api
 
 
 service:
   type: NodePort
   name: dmaap-bc
-  portName: dmaap-bc
-  portName2: dmaap-bc
-  externalPort: 8080
-  internalPort: 8080
-  externalPort2: 8443
-  internalPort2: 8443
-  nodePort: 41
-  nodePort2: 42
+  ports:
+    - name: api
+      port: 8443
+      plain_port: 8080
+      port_protocol: http
+      nodePort: 42
 
 
 # application configuration override for postgres