diff --git a/.github/ct.yaml b/.github/ct.yaml new file mode 100644 index 00000000..4f94c805 --- /dev/null +++ b/.github/ct.yaml @@ -0,0 +1,3 @@ +helm-extra-args: --timeout 600 +check-version-increment: true +debug: true diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 00000000..2fecbacd --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,29 @@ +name: Lint and Test Charts + +on: + pull_request: + paths: + - "charts/**" + +jobs: + lint-chart: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up chart-testing + uses: helm/chart-testing-action@v2.0.1 + + - name: Run chart-testing (list-changed) + id: list-changed + run: | + changed=$(ct list-changed) + if [[ -n "$changed" ]]; then + echo "::set-output name=changed::true" + fi + + - name: Run chart-testing (lint) + run: ct lint diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..b5009067 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,25 @@ +name: Release Charts + +on: + push: + branches: + - master + paths: + - "charts/**" + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Run chart-releaser + uses: helm/chart-releaser-action@v1.1.0 + env: + CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" diff --git a/charts/fhir-server/.helmignore b/charts/fhir-server/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/fhir-server/.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/fhir-server/Chart.yaml b/charts/fhir-server/Chart.yaml new file mode 100644 index 00000000..349acfb4 --- /dev/null +++ b/charts/fhir-server/Chart.yaml @@ -0,0 +1,20 @@ +apiVersion: v2 +name: fhir-server +description: A Helm chart for deploying the Microsoft FHIR Server for Azure +maintainers: + - name: chgl + url: https://github.com/chgl + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +version: 0.4.0 diff --git a/charts/fhir-server/templates/NOTES.txt b/charts/fhir-server/templates/NOTES.txt new file mode 100644 index 00000000..38c847d4 --- /dev/null +++ b/charts/fhir-server/templates/NOTES.txt @@ -0,0 +1,21 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "fhir-server.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "fhir-server.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "fhir-server.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "fhir-server.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + echo "Visit http://127.0.0.1:8080 to use your application" + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:80 +{{- end }} diff --git a/charts/fhir-server/templates/_helpers.tpl b/charts/fhir-server/templates/_helpers.tpl new file mode 100644 index 00000000..db523289 --- /dev/null +++ b/charts/fhir-server/templates/_helpers.tpl @@ -0,0 +1,71 @@ +{{/* vim: set filetype=mustache: */}} +{{/* +Expand the name of the chart. +*/}} +{{- define "fhir-server.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 "fhir-server.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 "fhir-server.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} +{{- end -}} + +{{/* +Common labels +*/}} +{{- define "fhir-server.labels" -}} +helm.sh/chart: {{ include "fhir-server.chart" . }} +{{ include "fhir-server.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "fhir-server.selectorLabels" -}} +app.kubernetes.io/name: {{ include "fhir-server.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Selector labels for MSSQL +*/}} +{{- define "fhir-server-mssql.selectorLabels" -}} +app.kubernetes.io/name: {{ include "fhir-server.name" . }}-mssql +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "fhir-server.serviceAccountName" -}} +{{- if .Values.serviceAccount.create -}} + {{ default (include "fhir-server.fullname" .) .Values.serviceAccount.name }} +{{- else -}} + {{ default "default" .Values.serviceAccount.name }} +{{- end -}} +{{- end -}} diff --git a/charts/fhir-server/templates/azureidentity.yaml b/charts/fhir-server/templates/azureidentity.yaml new file mode 100644 index 00000000..eda34552 --- /dev/null +++ b/charts/fhir-server/templates/azureidentity.yaml @@ -0,0 +1,12 @@ +{{- if .Values.podIdentity.enabled -}} +apiVersion: "aadpodidentity.k8s.io/v1" +kind: AzureIdentity +metadata: + name: {{ include "fhir-server.fullname" . }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +spec: + type: 0 + resourceID: {{ .Values.podIdentity.identityResourceId }} + clientID: {{ .Values.podIdentity.identityClientId }} +{{- end }} \ No newline at end of file diff --git a/charts/fhir-server/templates/azureidentitybinding.yaml b/charts/fhir-server/templates/azureidentitybinding.yaml new file mode 100644 index 00000000..d398c8dc --- /dev/null +++ b/charts/fhir-server/templates/azureidentitybinding.yaml @@ -0,0 +1,9 @@ +{{- if .Values.podIdentity.enabled -}} +apiVersion: "aadpodidentity.k8s.io/v1" +kind: AzureIdentityBinding +metadata: + name: {{ include "fhir-server.fullname" . }}-binding +spec: + azureIdentity: {{ include "fhir-server.fullname" . }} + selector: {{ include "fhir-server.fullname" . }} +{{- end }} \ No newline at end of file diff --git a/charts/fhir-server/templates/azuresqldatabase.yaml b/charts/fhir-server/templates/azuresqldatabase.yaml new file mode 100644 index 00000000..6545b845 --- /dev/null +++ b/charts/fhir-server/templates/azuresqldatabase.yaml @@ -0,0 +1,14 @@ +{{- if eq .Values.database.dataStore "SqlServer" }} +{{- $fullName := include "fhir-server.fullname" . -}} +apiVersion: azure.microsoft.com/v1beta1 +kind: AzureSqlDatabase +metadata: + name: {{ $fullName }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +spec: + location: {{ .Values.database.location }} + resourceGroup: {{ .Values.database.resourceGroup }} + edition: {{ .Values.database.sql.edition }} + server: {{ $fullName }} +{{- end }} \ No newline at end of file diff --git a/charts/fhir-server/templates/azuresqlfirewallrule.yaml b/charts/fhir-server/templates/azuresqlfirewallrule.yaml new file mode 100644 index 00000000..a95b8796 --- /dev/null +++ b/charts/fhir-server/templates/azuresqlfirewallrule.yaml @@ -0,0 +1,16 @@ +{{- if eq .Values.database.dataStore "SqlServer" }} +{{- $fullName := include "fhir-server.fullname" . -}} +apiVersion: azure.microsoft.com/v1beta1 +kind: AzureSqlFirewallRule +metadata: + name: {{ $fullName }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +spec: + resourceGroup: {{ .Values.database.resourceGroup }} + server: {{ $fullName }} + + # this IP range enables Azure Service access + startIpAddress: 0.0.0.0 + endIpAddress: 0.0.0.0 +{{- end }} \ No newline at end of file diff --git a/charts/fhir-server/templates/azuresqlserver.yaml b/charts/fhir-server/templates/azuresqlserver.yaml new file mode 100644 index 00000000..15e3e95b --- /dev/null +++ b/charts/fhir-server/templates/azuresqlserver.yaml @@ -0,0 +1,12 @@ +{{- if eq .Values.database.dataStore "SqlServer" }} +{{- $fullName := include "fhir-server.fullname" . -}} +apiVersion: azure.microsoft.com/v1beta1 +kind: AzureSqlServer +metadata: + name: {{ $fullName }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +spec: + location: {{ .Values.database.location }} + resourceGroup: {{ .Values.database.resourceGroup }} +{{- end }} \ No newline at end of file diff --git a/charts/fhir-server/templates/cosmosdb.yaml b/charts/fhir-server/templates/cosmosdb.yaml new file mode 100644 index 00000000..31a34837 --- /dev/null +++ b/charts/fhir-server/templates/cosmosdb.yaml @@ -0,0 +1,14 @@ +{{- if eq .Values.database.dataStore "CosmosDb" }} +{{- $fullName := include "fhir-server.fullname" . -}} +apiVersion: azure.microsoft.com/v1alpha1 +kind: CosmosDB +metadata: + name: {{ $fullName }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +spec: + location: {{ .Values.database.location }} + resourceGroup: {{ .Values.database.resourceGroup }} + properties: + databaseAccountOfferType: Standard +{{- end }} \ No newline at end of file diff --git a/charts/fhir-server/templates/deployment.yaml b/charts/fhir-server/templates/deployment.yaml new file mode 100644 index 00000000..70795b70 --- /dev/null +++ b/charts/fhir-server/templates/deployment.yaml @@ -0,0 +1,215 @@ +{{- $fullName := include "fhir-server.fullname" . -}} +{{- $dbservicename := printf "%s-mssql" $fullName }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "fhir-server.fullname" . }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + {{- include "fhir-server.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "fhir-server.selectorLabels" . | nindent 8 }} + {{- if .Values.podIdentity.enabled }} + aadpodidbinding: {{ include "fhir-server.fullname" . }} + {{- end}} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: ASPNETCORE_FORWARDEDHEADERS_ENABLED + value: "true" + {{- if .Values.export.enabled }} + - name: FhirServer__Operations__Export__Enabled + value: "true" + - name: FhirServer__Operations__Export__StorageAccountUri + value: {{ .Values.export.blobStorageUri | quote }} + {{- end }} + {{- if .Values.serviceMonitor.enabled }} + - name: PrometheusMetrics__enabled + value: "true" + - name: PrometheusMetrics__port + value: {{ .Values.serviceMonitor.port | quote }} + - name: PrometheusMetrics__dotnetRuntimeMetrics + value: {{ .Values.serviceMonitor.dotnetRuntimeMetrics | quote }} + - name: PrometheusMetrics__httpMetrics + value: {{ .Values.serviceMonitor.httpMetrics | quote }} + - name: PrometheusMetrics__systemMetrics + value: {{ .Values.serviceMonitor.systemMetrics | quote }} + {{- end }} + {{- if .Values.appInsights.secretName }} + - name: ApplicationInsights__InstrumentationKey + valueFrom: + secretKeyRef: + name: {{ .Values.appInsights.secretName }} + key: {{ .Values.appInsights.secretKey }} + {{- end }} + - name: FhirServer__Security__Enabled + value: {{ .Values.security.enabled | quote }} + - name: FhirServer__Security__EnableAadSmartOnFhirProxy + value: {{ .Values.security.enableAadSmartOnFhirProxy | quote }} + {{- if .Values.security.authority }} + - name: FhirServer__Security__Authentication__Authority + value: {{ .Values.security.authority | lower | quote }} + {{- end }} + {{- if .Values.security.audience }} + - name: FhirServer__Security__Authentication__Audience + value: {{ .Values.security.audience | lower | quote }} + {{- end }} + {{- if eq .Values.database.dataStore "SqlServer" }} + - name: DataStore + value: "SqlServer" + - name: SqlServer__AllowDatabaseCreation + value: "true" + - name: SqlServer__Initialize + value: "true" + - name: SqlServer__SchemaOptions__AutomaticUpdatesEnabled + value: {{ .Values.database.sql.schema.automaticUpdatesEnabled | quote }} + - name: DATABASESERVERNAME + valueFrom: + secretKeyRef: + name: {{ include "fhir-server.fullname" . }} + key: fullyQualifiedServerName + - name: DATABASEUSERNAME + valueFrom: + secretKeyRef: + name: {{ include "fhir-server.fullname" . }} + key: username + - name: DATABASEPASSWORD + valueFrom: + secretKeyRef: + name: {{ include "fhir-server.fullname" . }} + key: password + - name: DATABASENAME + value: {{ include "fhir-server.fullname" . }} + - name: MAX_POOL_SIZE + value: {{ .Values.database.sql.maxPoolSize | quote }} + - name: SqlServer__ConnectionString + value: "Server=tcp:$(DATABASESERVERNAME),1433;Initial Catalog=$(DATABASENAME);Persist Security Info=False;User ID=$(DATABASEUSERNAME);Password=$(DATABASEPASSWORD);MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;Max Pool Size=$(MAX_POOL_SIZE)" + {{- end }} + {{- if eq .Values.database.dataStore "SqlContainer" }} + - name: DataStore + value: "SqlServer" + - name: SqlServer__AllowDatabaseCreation + value: "true" + - name: SqlServer__Initialize + value: "true" + - name: SqlServer__SchemaOptions__AutomaticUpdatesEnabled + value: {{ .Values.database.sql.schema.automaticUpdatesEnabled | quote }} + - name: DATABASEUSERNAME + value: {{ .Values.database.sqlContainer.userName }} + - name: DATABASEPASSWORD + valueFrom: + secretKeyRef: + name: {{ $dbservicename }} + key: sapassword + - name: DATABASENAME + value: {{ .Values.database.sqlContainer.databaseName }} + - name: DATABASESERVERNAME + value: {{ $dbservicename }} + - name: SqlServer__ConnectionString + value: "Server=tcp:$(DATABASESERVERNAME),1433;Initial Catalog=$(DATABASENAME);Persist Security Info=False;User ID=$(DATABASEUSERNAME);Password=$(DATABASEPASSWORD);MultipleActiveResultSets=False;Connection Timeout=30" + {{- end }} + {{- if eq .Values.database.dataStore "ExistingSqlServer" }} + - name: DataStore + value: "SqlServer" + - name: SqlServer__AllowDatabaseCreation + value: "true" + - name: SqlServer__Initialize + value: "true" + - name: SqlServer__SchemaOptions__AutomaticUpdatesEnabled + value: {{ .Values.database.sql.schema.automaticUpdatesEnabled | quote }} + - name: DATABASEUSERNAME + value: {{ .Values.database.existingSqlServer.userName }} + - name: DATABASEPASSWORD + valueFrom: + secretKeyRef: + {{- if .Values.database.existingSqlServer.existingSecret }} + name: {{ .Values.database.existingSqlServer.existingSecret }} + key: DATABASEPASSWORD + {{- else }} + name: {{ include "fhir-server.fullname" . }}-existing-mssql + key: DATABASEPASSWORD + {{- end }} + - name: DATABASENAME + value: {{ .Values.database.existingSqlServer.databaseName }} + - name: DATABASESERVERNAME + value: {{ .Values.database.existingSqlServer.serverName }} + - name: DATABASESERVERPORT + value: {{ .Values.database.existingSqlServer.port | quote }} + - name: SqlServer__ConnectionString + value: "Server=tcp:$(DATABASESERVERNAME),$(DATABASESERVERPORT);Initial Catalog=$(DATABASENAME);Persist Security Info=False;User ID=$(DATABASEUSERNAME);Password=$(DATABASEPASSWORD);MultipleActiveResultSets=False;Connection Timeout=30" + {{- end }} + {{- if eq .Values.database.dataStore "CosmosDb" }} + - name: DataStore + value: "CosmosDb" + - name: CosmosDb__Host + valueFrom: + secretKeyRef: + name: {{ include "fhir-server.fullname" . }} + key: primaryEndpoint + - name: CosmosDb__Key + valueFrom: + secretKeyRef: + name: {{ include "fhir-server.fullname" . }} + key: primaryMasterKey + - name: FhirServer__CosmosDb__InitialCollectionThroughput + value: {{ .Values.database.cosmosDb.initialCollectionThroughput | quote }} + {{- if .Values.database.cosmosDb.databaseId }} + - name: CosmosDb__DatabaseId + value: {{ .Values.database.cosmosDb.databaseId }} + {{- end }} + {{- if .Values.database.cosmosDb.collectionId }} + - name: FhirServer__CosmosDb__CollectionId + value: {{ .Values.database.cosmosDb.collectionId }} + {{- end }} + {{- end }} + ports: + - name: http + containerPort: 8080 + protocol: TCP + - name: metrics + containerPort: {{ .Values.serviceMonitor.port }} + protocol: TCP + livenessProbe: + httpGet: + path: /health/check + port: http + failureThreshold: 12 + periodSeconds: 20 + timeoutSeconds: 10 + readinessProbe: + httpGet: + path: /health/check + port: http + timeoutSeconds: 10 + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/fhir-server/templates/existingsqlserversecret.yaml b/charts/fhir-server/templates/existingsqlserversecret.yaml new file mode 100644 index 00000000..170dac31 --- /dev/null +++ b/charts/fhir-server/templates/existingsqlserversecret.yaml @@ -0,0 +1,11 @@ +{{- if and (eq .Values.database.dataStore "ExistingSqlServer") (not .Values.database.existingSqlServer.existingSecret) }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "fhir-server.fullname" . }}-existing-mssql + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +type: Opaque +data: + DATABASEPASSWORD: {{ .Values.database.existingSqlServer.password | b64enc | quote}} +{{- end }} diff --git a/charts/fhir-server/templates/ingress.yaml b/charts/fhir-server/templates/ingress.yaml new file mode 100644 index 00000000..de64f3c8 --- /dev/null +++ b/charts/fhir-server/templates/ingress.yaml @@ -0,0 +1,54 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "fhir-server.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion }} +apiVersion: networking.k8s.io/v1beta1 +{{ else }} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: +{{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} +{{- end }} + rules: + {{- range .Values.ingress.hosts }} + {{- $pathType := .pathType }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ . }} + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + pathType: {{ $pathType | default "ImplementationSpecific" }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{ else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/charts/fhir-server/templates/metricsservice.yaml b/charts/fhir-server/templates/metricsservice.yaml new file mode 100644 index 00000000..76b3048c --- /dev/null +++ b/charts/fhir-server/templates/metricsservice.yaml @@ -0,0 +1,17 @@ +{{- if .Values.serviceMonitor.enabled }} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fhir-server.fullname" . }}-metrics + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: {{ .Values.serviceMonitor.port }} + targetPort: {{ .Values.serviceMonitor.port }} + protocol: TCP + name: metrics + selector: + {{- include "fhir-server.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/fhir-server/templates/service.yaml b/charts/fhir-server/templates/service.yaml new file mode 100644 index 00000000..e2a73d20 --- /dev/null +++ b/charts/fhir-server/templates/service.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "fhir-server.fullname" . }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.service.port }} + targetPort: 8080 + protocol: TCP + name: http + selector: + {{- include "fhir-server.selectorLabels" . | nindent 4 }} diff --git a/charts/fhir-server/templates/servicemonitor.yaml b/charts/fhir-server/templates/servicemonitor.yaml new file mode 100644 index 00000000..b6995349 --- /dev/null +++ b/charts/fhir-server/templates/servicemonitor.yaml @@ -0,0 +1,18 @@ +{{- if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "fhir-server.fullname" . }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} + {{- with .Values.serviceMonitor.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + endpoints: + - port: metrics + interval: {{ .Values.serviceMonitor.interval }} + selector: + matchLabels: + {{- include "fhir-server.selectorLabels" . | nindent 6 }} +{{- end }} \ No newline at end of file diff --git a/charts/fhir-server/templates/sqlcontainerdeployment.yaml b/charts/fhir-server/templates/sqlcontainerdeployment.yaml new file mode 100644 index 00000000..4227c16e --- /dev/null +++ b/charts/fhir-server/templates/sqlcontainerdeployment.yaml @@ -0,0 +1,67 @@ +{{- if eq .Values.database.dataStore "SqlContainer" }} +{{- $fullName := include "fhir-server.fullname" . -}} +{{- $dbservicename := printf "%s-mssql" $fullName }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ $dbservicename }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +spec: + replicas: {{ .Values.database.sqlContainer.replicaCount }} + selector: + matchLabels: + {{- include "fhir-server-mssql.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "fhir-server-mssql.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + automountServiceAccountToken: false + securityContext: + {{- toYaml .Values.database.sqlContainer.podSecurityContext | nindent 8 }} + containers: + - name: mssql + securityContext: + {{- toYaml .Values.database.sqlContainer.securityContext | nindent 12 }} + image: "{{ .Values.database.sqlContainer.image.registry }}/{{ .Values.database.sqlContainer.image.repository }}:{{ .Values.database.sqlContainer.image.tag }}" + imagePullPolicy: {{ .Values.database.sqlContainer.image.pullPolicy }} + env: + - name: MSSQL_PID + value: {{ .Values.database.sqlContainer.edition | quote }} + - name: ACCEPT_EULA + value: {{ .Values.database.sqlContainer.acceptEula | upper | quote }} + - name: SA_PASSWORD + valueFrom: + secretKeyRef: + name: {{ $dbservicename }} + key: sapassword + ports: + - containerPort: 1433 + protocol: TCP + resources: + {{- toYaml .Values.database.sqlContainer.resources | nindent 12 }} + volumeMounts: + - name: mssqldb + mountPath: /var/opt/mssql + volumes: + - name: mssqldb + persistentVolumeClaim: + claimName: {{ $dbservicename }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} +{{- end }} diff --git a/charts/fhir-server/templates/sqlcontainerpvc.yaml b/charts/fhir-server/templates/sqlcontainerpvc.yaml new file mode 100644 index 00000000..1d472ff5 --- /dev/null +++ b/charts/fhir-server/templates/sqlcontainerpvc.yaml @@ -0,0 +1,21 @@ +{{- if eq .Values.database.dataStore "SqlContainer" }} +{{- $fullName := include "fhir-server.fullname" . -}} +{{- $dbservicename := printf "%s-mssql" $fullName }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ $dbservicename }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} + {{- with .Values.database.sqlContainer.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + storageClassName: {{ .Values.database.sqlContainer.persistence.storageClass }} + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.database.sqlContainer.persistence.size }} +{{- end }} \ No newline at end of file diff --git a/charts/fhir-server/templates/sqlcontainersecret.yaml b/charts/fhir-server/templates/sqlcontainersecret.yaml new file mode 100644 index 00000000..643814bc --- /dev/null +++ b/charts/fhir-server/templates/sqlcontainersecret.yaml @@ -0,0 +1,13 @@ +{{- if eq .Values.database.dataStore "SqlContainer" }} +{{- $fullName := include "fhir-server.fullname" . -}} +{{- $dbservicename := printf "%s-mssql" $fullName }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ $dbservicename }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +type: Opaque +data: + sapassword: {{ randAlphaNum 20 | b64enc | quote }} +{{- end }} \ No newline at end of file diff --git a/charts/fhir-server/templates/sqlcontainerservice.yaml b/charts/fhir-server/templates/sqlcontainerservice.yaml new file mode 100644 index 00000000..169e67d2 --- /dev/null +++ b/charts/fhir-server/templates/sqlcontainerservice.yaml @@ -0,0 +1,18 @@ +{{- if eq .Values.database.dataStore "SqlContainer" }} +{{- $fullName := include "fhir-server.fullname" . -}} +{{- $dbservicename := printf "%s-mssql" $fullName }} +apiVersion: v1 +kind: Service +metadata: + name: {{ $dbservicename }} + labels: + {{- include "fhir-server.labels" . | nindent 4 }} +spec: + type: ClusterIP + ports: + - port: {{ .Values.database.sqlContainer.port }} + targetPort: 1433 + protocol: TCP + selector: + {{- include "fhir-server-mssql.selectorLabels" . | nindent 4 }} +{{- end }} diff --git a/charts/fhir-server/values.yaml b/charts/fhir-server/values.yaml new file mode 100644 index 00000000..47047a6f --- /dev/null +++ b/charts/fhir-server/values.yaml @@ -0,0 +1,149 @@ +# Default values for fhir-server. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + registry: healthplatformregistry.azurecr.io + repository: r4_fhir-server + tag: 1.0.732 + pullPolicy: IfNotPresent + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +podIdentity: + enabled: false + # identityClientId: my-id + # identityResourceId: my-identity-resource-id + +export: + enabled: false + blobStorageUri: https://mystorageaccount.blob.core.windows.net + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + port: 80 + +database: + # options: ExistingSqlServer, SqlServer, SqlContainer, CosmosDb + dataStore: "SqlServer" + resourceGroup: "" + location: "" + sql: + # 0: Basic + # 1: Business + # 2: BusinessCritical + # 3: DataWarehouse + # 4: Free + # 5: GeneralPurpose + # 6: Hyperscale + # 7: Premium + # More at https://godoc.org/github.com/Azure/azure-sdk-for-go/services/preview/sql/mgmt/2015-05-01-preview/sql#DatabaseEdition + edition: 5 + maxPoolSize: 100 + schema: + automaticUpdatesEnabled: false + cosmosDb: + initialCollectionThroughput: "400" + # databaseId: health + # collectionId: fhir + sqlContainer: + # Accept EULA when deploying with --set database.sqlContainer.acceptEula="Y" + acceptEula: "n" + edition: "Developer" + image: + registry: mcr.microsoft.com + repository: mssql/server + tag: 2019-latest + pullPolicy: IfNotPresent + replicaCount: 1 + port: 1433 + databaseName: FHIR + userName: sa + resources: {} + persistence: + storageClass: default + size: 8Gi + annotations: {} + # "helm.sh/resource-policy": keep + securityContext: {} + podSecurityContext: + # mssql container has user mssql defined with id 10001 + runAsUser: 10001 + runAsGroup: 10001 + fsGroup: 10001 + existingSqlServer: + userName: sa + databaseName: FHIR + serverName: mymssql-mssql-linux.default + password: fhir + # name of a pre-created secret to retrieve the SQL Server's password. + # the secret must have a key named `DATABASEPASSWORD` with the password as its value. + existingSecret: "" + port: 1433 + +appInsights: + secretKey: "instrumentationKey" +# secretName: "cluster-app-insights" + +serviceMonitor: + enabled: false + port: 1234 + labels: {} + # prometheus: monitor + interval: 30s + dotnetRuntimeMetrics: true + httpMetrics: true + systemMetrics: true + +security: + enabled: false + enableAadSmartOnFhirProxy: false + authority: null + audience: null + +ingress: + enabled: false + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: ["/"] + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +nodeSelector: {} + +tolerations: [] + +affinity: {}