Skip to content

Commit

Permalink
Merge pull request #22 from holaplex/espi/credentials
Browse files Browse the repository at this point in the history
Hub Credentials Chart and Adjustments to Hub Orgs & Hub Identities
  • Loading branch information
kespinola authored Feb 27, 2023
2 parents fbc51fe + 6c94a52 commit 398109a
Show file tree
Hide file tree
Showing 20 changed files with 363 additions and 10 deletions.
23 changes: 23 additions & 0 deletions charts/hub-credentials/.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/
27 changes: 27 additions & 0 deletions charts/hub-credentials/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v2
name: hub-credentials
description: Helm chart for hub-credentials
maintainers:
- name: Holaplex Engineering
email: [email protected]

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

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "hub-credentials.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "hub-credentials.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
69 changes: 69 additions & 0 deletions charts/hub-credentials/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "hub-credentials.fullname" . }}
labels:
{{- include "hub-credentials.labels" . | nindent 4 }}
app.kubernetes.io/component: api
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "hub-credentials.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: api
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "hub-credentials.selectorLabels" . | nindent 8 }}
app.kubernetes.io/component: api
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "hub-credentials.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: api
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- configMapRef:
name: {{ include "hub-credentials.fullname" . }}
- secretRef:
name: {{ include "hub-credentials.fullname" . }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: http
readinessProbe:
httpGet:
path: /health
port: http
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 }}
10 changes: 10 additions & 0 deletions charts/hub-credentials/templates/environment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "hub-credentials.fullname" . }}
data:
{{- with .Values.environment }}
ORY_ADMIN_BASE_URL: {{ .oryAdminBaseUrl }}
ORY_PUBLIC_BASE_URL: {{ .oryPublicBaseUrl }}
PORT: {{ .port | quote }}
{{- end }}
28 changes: 28 additions & 0 deletions charts/hub-credentials/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 "hub-credentials.fullname" . }}
labels:
{{- include "hub-credentials.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "hub-credentials.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 }}
13 changes: 13 additions & 0 deletions charts/hub-credentials/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- with .Values.secrets }}
{{- if .enabled }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "hub-credentials.fullname" $ }}
annotations:
"helm.sh/hook": pre-install
type: Opaque
data:
ORY_AUTH_TOKEN: {{ .entries.oryAuthToken | b64enc }}
{{- end }}
{{- end }}
17 changes: 17 additions & 0 deletions charts/hub-credentials/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "hub-credentials.fullname" . }}
labels:
{{- include "hub-credentials.labels" . | nindent 4 }}
app.kubernetes.io/component: api
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "hub-credentials.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: api
12 changes: 12 additions & 0 deletions charts/hub-credentials/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 "hub-credentials.serviceAccountName" . }}
labels:
{{- include "hub-credentials.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
{{- end }}
76 changes: 76 additions & 0 deletions charts/hub-credentials/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Default values for hub-credentials.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
repository: holaplex/hub-credentials
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
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: 80

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi

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

nodeSelector: {}

tolerations: []

affinity: {}

secrets:
enabled: true
entries:
oryAuthToken: ""

environment:
port: "80"
oryAdminBaseUrl: "http://hydra-admin:4445"
oryPublicBaseUrl: "http://hydra-public:4444"
2 changes: 1 addition & 1 deletion charts/hub-identities/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ 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
version: 0.2.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
Expand Down
2 changes: 2 additions & 0 deletions charts/hub-identities/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ spec:
envFrom:
- configMapRef:
name: {{ include "hub-identities.fullname" . }}
- secretRef:
name: {{ include "hub-identities.fullname" . }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
Expand Down
2 changes: 1 addition & 1 deletion charts/hub-identities/templates/environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ kind: ConfigMap
metadata:
name: {{ include "hub-identities.fullname" . }}
data:
KRATOS_ADMIN_ENDPOINT: {{ .Values.environment.kratosAdminEndpoint }}
ORY_BASE_URL: {{ .Values.environment.oryBaseUrl }}
PORT: "{{ .Values.environment.port }}"
13 changes: 13 additions & 0 deletions charts/hub-identities/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{- with .Values.secrets }}
{{- if .enabled }}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "hub-identities.fullname" $ }}
annotations:
"helm.sh/hook": pre-install
type: Opaque
data:
ORY_AUTH_TOKEN: {{ .entries.oryAuthToken | b64enc }}
{{- end }}
{{- end }}
Loading

0 comments on commit 398109a

Please sign in to comment.