Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIM Intelligence : Helm changes #348

Draft
wants to merge 3 commits into
base: develop/portal
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions charts/intelligence/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
dependencies:
- name: kafka
repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami
version: 31.2.0
- name: mongodb
repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami
version: 16.4.1
- name: mysql
repository: https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami
version: 10.3.0
digest: sha256:6ca37e64a48a3e6e9cc6e4596d8a9687fb787a0f31997d9288611e935f2fb752
generated: "2025-01-17T12:50:09.691806+05:30"
23 changes: 23 additions & 0 deletions charts/intelligence/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v2
appVersion: "0.0.1"
description: APIM Intelligence
name: apim-intelligence
version: 0.0.1
type: application
home: https://github.com/CAAPIM/apim-chart
maintainers:
- name: Layer7
sources:
- https://github.com/CAAPIM/apim-charts
engine: gotpl
dependencies:
- name: kafka
version: 31.2.0
repository: "https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami"
- name: mongodb
version: 16.4.1
repository: "https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami"
- name: mysql
version: 10.3.0
repository: "https://raw.githubusercontent.com/bitnami/charts/archive-full-index/bitnami"
condition: global.setupDemoDatabase
Empty file added charts/intelligence/README.md
Empty file.
Binary file added charts/intelligence/apim-intelligence-0.0.1.tgz
Binary file not shown.
Binary file added charts/intelligence/charts/kafka-31.2.0.tgz
Binary file not shown.
Binary file added charts/intelligence/charts/mongodb-16.4.1.tgz
Binary file not shown.
Binary file added charts/intelligence/charts/mysql-10.3.0.tgz
Binary file not shown.
Empty file.
95 changes: 95 additions & 0 deletions charts/intelligence/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "intelligence.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 "intelligence.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 "intelligence.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}


{{/*
Set the service account name for the Portal Stack
*/}}
{{- define "intelligence.serviceAccountName" -}}
{{- if .Values.global.serviceAccountName }}
{{ default "default" .Values.global.serviceAccountName }}
{{- else }}
{{- if .Values.serviceAccount.create -}}
{{ default (include "intelligence.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{- end -}}


{{/*
Get "intelligence" database name
*/}}
{{- define "intelligence-db-name" -}}
{{ if .Values.global.legacyDatabaseNames }}
{{- print "intelligence" }}
{{- else }}
{{- $f:= .Values.global.subdomainPrefix -}}
{{ if empty $f }}
{{- fail "Please define subdomainPrefix in values.yaml" }}
{{- else }}
{{- printf "%s_%s" $f "intelligence" | replace "-" "_" -}}
{{- end }}
{{- end }}
{{- end -}}

{{/*
Get "database-port" based on databaseType value
*/}}
{{- define "database-port" -}}
{{- print .Values.global.databasePort -}}
{{- end -}}

{{/*
Get "mongodb" host
*/}}
{{- define "mongodb-host" -}}
{{- printf "%s-%s" .Release.Name "mongodb" -}}
{{- end -}}

{{/*
Get "kafka" brokers
*/}}
{{- define "kafka-brokers" -}}
{{- printf "%s-kafka:%g" .Release.Name .Values.kafka.listeners.client.containerPort -}}
{{- end -}}

{{/*
Create Image Pull Secret
*/}}
{{- define "intelligence-imagePullSecret" }}
{{- if and (not .Values.intelligence.useExistingPullSecret) (.Values.intelligence.imagePullSecret.enabled) }}
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"auth\":\"%s\"}}}" .Values.global.portalRepository .Values.intelligence.imagePullSecret.username .Values.intelligence.imagePullSecret.password (printf "%s:%s" .Values.intelligence.imagePullSecret.username .Values.intelligence.imagePullSecret.password | b64enc) | b64enc }}
{{- end }}
{{- end }}
34 changes: 34 additions & 0 deletions charts/intelligence/templates/database-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{ if and (.Values.standalone) (not .Values.global.useExistingDatabaseSecret) }}
apiVersion: v1
kind: Secret
metadata:
name: {{.Values.global.databaseSecret}}
annotations:
helm.sh/hook: pre-install
helm.sh/hook-weight: "-10"
labels:
app: {{ template "intelligence.name" . }}
chart: {{ template "intelligence.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
{{ if eq .Values.global.databaseType "mysql" }}
{{- if and .Values.global.setupDemoDatabase .Values.global.demoDatabaseRootPassword }}
mysql-root-password: {{ .Values.global.demoDatabaseRootPassword | b64enc | quote }}
{{ else }}
mysql-root-password: {{ randAlphaNum 10 | b64enc | quote }}
{{ end }}
{{- if and .Values.global.setupDemoDatabase .Values.global.demoDatabaseReplicationPassword }}
mysql-replication-password: {{ .Values.global.demoDatabaseReplicationPassword | b64enc | quote }}
{{ else }}
mysql-replication-password: {{ randAlphaNum 10 | b64enc | quote }}
{{ end }}
{{if .Values.global.databasePassword }}
mysql-password: {{ .Values.global.databasePassword | b64enc | quote }}
{{ else }}
mysql-password: {{ randAlphaNum 10 | b64enc | quote }}
{{ end }}

{{ end }}
{{ end }}
29 changes: 29 additions & 0 deletions charts/intelligence/templates/docker-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{ if and (not .Values.intelligence.useExistingPullSecret) (.Values.standalone) }}
{{ if or (.Values.intelligence.registryCredentials) (.Values.intelligence.imagePullSecret.enabled) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ .Values.global.pullSecret }}
annotations:
helm.sh/hook: pre-install
helm.sh/hook-weight: "-10"
labels:
app: {{ template "intelligence.name" . }}
chart: {{ template "intelligence.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: kubernetes.io/dockerconfigjson
data:
{{- if .Values.intelligence.registryCredentials }}
{{- range $key, $value := fromYaml .Values.intelligence.registryCredentials }}
{{- if eq $key "data" }}
{{- range $value }}
.dockerconfigjson: {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- else }}
.dockerconfigjson: {{ template "intelligence-imagePullSecret" . }}
{{ end }}
{{ end }}
{{ end }}
15 changes: 15 additions & 0 deletions charts/intelligence/templates/mongodb/mongodb-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{if not .Values.security.mongodb.useExistingSectet }}
apiVersion: v1
kind: Secret
metadata:
name: mongodb-secret
labels:
app: mongodb
chart: {{ template "intelligence.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
mongodb-passwords: {{ required "Please fill in security.mongodb.dbPassword in values.yaml" .Values.security.mongodb.dbPassword | b64enc | quote }}
mongodb-root-password: {{ required "Please fill in security.mongodb.rootPassword in values.yaml" .Values.security.mongodb.rootPassword | b64enc | quote }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/intelligence/templates/server/server-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: intelligence-server-config
labels:
app: intelligence-server
chart: {{ template "intelligence.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
data:
{{ if .Values.global.setupDemoDatabase}}
DATABASE_HOST: {{ .Release.Name }}-{{ .Values.global.databaseHost }}
{{ else }}
DATABASE_HOST: {{ .Values.global.databaseHost | quote }}
{{ end }}
DATABASE_PORT: {{ include "database-port" . | quote }}
DATABASE_USE_SSL: {{ .Values.global.databaseUseSSL | quote }}
DATABASE_REQUIRE_SSL: {{ .Values.global.databaseRequireSSL | quote }}
INTELLIGENCE_DATABASE_NAME: {{ include "intelligence-db-name" . | quote }}
MONGO_DB_HOST: {{ include "mongodb-host" . | quote}}
MONGO_DB_PORT: {{ .Values.mongodb.containerPorts.mongodb | quote}}
MONGO_DB_NAME: {{ required "Please fill in mongodb.auth.database in values.yaml" .Values.mongodb.auth.database | quote }}
KAFKA_BROKERS: {{ include "kafka-brokers" . | quote}}
110 changes: 110 additions & 0 deletions charts/intelligence/templates/server/server-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: intelligence-server
labels:
app: intelligence-server
chart: {{ template "intelligence.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
{{- range $key, $val := .Values.global.additionalLabels }}
{{ $key }}: "{{ $val }}"
{{- end }}
{{- range $key, $val := .Values.intelligenceServer.additionalLabels }}
{{ $key }}: "{{ $val }}"
{{- end }}
spec:
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
replicas: {{ .Values.intelligenceServer.replicaCount }}
selector:
matchLabels:
app: intelligence-server
template:
metadata:
labels:
app: intelligence-server
{{ if .Values.forceRedeploy }}
annotations:
timestamp: {{ now | quote }}
{{- end }}
spec:
serviceAccountName: {{ include "intelligence.serviceAccountName" . }}
{{- if .Values.intelligenceServer.affinity }}
affinity: {{- toYaml .Values.intelligenceServer.affinity | nindent 12 }}
{{- end }}
{{- if .Values.intelligenceServer.nodeSelector }}
nodeSelector: {{- toYaml .Values.intelligenceServer.nodeSelector | nindent 12 }}
{{- end }}
{{- if .Values.intelligenceServer.tolerations }}
tolerations: {{- toYaml .Values.intelligenceServer.tolerations | nindent 12 }}
{{- end }}
{{- if .Values.intelligenceServer.podSecurityContext }}
securityContext: {{- toYaml .Values.intelligenceServer.podSecurityContext | nindent 12 }}
{{- else if .Values.global.podSecurityContext }}
securityContext: {{- toYaml .Values.global.podSecurityContext | nindent 12 }}
{{- end }}
containers:
- name: intelligence-server
image: "{{ .Values.global.portalRepository }}{{ .Values.image.intelligenceServer }}"
imagePullPolicy: "{{ .Values.intelligenceServer.image.pullPolicy }}"
{{- if .Values.intelligenceServer.containerSecurityContext }}
securityContext: {{- toYaml .Values.intelligenceServer.containerSecurityContext | nindent 12 }}
{{- else if .Values.global.containerSecurityContext }}
securityContext: {{- toYaml .Values.global.containerSecurityContext | nindent 12 }}
{{- end }}
{{- if .Values.intelligenceServer.affinity }}
affinity: {{- toYaml .Values.intelligenceServer.affinity | nindent 12 }}
{{- end }}
{{- if .Values.intelligenceServer.nodeSelector }}
nodeSelector: {{- toYaml .Values.intelligenceServer.nodeSelector | nindent 12 }}
{{- end }}
{{- if .Values.intelligenceServer.tolerations }}
tolerations: {{- toYaml .Values.intelligenceServer.tolerations | nindent 12 }}
{{- end }}
{{- if .Values.global.schedulerName }}
schedulerName: "{{ .Values.global.schedulerName }}"
{{- end }}
env:
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.global.databaseSecret }}
{{ if eq .Values.global.databaseType "mysql" }}
key: mysql-password
{{ end }}
envFrom:
- configMapRef:
name: intelligence-server-config
- secretRef:
name: intelligence-server-secret
# readinessProbe:
# httpGet:
# path: "/actuator/health/readiness"
# port: 8282
# initialDelaySeconds: 90
# timeoutSeconds: 1
# periodSeconds: 15
# successThreshold: 1
# livenessProbe:
# httpGet:
# path: "/actuator/health/liveness"
# port: 8282
# initialDelaySeconds: 120
# timeoutSeconds: 1
# periodSeconds: 15
# successThreshold: 1
{{- if .Values.intelligenceServer.resources }}
resources: {{- toYaml .Values.intelligenceServer.resources | nindent 12 }}
{{- end }}
ports:
- containerPort: 8282
{{- if .Values.global.pullSecret }}
imagePullSecrets:
- name: "{{ .Values.global.pullSecret }}"
{{- end }}
restartPolicy: Always
terminationGracePeriodSeconds: 30
13 changes: 13 additions & 0 deletions charts/intelligence/templates/server/server-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Secret
metadata:
name: intelligence-server-secret
labels:
app: intelligence-server
chart: {{ template "intelligence.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
type: Opaque
data:
DATABASE_USERNAME: {{ required "Please fill in databaseUsername in values.yaml" .Values.global.databaseUsername | b64enc | quote }}
MONGO_DB_USERNAME: {{ required "Please fill in mongodb.auth.username in values.yaml" .Values.mongodb.auth.username | b64enc | quote }}
18 changes: 18 additions & 0 deletions charts/intelligence/templates/server/server-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: v1
kind: Service
metadata:
name: intelligence-server
labels:
app: intelligence-server
chart: {{ template "intelligence.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
clusterIP: None
ports:
- name: "8282"
port: {{ .Values.intelligenceServer.port }}
targetPort: 8282
selector:
app: intelligence-server
sessionAffinity: ClientIP
Loading
Loading