Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #16 from digitalis-io/resources
Browse files Browse the repository at this point in the history
Adds HPA and support for local https sites (adding the parameter jsonNoCheckCertificate (true/false) to the values.yaml)
  • Loading branch information
SellamiRami authored Oct 20, 2021
2 parents 7cf6f25 + d205a59 commit e46ca44
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
apiVersion: v2
name: swaggerui
version: 0.3.2
version: 0.3.3
appVersion: 3.24.3
description: Swagger is an open-source software framework backed by a large ecosystem of tools that helps developers design, build, document, and consume RESTful Web services.
keywords:
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ The following table lists the configurable parameters of the swagger-ui chart an
| **Deployment** |
| `deployment.replicas` | Number of replicas | `1` |
| `deployment.extraEnv` | Additional environment variable | `` |
| `deployment.jsonNoCheckCertificate` | Enable/Disable certificate check | `false` |
| **Service** |
| `service.type` | Type of service for swagger-ui frontend | `NodePort` |
| `service.port` | Port to expose service | `8080` |
Expand Down Expand Up @@ -100,4 +101,4 @@ Please read the official [Contribution Guide](https:/helm/charts/blo

## License

[Apache License 2.0](/LICENSE.md)
[Apache License 2.0](/LICENSE.md)
11 changes: 9 additions & 2 deletions templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ spec:
name: swagger-config
{{ else }}
command: ["/bin/sh","-c"]
args : {{ (printf "[\"mkdir /api-doc && wget %s -O /api-doc/openapi.json && apk update && apk add jq && jq '.servers += [{\\\"url\\\":\\\"%s\\\",\\\"description\\\":\\\"%s\\\"}]' /api-doc/openapi.json > json.tmp && mv json.tmp /api-doc/openapi.json && /usr/share/nginx/run.sh\"]" .Values.swaggerui.jsonUrl .Values.swaggerui.server.url .Values.swaggerui.server.description ) }} {{ end }}
{{- if .Values.deployment.jsonNoCheckCertificate }}
args : {{ (printf "[\"mkdir /api-doc && wget --no-check-certificate %s -O /api-doc/openapi.json && apk update && apk add jq && jq '.servers += [{\\\"url\\\":\\\"%s\\\",\\\"description\\\":\\\"%s\\\"}]' /api-doc/openapi.json > json.tmp && mv json.tmp /api-doc/openapi.json && /usr/share/nginx/run.sh\"]" .Values.swaggerui.jsonUrl .Values.swaggerui.server.url .Values.swaggerui.server.description ) }}
{{- else }}
args : {{ (printf "[\"mkdir /api-doc && wget %s -O /api-doc/openapi.json && apk update && apk add jq && jq '.servers += [{\\\"url\\\":\\\"%s\\\",\\\"description\\\":\\\"%s\\\"}]' /api-doc/openapi.json > json.tmp && mv json.tmp /api-doc/openapi.json && /usr/share/nginx/run.sh\"]" .Values.swaggerui.jsonUrl .Values.swaggerui.server.url .Values.swaggerui.server.description ) }}
{{- end }}
{{- end }}
env:
{{- with .Values.deployment.extraEnv }}
{{- toYaml . | nindent 10 }}
Expand All @@ -48,6 +53,8 @@ spec:
- name: http
containerPort: 8080
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- if .Values.swaggerui.jsonPath }}
volumes:
- name: swagger-config
Expand All @@ -56,4 +63,4 @@ spec:
items:
- key: conf.json
path: openapi.json
{{ end }}
{{ end }}
31 changes: 31 additions & 0 deletions templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "swagger-ui.fullname" . }}
labels:
app: {{ template "swagger-ui.name" . }}
chart: {{ template "swagger-ui.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "swagger-ui.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ swaggerui :
##
deployment:
replicas: 1
jsonNoCheckCertificate: false
extraEnv:
# - name: BASE_URL
# value: /swagger
Expand Down Expand Up @@ -79,6 +80,13 @@ livenessProbe:
periodSeconds: 30
timeoutSeconds: 10

autoscaling:
enabled: true
minReplicas: 1
maxReplicas: 10
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80

## Configure resource requests and limits
## ref: http://kubernetes.io/docs/user-guide/compute-resources/
##
Expand Down

0 comments on commit e46ca44

Please sign in to comment.