diff --git a/.gitignore b/.gitignore index 0b81b3f019a93de98db02b261d7068a15713581b..f7e7dd86ded915fa21e6425bcf8f175642da575c 100644 --- a/.gitignore +++ b/.gitignore @@ -141,3 +141,8 @@ common/go/src/asapo_common/version/version_lib.go .terraform terraform.tfstate* + + +#helm chart +deploy/asapo_helm_chart/asapo/Chart.lock +deploy/asapo_helm_chart/asapo/charts/ \ No newline at end of file diff --git a/deploy/asapo_helm_chart/asapo/Chart.yaml b/deploy/asapo_helm_chart/asapo/Chart.yaml index b73e5145fdc355c61dabf6e9264b0a5e946dbaa9..032a6d45bf5ccfff6c17974c8d09d108506a09f4 100644 --- a/deploy/asapo_helm_chart/asapo/Chart.yaml +++ b/deploy/asapo_helm_chart/asapo/Chart.yaml @@ -19,3 +19,11 @@ version: 0.1.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. appVersion: 1.16.0 + + +dependencies: + - name: influxdb + version: "~0.4.3" + repository: "https://charts.bitnami.com/bitnami" + + diff --git a/deploy/asapo_helm_chart/asapo/configs/authorizer.json b/deploy/asapo_helm_chart/asapo/configs/asapo-authorizer.json similarity index 92% rename from deploy/asapo_helm_chart/asapo/configs/authorizer.json rename to deploy/asapo_helm_chart/asapo/configs/asapo-authorizer.json index 3a6784d5b25e540dfe811deb8df95bbe5a6d983c..b3ad3fd52c785b586e2277882f30cbf6289a87d1 100644 --- a/deploy/asapo_helm_chart/asapo/configs/authorizer.json +++ b/deploy/asapo_helm_chart/asapo/configs/asapo-authorizer.json @@ -1,5 +1,5 @@ { - "Port": 5007, + "Port": {{ .Values.ownServices.authorizer.port }}, "LogLevel":"debug", "AlwaysAllowedBeamtimes":[{"beamtimeId":"asapo_test","beamline":"test","core-path":"{{ .Values.common.offlineDir }}/test_facility/gpfs/test/2019/data/asapo_test"}, {"beamtimeId":"asapo_test1","beamline":"test1","core-path":"{{ .Values.common.offlineDir }}/test_facility/gpfs/test1/2019/data/asapo_test1"}, @@ -9,4 +9,3 @@ "SecretFile":"/etc/authorizer/auth_secret.key", "TokenDurationMin":600 } - diff --git a/deploy/asapo_helm_chart/asapo/configs/asapo-broker.json b/deploy/asapo_helm_chart/asapo/configs/asapo-broker.json new file mode 100644 index 0000000000000000000000000000000000000000..10441cd9f575371bed79a453c7368eb4023556e5 --- /dev/null +++ b/deploy/asapo_helm_chart/asapo/configs/asapo-broker.json @@ -0,0 +1,9 @@ +{ + "DatabaseServer":"auto", + "DiscoveryServer": "discovery:{{ .Values.ownServices.discovery.port }}", + "PerformanceDbServer":"{{ .Chart.Name }}-influxdb:{{ .Values.influxdb.influxdb.service.port }}", + "PerformanceDbName": "asapo_brokers", + "Port": {{ .Values.ownServices.broker.port }}, + "LogLevel":"debug", + "SecretFile":"/etc/broker/auth_secret.key" +} diff --git a/deploy/asapo_helm_chart/asapo/templates/_config-map.tpl b/deploy/asapo_helm_chart/asapo/templates/_config-map.tpl new file mode 100644 index 0000000000000000000000000000000000000000..14851a6c10620c7347b0ed1e9284bc2f67c1d032 --- /dev/null +++ b/deploy/asapo_helm_chart/asapo/templates/_config-map.tpl @@ -0,0 +1,10 @@ +{{/* Generate configmaps */}} +{{- define "asapo.configmap-fromfile" }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ .service.serviceName }}-config +data: + {{ .service.serviceName }}.json: {{ tpl (.Files.Get (printf "configs/%s.json" .service.serviceName)) . | quote }} +{{- end }} + diff --git a/deploy/asapo_helm_chart/asapo/templates/_helpers.tpl b/deploy/asapo_helm_chart/asapo/templates/_helpers.tpl deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/deploy/asapo_helm_chart/asapo/templates/_ingress.tpl b/deploy/asapo_helm_chart/asapo/templates/_ingress.tpl new file mode 100644 index 0000000000000000000000000000000000000000..2ef5a7eab873adf81e0233a37ed7a7e6ecf1c0f1 --- /dev/null +++ b/deploy/asapo_helm_chart/asapo/templates/_ingress.tpl @@ -0,0 +1,20 @@ +{{/* Generate ingres */}} +{{- define "asapo.ingress" }} +apiVersion: networking.k8s.io/v1beta1 +kind: Ingress +metadata: + name: ingress-{{ .service.serviceName }} + annotations: + kubernetes.io/ingress.class: "nginx" + nginx.ingress.kubernetes.io/rewrite-target: /$2 + nginx.ingress.kubernetes.io/whitelist-source-range: 131.169.0.0/16 +spec: + rules: + - host: "*.desy.de" + http: + paths: + - path: /{{ .Release.Namespace }}/{{ .service.serviceName }}(/|$)(.*) + backend: + serviceName: {{ .service.serviceName }} + servicePort: {{ .service.port }} +{{- end }} diff --git a/deploy/asapo_helm_chart/asapo/templates/_service.tpl b/deploy/asapo_helm_chart/asapo/templates/_service.tpl new file mode 100644 index 0000000000000000000000000000000000000000..c766111db11f013f756763447d141e2db7e2089c --- /dev/null +++ b/deploy/asapo_helm_chart/asapo/templates/_service.tpl @@ -0,0 +1,14 @@ +{{/* Generate service */}} +{{- define "asapo.service" }} +apiVersion: v1 +kind: Service +metadata: + name: {{ .service.serviceName }} +spec: + type: {{ if .service._exposeServiceExtrernally }}NodePort{{ else }}ClusterIP{{ end }} + ports: + - protocol: TCP + port: {{ .service.port }} + selector: + app: {{ .service.serviceName }} +{{- end }} diff --git a/deploy/asapo_helm_chart/asapo/templates/authorizer-config.yaml b/deploy/asapo_helm_chart/asapo/templates/authorizer-config.yaml deleted file mode 100644 index a20024084eccb1a73c4d17d597872e98a7c413f6..0000000000000000000000000000000000000000 --- a/deploy/asapo_helm_chart/asapo/templates/authorizer-config.yaml +++ /dev/null @@ -1,6 +0,0 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: authorizer-config -data: - authorizer.json: {{ tpl (.Files.Get "configs/authorizer.json") . | quote }} diff --git a/deploy/asapo_helm_chart/asapo/templates/authorizer-deployment.yaml b/deploy/asapo_helm_chart/asapo/templates/authorizer-deployment.yaml index 2d6afedcbd95a95e98c142d9c17ff2b0ce08dd5e..7ad1bd27e79e57d0b98879d51d5e51c394c5f914 100644 --- a/deploy/asapo_helm_chart/asapo/templates/authorizer-deployment.yaml +++ b/deploy/asapo_helm_chart/asapo/templates/authorizer-deployment.yaml @@ -1,20 +1,20 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: authorizer-deployment + name: asapo-authorizer labels: - app: authorizer + app: asapo-authorizer spec: - replicas: {{ .Values.authorizer.replicaCount }} + replicas: {{ .Values.ownServices.authorizer.replicaCount }} selector: matchLabels: - app: authorizer + app: asapo-authorizer template: metadata: labels: - app: authorizer + app: asapo-authorizer annotations: - checksum/config: {{ include (print $.Template.BasePath "/authorizer-config.yaml") . | sha256sum }} + checksum/config: {{ .Files.Get "configs/asapo-authorizer.json" | sha256sum }} checksum/secret: {{ include (print $.Template.BasePath "/auth-secret.yaml") . | sha256sum }} spec: volumes: @@ -22,7 +22,7 @@ spec: projected: sources: - configMap: - name: authorizer-config + name: asapo-authorizer-config - secret: name: auth-secret - name: shared-volume-offline @@ -35,9 +35,9 @@ spec: - name: authorizer image: "yakser/asapo-authorizer-dev:{{ .Values.common.asapoVersionTag }}" command: ["/asapo-authorizer"] - args: ["-config", "/etc/authorizer/authorizer.json"] + args: ["-config", "/etc/authorizer/asapo-authorizer.json"] ports: - - containerPort: 5007 + - containerPort: {{ .Values.ownServices.authorizer.port }} volumeMounts: - mountPath: "/etc/authorizer" name: all-in-one diff --git a/deploy/asapo_helm_chart/asapo/templates/authorizer-ingress.yaml b/deploy/asapo_helm_chart/asapo/templates/authorizer-ingress.yaml index e4bccfc531fc173b69b6c9f979ec747ff45a02fd..08bc7107bc48c9640811a4b6d3e2296f7642f3d8 100644 --- a/deploy/asapo_helm_chart/asapo/templates/authorizer-ingress.yaml +++ b/deploy/asapo_helm_chart/asapo/templates/authorizer-ingress.yaml @@ -1,17 +1,2 @@ -apiVersion: networking.k8s.io/v1beta1 -kind: Ingress -metadata: - name: ingress-authorizer - annotations: - kubernetes.io/ingress.class: "nginx" - nginx.ingress.kubernetes.io/rewrite-target: /$2 - nginx.ingress.kubernetes.io/whitelist-source-range: 131.169.0.0/16 -spec: - rules: - - host: "*.desy.de" - http: - paths: - - path: /{{ .Release.Namespace }}/authorizer(/|$)(.*) - backend: - serviceName: authorizer - servicePort: 5007 +{{ $data := dict "Release" .Release "Values" .Values "service" .Values.ownServices.authorizer }} +{{- template "asapo.ingress" $data }} diff --git a/deploy/asapo_helm_chart/asapo/templates/authorizer-service.yaml b/deploy/asapo_helm_chart/asapo/templates/authorizer-service.yaml deleted file mode 100644 index a67faa7a1491206aa7be8c6732ba97a4ac85d3d1..0000000000000000000000000000000000000000 --- a/deploy/asapo_helm_chart/asapo/templates/authorizer-service.yaml +++ /dev/null @@ -1,11 +0,0 @@ -apiVersion: v1 -kind: Service -metadata: - name: authorizer -spec: - type: ClusterIP - ports: - - protocol: TCP - port: 5007 - selector: - app: authorizer diff --git a/deploy/asapo_helm_chart/asapo/templates/broker-deployment.yaml b/deploy/asapo_helm_chart/asapo/templates/broker-deployment.yaml new file mode 100644 index 0000000000000000000000000000000000000000..9552f0cc15a145a924e90feb485635132ab03ecb --- /dev/null +++ b/deploy/asapo_helm_chart/asapo/templates/broker-deployment.yaml @@ -0,0 +1,42 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: asapo-broker + labels: + app: asapo-broker +spec: + replicas: {{ .Values.ownServices.broker.replicaCount }} + selector: + matchLabels: + app: broker + template: + metadata: + labels: + app: broker + annotations: + checksum/config: {{ .Files.Get "configs/asapo-broker.json" | sha256sum }} + checksum/secret: {{ include (print $.Template.BasePath "/auth-secret.yaml") . | sha256sum }} + spec: + volumes: + - name: all-in-one + projected: + sources: + - configMap: + name: asapo-broker-config + - secret: + name: auth-secret + initContainers: + - name: wait-databases + image: busybox:1.28 + command: ['sh', '-c', "until wget asapo-influxdb:8086/ping; do echo waiting for influxdb; sleep 2; done"] + containers: + - name: broker + image: "yakser/asapo-broker-dev:{{ .Values.common.asapoVersionTag }}" + command: ["/asapo-broker"] + args: ["-config", "/etc/broker/asapo-broker.json"] + ports: + - containerPort: {{ .Values.ownServices.broker.port }} + volumeMounts: + - mountPath: "/etc/broker" + name: all-in-one + diff --git a/deploy/asapo_helm_chart/asapo/templates/configs.yaml b/deploy/asapo_helm_chart/asapo/templates/configs.yaml new file mode 100644 index 0000000000000000000000000000000000000000..4c6fcd30b19dfb5b2db1af11b7b0cbf6b2007351 --- /dev/null +++ b/deploy/asapo_helm_chart/asapo/templates/configs.yaml @@ -0,0 +1,9 @@ +{{ $servicesToConfig := list .Values.ownServices.authorizer.serviceName .Values.ownServices.broker.serviceName }} + +{{- range .Values.ownServices }} + {{ $data := dict "Chart" $.Chart "Template" $.Template "Values" $.Values "Files" $.Files "service" . }} + {{- if has .serviceName $servicesToConfig }} + {{- template "asapo.configmap-fromfile" $data }} +--- + {{- end }} +{{- end }} diff --git a/deploy/asapo_helm_chart/asapo/templates/services.yaml b/deploy/asapo_helm_chart/asapo/templates/services.yaml new file mode 100644 index 0000000000000000000000000000000000000000..c40f4a5308dee0d1d987310d2b528fc092f2122e --- /dev/null +++ b/deploy/asapo_helm_chart/asapo/templates/services.yaml @@ -0,0 +1,9 @@ +{{ $servicesToConfig := list .Values.ownServices.authorizer.serviceName .Values.ownServices.broker.serviceName }} + +{{- range .Values.ownServices }} + {{ $data := dict "Values" $.Values "service" . }} + {{- if has .serviceName $servicesToConfig }} + {{- template "asapo.service" $data }} +--- + {{- end }} +{{- end }} diff --git a/deploy/asapo_helm_chart/asapo/templates/storage.yaml b/deploy/asapo_helm_chart/asapo/templates/storage.yaml index 391c2b4e942d0fc0d733abf48345aa2c032db0f8..3dcd969280d10098c379eb04fa76a8ff85c6a711 100644 --- a/deploy/asapo_helm_chart/asapo/templates/storage.yaml +++ b/deploy/asapo_helm_chart/asapo/templates/storage.yaml @@ -8,7 +8,7 @@ spec: - ReadWriteMany resources: requests: - storage: 5Gi + storage: 3Gi --- apiVersion: v1 kind: PersistentVolumeClaim @@ -20,4 +20,4 @@ spec: - ReadWriteMany resources: requests: - storage: 5Gi \ No newline at end of file + storage: 1Gi \ No newline at end of file diff --git a/deploy/asapo_helm_chart/asapo/values.yaml b/deploy/asapo_helm_chart/asapo/values.yaml index acf26a0b2711b50b0b42c46fec8f7debe372d015..bcd30a3cf5b18b0c901db77d2a517c0bd8877835 100644 --- a/deploy/asapo_helm_chart/asapo/values.yaml +++ b/deploy/asapo_helm_chart/asapo/values.yaml @@ -1,8 +1,29 @@ -authorizer: - replicaCount: 1 +ownServices: + authorizer: + serviceName: asapo-authorizer + replicaCount: 1 + port: 5006 + _exposeServiceExtrernally: false + broker: + serviceName: asapo-broker + replicaCount: 1 + port: 5007 + _exposeServiceExtrernally: true + discovery: + serviceName: asapo-discovery + replicaCount: 1 + port: 5008 + _exposeServiceExtrernally: false common: authSecret: "12ljzgneasfd" offlineDir: "/test_offline" onlineDir: "/test_online" - asapoVersionTag: "develop.20.03-10-g06dc0be" \ No newline at end of file + asapoVersionTag: "develop.20.03-10-g06dc0be" + +influxdb: + authEnabled: false + influxdb: + updateStrategy: Recreate + service: + port: 8086