Skip to content

Commit

Permalink
Merge pull request #35 from daystram/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
daystram authored Feb 15, 2021
2 parents 2154b49 + 151b00b commit f220456
Show file tree
Hide file tree
Showing 13 changed files with 606 additions and 16 deletions.
23 changes: 23 additions & 0 deletions .daystram/helm-chart/.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 .daystram/helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: ratify
description: Central Authentication Service implementing OAuth 2.0 and OpenID Connect protocols

# 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: APPLICATION_VERSION

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

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "ratify.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "ratify.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
118 changes: 118 additions & 0 deletions .daystram/helm-chart/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@

apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ratify.fullname" . }}-be
labels:
{{- include "ratify.labels" . | nindent 4 }}
tier: be
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.ratify.be.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "ratify.selectorLabels" . | nindent 6 }}
tier: be
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "ratify.selectorLabels" . | nindent 8 }}
tier: be
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "ratify.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:be-{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- secretRef:
name: {{ .Values.ratify.be.envFrom.secretRef }}
ports:
- name: http
containerPort: 8080
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "ratify.fullname" . }}-fe
labels:
{{- include "ratify.labels" . | nindent 4 }}
tier: fe
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.ratify.fe.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "ratify.selectorLabels" . | nindent 6 }}
tier: fe
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "ratify.selectorLabels" . | nindent 8 }}
tier: fe
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "ratify.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:fe-{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: 80
protocol: TCP
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
28 changes: 28 additions & 0 deletions .daystram/helm-chart/templates/hpa.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "ratify.fullname" . }}
labels:
{{- include "ratify.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "ratify.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 }}
86 changes: 86 additions & 0 deletions .daystram/helm-chart/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
{{- if .Values.ingress.enabled -}}
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: {{ include "ratify.fullname" . }}
labels:
{{- include "ratify.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
entryPoints:
- websecure
routes:
- kind: Rule
match: "Host(`{{ .Values.ingress.host }}`)"
services:
- name: {{ include "ratify.fullname" . }}-fe
passHostHeader: true
port: {{ .Values.service.port }}
middlewares:
- name: gzip
- kind: Rule
match: "Host(`{{ .Values.ingress.host }}`) && PathPrefix(`/api`)"
services:
- name: {{ include "ratify.fullname" . }}-be
passHostHeader: true
port: {{ .Values.service.port }}
- kind: Rule
match: "Host(`{{ .Values.ingress.host }}`) && PathPrefix(`/oauth`)"
services:
- name: {{ include "ratify.fullname" . }}-be
passHostHeader: true
port: {{ .Values.service.port }}
middlewares:
- name: cors
{{- if .Values.ingress.tls }}
tls:
secretName: cert-{{ include "ratify.fullname" . }}
{{- end }}

---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: gzip
spec:
compress: {}

---
apiVersion: traefik.containo.us/v1alpha1
kind: Middleware
metadata:
name: cors
spec:
headers:
accessControlAllowOriginList:
- "*"
accessControlAllowMethods:
- "GET"
- "POST"
accessControlAllowHeaders:
- "Content-Type"
- "Content-Length"
- "Authorization"
- "Origin"
accessControlExposeHeaders:
- "Content-Type"
- "Content-Length"
accessControlAllowCredentials: false
accessControlMaxAge: 120

---
apiVersion: cert-manager.io/v1alpha2
kind: Certificate
metadata:
name: cert-{{ include "ratify.fullname" . }}
spec:
secretName: cert-{{ include "ratify.fullname" . }}
dnsNames:
- {{ .Values.ingress.host }}
issuerRef:
kind: {{ .Values.ingress.certificate.issuerRef.kind }}
name: {{ .Values.ingress.certificate.issuerRef.name }}
{{- end }}
36 changes: 36 additions & 0 deletions .daystram/helm-chart/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "ratify.fullname" . }}-fe
labels:
{{- include "ratify.labels" . | nindent 4 }}
tier: fe
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "ratify.selectorLabels" . | nindent 4 }}
tier: fe

---
apiVersion: v1
kind: Service
metadata:
name: {{ include "ratify.fullname" . }}-be
labels:
{{- include "ratify.labels" . | nindent 4 }}
tier: be
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "ratify.selectorLabels" . | nindent 4 }}
tier: be
12 changes: 12 additions & 0 deletions .daystram/helm-chart/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 "ratify.serviceAccountName" . }}
labels:
{{- include "ratify.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
Loading

0 comments on commit f220456

Please sign in to comment.