Skip to content

Commit

Permalink
chore(chart/simpaas): add swagger-ui (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
leroyguillaume authored Jul 20, 2024
1 parent c92cae2 commit 4e6b89c
Show file tree
Hide file tree
Showing 5 changed files with 172 additions and 2 deletions.
16 changes: 16 additions & 0 deletions charts/simpaas/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,19 @@ app.kubernetes.io/name: {{ include "simpaas.smtp.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: smtp
{{- end }}

{{- define "simpaas.swaggerUi.labels" -}}
{{ include "simpaas.labels" . }}
app.kubernetes.io/version: {{ .Values.swaggerUi.image.tag }}
{{ include "simpaas.swaggerUi.selectorLabels" . }}
{{- end }}

{{- define "simpaas.swaggerUi.name" -}}
{{ printf "%s-swagger-ui" .Release.Name | trunc 63 | trimSuffix "-" }}
{{- end -}}

{{- define "simpaas.swaggerUi.selectorLabels" -}}
app.kubernetes.io/name: {{ include "simpaas.swaggerUi.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: swagger-ui
{{- end }}
3 changes: 2 additions & 1 deletion charts/simpaas/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
{{- $tlsHosts := list -}}
{{- $apiIngress := dict "Ingress" .Values.api.ingress "Service" (dict "Name" (include "simpaas.api.name" .) "Port" .Values.api.port) "Values" .Values -}}
{{- $webappIngress := dict "Ingress" .Values.webapp.ingress "Service" (dict "Name" (include "simpaas.webapp.name" .) "Port" .Values.webapp.port) "Values" .Values -}}
{{- $ingresses := list $apiIngress $webappIngress -}}
{{- $swaggerUiIngress := dict "Ingress" .Values.swaggerUi.ingress "Service" (dict "Name" (include "simpaas.swaggerUi.name" .) "Port" .Values.swaggerUi.port) "Values" .Values -}}
{{- $ingresses := list $apiIngress $webappIngress $swaggerUiIngress -}}
{{- range $ingress := $ingresses -}}
{{- if $ingress.Ingress.enabled -}}
{{- $fqdn := include "simpaas.fqdn" $ingress -}}
Expand Down
95 changes: 95 additions & 0 deletions charts/simpaas/templates/swagger-ui/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{{- if .Values.swaggerUi.enabled }}
{{- $podAnnotations := merge .Values.common.podAnnotations .Values.swaggerUi.podAnnotations -}}
{{- $podLabels := merge .Values.common.podLabels .Values.swaggerUi.podLabels -}}
{{- $imagePullSecrets := concat .Values.common.imagePullSecrets .Values.swaggerUi.imagePullSecrets -}}
{{- $podSecurityContext := merge .Values.common.podSecurityContext .Values.swaggerUi.podSecurityContext -}}
{{- $securityContext := merge .Values.common.securityContext .Values.swaggerUi.securityContext -}}
{{- $env := concat .Values.common.env .Values.swaggerUi.env -}}
{{- $volumeMounts := concat .Values.common.volumeMounts .Values.swaggerUi.volumeMounts -}}
{{- $volumes := concat .Values.common.volumes .Values.swaggerUi.volumes -}}
{{- $nodeSelector := merge .Values.common.nodeSelector .Values.swaggerUi.nodeSelector -}}
{{- $affinity := merge .Values.common.affinity .Values.swaggerUi.affinity -}}
{{- $tolerations := concat .Values.common.tolerations .Values.swaggerUi.tolerations -}}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "simpaas.swaggerUi.name" . }}
labels:
{{- include "simpaas.swaggerUi.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.swaggerUi.replicas }}
selector:
matchLabels:
{{- include "simpaas.swaggerUi.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with $podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "simpaas.swaggerUi.labels" . | nindent 8 }}
{{- with $podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with $imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "simpaas.serviceAccountName" . }}
securityContext:
{{- toYaml $podSecurityContext | nindent 8 }}
containers:
- name: swagger-ui
securityContext:
{{- toYaml $securityContext | nindent 12 }}
image: {{ printf "%s:%s" .Values.swaggerUi.image.repository .Values.swaggerUi.image.tag }}
imagePullPolicy: {{ default .Values.common.image.pullPolicy .Values.swaggerUi.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.swaggerUi.port }}
protocol: TCP
{{- with .Values.swaggerUi.livenessProbe }}
livenessProbe:
{{ toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.swaggerUi.readinessProbe }}
readinessProbe:
{{ toYaml . | nindent 10 }}
{{- end }}
env:
- name: BASE_URL
value: {{ .Values.swaggerUi.ingress.path }}
{{- if and .Values.ingress.create .Values.api.ingress.enabled }}
{{- $apiFqdn := include "simpaas.fqdn" (dict "Ingress" .Values.api.ingress "Values" .Values) }}
{{- $protocol := .Values.api.ingress.tls | ternary "https" "http" }}
- name: SWAGGER_JSON_URL
value: {{ printf "%s://%s%s/_doc" $protocol $apiFqdn .Values.api.ingress.path }}
{{- end }}
{{- with $env }}
{{- toYaml . | nindent 8 }}
{{- end }}
resources:
{{- toYaml .Values.swaggerUi.resources | nindent 10 }}
{{- with $volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $volumes }}
volumes:
{{- toYaml . | nindent 6 }}
{{- end }}
{{- with $nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with $tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
16 changes: 16 additions & 0 deletions charts/simpaas/templates/swagger-ui/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{{- if .Values.swaggerUi.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "simpaas.swaggerUi.name" . }}
labels:
{{- include "simpaas.swaggerUi.labels" . | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: {{ .Values.swaggerUi.port }}
targetPort: {{ .Values.swaggerUi.port }}
protocol: TCP
selector:
{{- include "simpaas.swaggerUi.selectorLabels" . | nindent 4 }}
{{- end }}
44 changes: 43 additions & 1 deletion charts/simpaas/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ webapp:
pathType: ImplementationSpecific

ingress:
create: false
create: true
className: ~
domain: ~
tlsSecretName: ~
Expand Down Expand Up @@ -219,3 +219,45 @@ smtp:

livenessProbe: {}
readinessProbe: {}

swaggerUi:
enabled: true

replicas: 1

image:
repository: swaggerapi/swagger-ui
tag: v5.17.14
imagePullSecrets: []

podAnnotations: {}
podLabels: {}

podSecurityContext: {}
securityContext: {}

env: []

resoures: {}

volumeMounts: []
volumes: []

nodeSelector: {}

affinity: {}

tolerations: []

port: 8080

livenessProbe: {}
readinessProbe: {}

ingress:
enabled: true
domain: ~
fqdn: ~
tls: false
path: /swagger-ui
pathType: ImplementationSpecific

0 comments on commit 4e6b89c

Please sign in to comment.