Skip to content

Commit

Permalink
Merge branch 'feature/image-viewer' into feature/fix-mongodb
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewpeterkort authored Oct 16, 2024
2 parents 0240d6d + c4aaa11 commit 07bd5f0
Show file tree
Hide file tree
Showing 15 changed files with 348 additions and 2 deletions.
4 changes: 4 additions & 0 deletions helm/gen3/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ dependencies:
version: 0.1.0
repository: "file://../image-viewer"
condition: image-viewer.enabled
- name: viv
version: 0.1.0
repository: "file://../viv"
condition: viv.enabled

# A chart can be either an 'application' or a 'library' chart.
#
Expand Down
2 changes: 1 addition & 1 deletion helm/image-viewer/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec:
- "/bin/sh"
- "-c"
- >
uvicorn image_viewer.app:app --host 0.0.0.0 --port 8000 --reload
uvicorn image_viewer.app:app --host 0.0.0.0 --port {{ .Values.service.port }} --reload
{{- with .Values.nodeSelector }}
nodeSelector:
Expand Down
8 changes: 7 additions & 1 deletion helm/image-viewer/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ replicaCount: 1
serviceName: image-viewer-service

image:
repository: gen3-image-viewer
repository: quay.io/ohsu-comp-bio/gen3-image-viewer
pullPolicy: Always
tag: "latest"


imagePullSecrets: []
nameOverride: ""
Expand Down Expand Up @@ -59,3 +61,7 @@ nodeSelector: {}
tolerations: []

affinity: {}

env:
BASE_URL: "/aviator/?image_url="

Check failure on line 67 in helm/image-viewer/values.yaml

View workflow job for this annotation

GitHub Actions / lint-test

67:1 [empty-lines] too many blank lines (1 > 0)
9 changes: 9 additions & 0 deletions helm/revproxy/gen3.nginx.conf/viv-service.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
location /aviator/ {
proxy_connect_timeout 600s;
proxy_send_timeout 600s;
proxy_read_timeout 600s;
send_timeout 600s;

# maintain the /aviator prefix in the proxied request
proxy_pass http://viv-service.$namespace.svc.cluster.local:8000;
}
23 changes: 23 additions & 0 deletions helm/viv/.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/
24 changes: 24 additions & 0 deletions helm/viv/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: viv
description: A Helm chart for Kubernetes

# 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.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
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. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.14.2"
3 changes: 3 additions & 0 deletions helm/viv/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# To get viv to be discoverable to other microservices run the following command

kc expose deployment local-viv
62 changes: 62 additions & 0 deletions helm/viv/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "viv.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 "viv.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 "viv.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "viv.labels" -}}
helm.sh/chart: {{ include "viv.chart" . }}
{{ include "viv.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "viv.selectorLabels" -}}
app.kubernetes.io/name: {{ include "viv.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "viv.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "viv.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
72 changes: 72 additions & 0 deletions helm/viv/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: viv-deployment
labels:
{{- include "viv.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "viv.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "viv.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "viv.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
volumes: []
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /
port: 8000
initialDelaySeconds: 10
periodSeconds: 60
timeoutSeconds: 30
readinessProbe:
httpGet:
path: /
port: 8000
initialDelaySeconds: 10
resources:
{{- toYaml .Values.resources | nindent 12 }}
command:
- "/bin/sh"
- "-c"
- >
pnpm dev --host 0.0.0.0 --port {{ .Values.service.port }} --base /aviator
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
32 changes: 32 additions & 0 deletions helm/viv/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "viv.fullname" . }}
labels:
{{- include "viv.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "viv.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 }}
16 changes: 16 additions & 0 deletions helm/viv/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.serviceName}}
labels:
{{- include "viv.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "viv.selectorLabels" . | nindent 4 }}

12 changes: 12 additions & 0 deletions helm/viv/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "viv.serviceAccountName" . }}
labels:
{{- include "viv.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions helm/viv/templates/tests/test-connection.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "viv.fullname" . }}-test-connection"
labels:
{{- include "viv.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "viv.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never
6 changes: 6 additions & 0 deletions helm/viv/templates/viv-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: viv-values
data:
serviceName: {{ .Values.serviceName | quote }}
62 changes: 62 additions & 0 deletions helm/viv/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Default values for viv.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1
serviceName: viv-service

image:
repository: quay.io/ohsu-comp-bio/viv
pullPolicy: Always
tag: "latest"

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: 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: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
port: 8000

resources:
limits:
cpu: 2.0
memory: 2Gi
requests:
cpu: 0.2
memory: 256Mi

autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

nodeSelector: {}

tolerations: []

affinity: {}

0 comments on commit 07bd5f0

Please sign in to comment.