Skip to content

Commit

Permalink
Merge pull request #1 from chgl/add-ci
Browse files Browse the repository at this point in the history
added fhir-server and GH actions
  • Loading branch information
chgl authored Dec 15, 2020
2 parents b38a843 + 136b15b commit bd4233d
Show file tree
Hide file tree
Showing 24 changed files with 867 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/ct.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
helm-extra-args: --timeout 600
check-version-increment: true
debug: true
29 changes: 29 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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/[email protected]

- 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
25 changes: 25 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -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 "[email protected]"
- name: Run chart-releaser
uses: helm/[email protected]
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
23 changes: 23 additions & 0 deletions charts/fhir-server/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
20 changes: 20 additions & 0 deletions charts/fhir-server/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions charts/fhir-server/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -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 }}
71 changes: 71 additions & 0 deletions charts/fhir-server/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -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 -}}
12 changes: 12 additions & 0 deletions charts/fhir-server/templates/azureidentity.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
9 changes: 9 additions & 0 deletions charts/fhir-server/templates/azureidentitybinding.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
14 changes: 14 additions & 0 deletions charts/fhir-server/templates/azuresqldatabase.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
16 changes: 16 additions & 0 deletions charts/fhir-server/templates/azuresqlfirewallrule.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
12 changes: 12 additions & 0 deletions charts/fhir-server/templates/azuresqlserver.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
14 changes: 14 additions & 0 deletions charts/fhir-server/templates/cosmosdb.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Loading

0 comments on commit bd4233d

Please sign in to comment.