diff --git a/charts/chris-ui/.helmignore b/charts/chris-ui/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/chris-ui/.helmignore @@ -0,0 +1,23 @@ +# 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 +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/chris-ui/Chart.lock b/charts/chris-ui/Chart.lock new file mode 100644 index 0000000..d7d78db --- /dev/null +++ b/charts/chris-ui/Chart.lock @@ -0,0 +1,6 @@ +dependencies: +- name: util + repository: https://fnndsc.github.io/charts + version: 0.1.0 +digest: sha256:ceee9595de62e5f7c0cbc7df9f7ac03a33b4dd91964c7321b9e849e0f90453f9 +generated: "2024-11-25T14:32:50.21170062-05:00" diff --git a/charts/chris-ui/Chart.yaml b/charts/chris-ui/Chart.yaml new file mode 100644 index 0000000..aa250b7 --- /dev/null +++ b/charts/chris-ui/Chart.yaml @@ -0,0 +1,29 @@ +apiVersion: v2 +name: chris-ui +description: ChRIS user interface +home: https://chrisproject.org +sources: +- https://github.com/FNNDSC/charts +- https://github.com/FNNDSC/ChRIS_ui +keywords: +- medicine +- science +- bioinformatics +- neuroscience +- scientific workflow system +icon: ./logo_chris.png + +type: application +version: 0.1.0-alpha.1 + +appVersion: "36f2dcb" +maintainers: +- name: The FNNDSC Dev Team + email: dev@babyMRI.org + url: https://fnndsc.org + +dependencies: +- name: util + version: "~0.1.0" + repository: "https://fnndsc.github.io/charts" + diff --git a/charts/chris-ui/charts/util b/charts/chris-ui/charts/util new file mode 120000 index 0000000..8b27964 --- /dev/null +++ b/charts/chris-ui/charts/util @@ -0,0 +1 @@ +../../util \ No newline at end of file diff --git a/charts/chris-ui/templates/chrisui.yml b/charts/chris-ui/templates/chrisui.yml new file mode 100644 index 0000000..5c621b3 --- /dev/null +++ b/charts/chris-ui/templates/chrisui.yml @@ -0,0 +1,18 @@ +{{- $env := (dict + "SERVER_PORT" .Values.service.port + "CHRIS_UI_URL" (.Values.cubeUrl | required "cubeUrl is required") + "PFDCM_URL" (.Values.pfdcmUrl | required "pfdcmUrl is required") +) -}} +{{- $optionalEnvNames := (dict + "ohifUrl" "OHIF_URL" + "ackeeServer" "ACKEE_SERVER" + "ackeeDomainId" "ACKEE_DOMAIN_ID" +) -}} +{{- range $k, $v := $optionalEnvNames -}} + {{- $value := (get $.Values $k) -}} + {{- with (get $.Values $k) -}} + {{- $_ := set $env $v . -}} + {{- end -}} +{{- end -}} +{{- $moreValues := (dict "Values" (dict "extraEnv" $env)) -}} +{{- mustMerge $moreValues . | include "util.knativeOrDeployment" -}} diff --git a/charts/chris-ui/values.yaml b/charts/chris-ui/values.yaml new file mode 100644 index 0000000..6a62f69 --- /dev/null +++ b/charts/chris-ui/values.yaml @@ -0,0 +1,187 @@ +# Default values for chris-ui. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +nameOverride: "" +fullnameOverride: "" + +# ChRIS_ui configuration +##################### + +# -- (required) URL of ChRIS backend. +cubeUrl: +# -- (required) URL of PFDCM. +pfdcmUrl: +# -- (optional) URL of OHIF. +ohifUrl: +# -- (optional) URL of Ackee web analytics. +ackeeServer: +# -- (optional) Domain ID for Ackee web analytics. +ackeeDomainId: + +# -- Extra environment variables. +# -- See https://static-web-server.net/configuration/environment-variables/ +extraEnv: + SERVER_HEALTH: true + +# Resource configuration +##################### + +# -- This sets the container image more information can be found here: https://kubernetes.io/docs/concepts/containers/images/ +image: + registry: ghcr.io + repository: fnndsc/chris_ui + # -- This sets the pull policy for images. + pullPolicy: IfNotPresent + # -- Overrides the image tag whose default is the chart appVersion. + tag: "" + +# -- This is for the secrets for pulling an image from a private repository more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] + +# -- This section builds out the service account more information can be found here: https://kubernetes.io/docs/concepts/security/service-accounts/ +serviceAccount: + # Specifies whether a service account should be created + create: false + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: "" + +# -- This is for setting Kubernetes Annotations to a Pod. +# -- For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/ +podAnnotations: {} + +# -- This is for setting Kubernetes Labels to a Pod. +# -- For more information checkout: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + runAsNonRoot: true + seccompProfile: + type: RuntimeDefault + +resources: {} + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +# -- This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/ +# -- Recommended to use the /health endpoint. See https://static-web-server.net/configuration/environment-variables/#server_health +# -- Note: it is recommended to set `extraEnv.SERVER_HEALTH=true` +livenessProbe: + httpGet: + path: /health + port: http +readinessProbe: + httpGet: + path: /health + port: http +startupProbe: + httpGet: + path: /health + port: http + failureThreshold: 60 + periodSeconds: 1 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +# -- Labels for the Deployment/Service resource. +labels: {} + +# -- Annotations for the Deployment/Service resource. +annotations: {} + +# Kind configuration +##################### + +# -- kind must be one of: +# -- +# -- - "Deployment": use (standard) Kubernetes Deployment and Service APIs +# -- - "Service": use the KNative Serving API +kind: Deployment + + +# KNative Serving configuration +##################### + +# -- KNative Serving revision annotations. +# -- Only used with `kind=Service` +revisionAnnotations: {} + # autoscaling.knative.dev/target: "100" + # autoscaling.knative.dev/min-scale: "1" + # autoscaling.knative.dev/max-scale: "3" + # autoscaling.knative.dev/scale-to-zero-pod-retention-period: "1m5s" + + +# Deployment configuration +##################### + +# -- This will set the replicaset count more information can be found here: https://kubernetes.io/docs/concepts/workloads/controllers/replicaset/ +# -- Ignored if `autoscaling.enabled=true` +# -- Only used with `kind=Deployment` +replicaCount: 1 + +# -- This is for setting up a service more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/ +# -- Only used with `kind=Deployment` +service: + # This sets the service type more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types + type: ClusterIP + # This sets the ports more information can be found here: https://kubernetes.io/docs/concepts/services-networking/service/#field-spec-ports + port: 8080 + # nodePort: + +# -- This block is for setting up the ingress for more information can be found here: https://kubernetes.io/docs/concepts/services-networking/ingress/ +# -- Only used with `kind=Deployment` +ingress: + enabled: false + className: "" + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +# -- OpenShift route. +# -- Only used with `kind=Deployment` +route: + enabled: false + host: chart-example.local + tls: + termination: edge + insecureEdgeTerminationPolicy: Redirect + destinationCACertificate: '' + +# -- This section is for setting up autoscaling more information can be found here: https://kubernetes.io/docs/concepts/workloads/autoscaling/ +# -- Only used with `kind=Deployment` +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + diff --git a/charts/util/templates/_deployment.tpl b/charts/util/templates/_deployment.tpl new file mode 100644 index 0000000..ff355f5 --- /dev/null +++ b/charts/util/templates/_deployment.tpl @@ -0,0 +1,38 @@ +{{- define "util.deploymentTpl" }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "util.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "util.labels" . | nindent 4 }} + {{- with .Values.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "util.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "util.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + containers: + {{- include "util.container" (mustMerge (dict "containerName" (include "util.name" .) "portName" "http") .) | nindent 8 }} + {{- include "util.podSpec" . | nindent 6 }} +{{- end }} diff --git a/charts/util/templates/_helpers.tpl b/charts/util/templates/_helpers.tpl index 936eb13..e6ecfb2 100644 --- a/charts/util/templates/_helpers.tpl +++ b/charts/util/templates/_helpers.tpl @@ -62,19 +62,19 @@ Create the name of the service account to use {{- end }} {{- end }} -{{- define "util.image" }} +{{- define "util.image" -}} {{ if .Values.image.registry }}{{ .Values.image.registry }}/{{ end }}{{ .Values.image.repository }}:{{ .Values.image.tag | default .appVersion | default .Chart.AppVersion }} -{{- end }} +{{- end -}} -{{- define "util.podSpec" }} -{{- with (concat .Values.imagePullSecrets .Values.global.imagePullSecrets | mustUniq) }} +{{- define "util.podSpec" -}} +{{- with (concat (.Values.imagePullSecrets | default (list)) ((.Values.global).imagePullSecrets | default (list)) | mustUniq) }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} {{- if (or .Values.serviceAccount.name .Values.serviceAccount.create) }} serviceAccountName: {{ include "util.util.serviceAccountName" . }} {{- end }} -{{- with (.Values.podSecurityContext | deepCopy | mustMergeOverwrite (deepCopy .Values.global.podSecurityContext | default (dict))) }} +{{- with (.Values.podSecurityContext | deepCopy | mustMergeOverwrite (deepCopy ((.Values.global).podSecurityContext | default (dict)))) }} securityContext: {{- toYaml . | nindent 8 }} {{- end }} @@ -90,20 +90,25 @@ affinity: tolerations: {{- toYaml . | nindent 8 }} {{- end }} -{{- end }} +{{- end -}} -{{- define "util.container" }} +{{- define "util.container" -}} - image: {{ include "util.image" . }} + {{- if .containerName }} + name: {{ .containerName }} + {{- end }} {{- if .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }} {{- end }} ports: - - name: http - containerPort: {{ .Values.containerPort | default .Values.service.port }} + - containerPort: {{ .Values.containerPort | default .Values.service.port }} {{- if .Values.hostPort }} hostPort: {{ .Values.hostPort }} {{- end }} protocol: TCP + {{- if .portName }} + name: {{ .portName }} + {{- end }} {{- if .Values.extraEnv }} env: {{- range $k, $v := .Values.extraEnv }} @@ -113,22 +118,22 @@ tolerations: {{- end }} {{- with .Values.securityContext }} securityContext: - {{- toYaml . | nindent 12 }} + {{- toYaml . | nindent 4 }} {{- end }} {{- with .Values.resources }} resources: - {{- toYaml . | nindent 12 }} + {{- toYaml . | nindent 4 }} {{- end }} {{- with .Values.livenessProbe }} livenessProbe: - {{- toYaml . | nindent 12 }} + {{- toYaml . | nindent 4 }} {{- end }} {{- with .Values.readinessProbe }} readinessProbe: - {{- toYaml . | nindent 12 }} + {{- toYaml . | nindent 4 }} {{- end }} {{- with .Values.startupProbe }} startupProbe: - {{- toYaml . | nindent 12 }} + {{- toYaml . | nindent 4 }} {{- end }} -{{- end }} +{{- end -}} diff --git a/charts/util/templates/_hpa.tpl b/charts/util/templates/_hpa.tpl new file mode 100644 index 0000000..6742ec8 --- /dev/null +++ b/charts/util/templates/_hpa.tpl @@ -0,0 +1,35 @@ +{{- define "util.hpaTpl" }} +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "util.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "util.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "util.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/util/templates/_ingress.tpl b/charts/util/templates/_ingress.tpl new file mode 100644 index 0000000..a71dd6f --- /dev/null +++ b/charts/util/templates/_ingress.tpl @@ -0,0 +1,46 @@ +{{- define "util.ingressTpl" }} +{{- if .Values.ingress.enabled -}} +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ include "util.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "util.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- with .Values.ingress.className }} + ingressClassName: {{ . }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- with .pathType }} + pathType: {{ . }} + {{- end }} + backend: + service: + name: {{ include "util.fullname" $ }} + port: + number: {{ $.Values.service.port }} + {{- end }} + {{- end }} +{{- end }} +{{- end }} diff --git a/charts/util/templates/_knative.tpl b/charts/util/templates/_knative.tpl new file mode 100644 index 0000000..b97f315 --- /dev/null +++ b/charts/util/templates/_knative.tpl @@ -0,0 +1,34 @@ +{{- define "util.knativeServiceTpl" }} +apiVersion: serving.knative.dev/v1 +kind: Service +metadata: + name: {{ include "util.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "util.labels" . | nindent 4 }} + {{- with .Values.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .Values.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + template: + metadata: + {{- with .Values.revisionAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.podLabels }} + labels: + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- if .Values.containerConcurrency }} + containerConcurrency: {{ .Values.containerConcurrency }} + {{- end }} + containers: + {{- include "util.container" . | nindent 8 }} + {{- mustMerge (omit . "Values") (dict "Values" (omit .Values "startupProbe")) | include "util.podSpec" | nindent 6 }} +{{- end }} diff --git a/charts/util/templates/_knative_or_deployment.tpl b/charts/util/templates/_knative_or_deployment.tpl new file mode 100644 index 0000000..bcf9f86 --- /dev/null +++ b/charts/util/templates/_knative_or_deployment.tpl @@ -0,0 +1,24 @@ +{{- define "util.knativeOrDeployment" -}} +{{- include "util.serviceAccountTpl" . }} +{{- if (eq .Values.kind "Service") }} +{{- include "util.knativeServiceTpl" . }} +{{- else if (eq .Values.kind "Deployment") }} +{{- include "util.deploymentEverythingTpl" . }} +{{- else }} +{{- fail (printf "Unsupported kind: %s" .kind) }} +{{- end -}} +{{- end -}} + +{{- define "util.deploymentEverythingTpl" }} +{{- include "util.deploymentTpl" . }} +--- +{{- include "util.hpaTpl" . }} +--- +{{- include "util.ingressTpl" . }} +--- +{{- include "util.serviceTpl" . }} +--- +{{- include "util.testServiceConnectionTpl" . }} +--- +{{- include "util.openshiftRouteTpl" . }} +{{- end }} diff --git a/charts/util/templates/_route.tpl b/charts/util/templates/_route.tpl new file mode 100644 index 0000000..e5e3e21 --- /dev/null +++ b/charts/util/templates/_route.tpl @@ -0,0 +1,25 @@ +{{- define "util.openshiftRouteTpl" }} +{{- if .Values.route.enabled -}} +kind: Route +apiVersion: route.openshift.io/v1 +metadata: + name: {{ include "util.fullname" . }} + labels: + {{- include "util.labels" . | nindent 4 }} + {{- with .Values.route.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + to: + kind: Service + name: {{ include "util.fullname" . }} + {{- with .Values.route.tls }} + tls: + {{- toYaml . | nindent 4 }} + {{- end }} + port: + targetPort: http + host: {{ required ".Values.route.host is required." .Values.route.host }} +{{- end }} +{{- end }} diff --git a/charts/util/templates/_service.tpl b/charts/util/templates/_service.tpl new file mode 100644 index 0000000..eeb77e0 --- /dev/null +++ b/charts/util/templates/_service.tpl @@ -0,0 +1,24 @@ +{{- define "util.serviceTpl" }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "util.fullname" . }} + labels: + {{- include "util.labels" . | nindent 4 }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP + name: http + {{- if .Values.service.nodePort }} + nodePort: {{ .Values.service.nodePort }} + {{- end }} + selector: + {{- include "util.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/util/templates/_serviceaccount.tpl b/charts/util/templates/_serviceaccount.tpl new file mode 100644 index 0000000..4813e54 --- /dev/null +++ b/charts/util/templates/_serviceaccount.tpl @@ -0,0 +1,18 @@ +{{- define "util.serviceAccountTpl" }} +{{- if .Values.serviceAccount.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "util.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} + {{- with .labels }} + labels: + {{- .Value.serviceAccount.labels | deepCopy | default (dict) | mustMergeOverwrite (include "util.labels" . | fromYaml) | toYaml | nindent 4 }} + {{- end }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} +{{- end }} diff --git a/charts/util/templates/_test_connection.tpl b/charts/util/templates/_test_connection.tpl new file mode 100644 index 0000000..7aa9bd8 --- /dev/null +++ b/charts/util/templates/_test_connection.tpl @@ -0,0 +1,19 @@ +{{- define "util.testServiceConnectionTpl" }} +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "util.fullname" . }}-test-connection" + labels: + {{- include "util.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: quay.io/prometheus/busybox:latest + command: ['wget'] + args: + - --spider + - http://{{ include "util.fullname" . }}:{{ .Values.service.port }}{{ (.Values.test).path }} + restartPolicy: Never +{{- end }} diff --git a/charts/util/templates/_valueOrLookupOrRandom.tpl b/charts/util/templates/_valueOrLookupOrRandom.tpl new file mode 100644 index 0000000..19f7ea0 --- /dev/null +++ b/charts/util/templates/_valueOrLookupOrRandom.tpl @@ -0,0 +1,25 @@ +{{- /* +Helper function to use a value. If the value is unset, try looking up the previous value +from a secret. If the secret does not exist, generate a random value with a specified length. +*/ -}} +{{- define "util.valueOrLookupOrRandom" -}} +{{- if .value -}} + {{- .value | b64enc | quote -}} +{{- else -}} + {{- $length := .length | default 32 -}} + {{- $name := .name -}} + {{- if (not $name) -}} + {{- fail (printf "util.valueOrLookupOrRandom was not called with required parameter 'name'. Given parameters: %s" (keys .)) -}} + {{- end -}} + {{- with (lookup "v1" "Secret" .root.Release.Namespace .secret) -}} + {{- if (and .data (hasKey .data $name)) -}} + {{- (index .data $name) | quote -}} + {{- else -}} + {{- randAlphaNum $length | b64enc | quote -}} + {{- end -}} + {{- else -}} + {{- randAlphaNum $length | b64enc | quote -}} + {{- end -}} +{{- end -}} +{{- end -}} +