diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..79b892e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.tgz +*.lock diff --git a/charts/DurpAPI/Chart.yaml b/charts/DurpAPI/Chart.yaml new file mode 100644 index 0000000..125884d --- /dev/null +++ b/charts/DurpAPI/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v2 +name: DurpAPI +description: A Helm chart for Kubernetes +type: application + +version: 0.1.0 +appVersion: "0.1.0" +dependencies: + - name: postgresql + version: 12.5.* + repository: https://charts.bitnami.com/bitnami diff --git a/charts/DurpAPI/templates/deployments/api.yaml b/charts/DurpAPI/templates/deployments/api.yaml new file mode 100644 index 0000000..c88d434 --- /dev/null +++ b/charts/DurpAPI/templates/deployments/api.yaml @@ -0,0 +1,38 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + namespace: {{ .Chart.Name }} + name: {{ .Chart.Name }} + labels: + app: {{ .Chart.Name }} +spec: + selector: + matchLabels: + app: {{ .Chart.Name }} + replicas: {{ .Values.deployment.hpa.minReplicas }} + template: + metadata: + labels: + app: {{ .Chart.Name }} + spec: + containers: + - name: api + image: "{{ .Values.deployment.image }}:{{ default .Chart.Version .Values.deployment.tag }}" + imagePullPolicy: {{ .Values.deployment.imagePullPolicy }} + readinessProbe: + {{- toYaml .Values.deployment.probe.readiness | nindent 12 }} + livenessProbe: + {{- toYaml .Values.deployment.probe.liveness | nindent 12 }} + startupProbe: + {{- toYaml .Values.deployment.probe.startup | nindent 12 }} + ports: + - name: http + containerPort: {{ .Values.service.targetport }} + env: + - name: host + value: {{ .Values.swagger.host }} + - name: version + value: {{ default .Chart.Version .Values.deployment.tag }} + envFrom: + - secretRef: + name: {{ .Values.deployment.secretfile }} \ No newline at end of file diff --git a/charts/DurpAPI/templates/hpa/api.yaml b/charts/DurpAPI/templates/hpa/api.yaml new file mode 100644 index 0000000..68d484d --- /dev/null +++ b/charts/DurpAPI/templates/hpa/api.yaml @@ -0,0 +1,24 @@ +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: "{{ .Chart.Name }}-hpa" +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ .Chart.Name }} + minReplicas: {{ .Values.deployment.hpa.minReplicas }} + maxReplicas: {{ .Values.deployment.hpa.maxReplicas }} + metrics: + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: 80 + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 40 diff --git a/charts/DurpAPI/templates/ingress/api.yaml b/charts/DurpAPI/templates/ingress/api.yaml new file mode 100644 index 0000000..f1d077a --- /dev/null +++ b/charts/DurpAPI/templates/ingress/api.yaml @@ -0,0 +1,37 @@ +{{ if .Values.ingress.enabled }} +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: "{{ .Chart.Name }}-ingress" +spec: + entryPoints: + - websecure + routes: + - match: Host("{{ .Values.ingress.host }}") && PathPrefix(`/`) + middlewares: + - name: authentik-proxy-provider + namespace: traefik + kind: Rule + services: + - name: "{{ .Chart.Name }}-service" + port: {{ .Values.service.port }} + tls: + secretName: {{ .Values.ingress.tls }} +{{ end }} + +--- + +{{ if .Values.ingress.enabled }} +apiVersion: cert-manager.io/v1 +kind: Certificate +metadata: + name: {{ .Values.ingress.tls }} +spec: + secretName: {{ .Values.ingress.tls }} + issuerRef: + name: {{ .Values.ingress.clusterissuer }} + kind: ClusterIssuer + commonName: {{ .Values.ingress.host }} + dnsNames: + - {{ .Values.ingress.host }} +{{ end }} \ No newline at end of file diff --git a/charts/DurpAPI/templates/service/api.yaml b/charts/DurpAPI/templates/service/api.yaml new file mode 100644 index 0000000..396498f --- /dev/null +++ b/charts/DurpAPI/templates/service/api.yaml @@ -0,0 +1,12 @@ +apiVersion: v1 +kind: Service +metadata: + name: "{{ .Chart.Name }}-service" +spec: + ports: + - name: http + port: {{ .Values.service.port }} + targetPort: {{ .Values.service.targetport }} + protocol: TCP + selector: + app: {{ .Chart.Name }} \ No newline at end of file diff --git a/charts/DurpAPI/values.yaml b/charts/DurpAPI/values.yaml new file mode 100644 index 0000000..1c787a4 --- /dev/null +++ b/charts/DurpAPI/values.yaml @@ -0,0 +1,35 @@ +deployment: + image: registry.gitlab.com/developerdurp/durpapi + tag: "" + imagePullPolicy: Always + secretfile: durpapi-secret + hpa: + minReplicas: 3 + maxReplicas: 10 + probe: + readiness: + httpGet: + path: /api/health/getHealth + port: 8080 + liveness: + httpGet: + path: /api/health/getHealth + port: 8080 + startup: + httpGet: + path: /api/health/getHealth + port: 8080 + +ingress: + enabled: false + clusterissuer: letsencrypt-production + host: durpapi.durp.info + tls: durpapi-tls + +service: + type: ClusterIP + port: 80 + targetport: 8080 + +swagger: + host: api.durp.info/durpapi \ No newline at end of file