Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,12 @@
.vscode/

go.work.sum
/dist
/.ext
dist/
.ext/
.dev/

# Helm package
scim-*.*.*.tgz

# Helm subpackages
helm/scim/charts/*.tgz
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ checksum:

snapshot:
# https://goreleaser.com/customization/snapshots/
name_template: "{{ .Tag }}"
name_template: "{{ incpatch .Version }}-{{ .ShortCommit }}{{ if .IsGitDirty }}-dirty{{ end }}"

source:
# https://goreleaser.com/customization/source/
Expand Down Expand Up @@ -112,4 +112,4 @@ docker_manifests:
- name_template: "{{ .Env.REGISTRY }}/{{ .Env.ORG }}/{{ .Env.REPO }}:{{ .Major }}.{{ .Minor }}"
image_templates: [*amd64-image, *arm64-image]
- name_template: "{{ .Env.REGISTRY }}/{{ .Env.ORG }}/{{ .Env.REPO }}:{{ .Major }}.{{ .Minor }}.{{ .Patch }}"
image_templates: [*amd64-image, *arm64-image]
image_templates: [*amd64-image, *arm64-image]
6 changes: 6 additions & 0 deletions helm/scim/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: aserto-lib
repository: oci://ghcr.io/aserto-dev/helm
version: 0.1.0
digest: sha256:2378cc51bcf35172c7909d0355ae43379fe4fa590d398551773ec93d1ff63947
generated: "2024-07-01T17:06:41.654882-04:00"
34 changes: 34 additions & 0 deletions helm/scim/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: v2
name: scim
description: A Helm chart for the Aserto SCIM Gateway
icon: https://www.aserto.com/images/aserto-logo.png

maintainers:
- name: Aserto
url: https://github.com/aserto-dev

# 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.0.6"

dependencies:
- name: aserto-lib
version: "0.1.0"
repository: oci://ghcr.io/aserto-dev/helm
22 changes: 22 additions & 0 deletions helm/scim/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "scim.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "scim.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "scim.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "scim.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export HTTPS_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
export GRPC_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[1].containerPort}")
echo "gRPC Service exposed on http://127.0.0.1:8282"
echo "REST Service exposed on http://127.0.0.1:8383"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8282:$GRPC_PORT 8383:$HTTPS_PORT
{{- end }}
66 changes: 66 additions & 0 deletions helm/scim/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "scim.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 "scim.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 "scim.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

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

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

{{/*
Create the name of the service account to use
*/}}
{{- define "scim.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "scim.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{- define "scim.port" -}}
{{ .Values.port | default "8080" }}
{{- end }}
14 changes: 14 additions & 0 deletions helm/scim/templates/api_keys.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
{{- $cfg := .Values.auth -}}
{{- $data := (lookup "v1" "Secret" $.Release.Namespace $cfg.secretName).data }}
apiVersion: v1
kind: Secret
type: opaque
metadata:
name: {{ $cfg.secretName }}
stringData:
{{- if $data }}
{{ $cfg.secretKey }}: {{ $data.secretKey }}
{{- else }}
{{ $cfg.secretKey }}: {{ randAlphaNum 20 }}
{{- end }}
41 changes: 41 additions & 0 deletions helm/scim/templates/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
apiVersion: v1
type: opaque
kind: Secret
metadata:
name: {{ include "scim.fullname" . }}-config
labels:
{{- include "scim.labels" . | nindent 4 }}
stringData:
config.yaml: |
---
logging:
prod: true
log_level: {{ .Values.log_level | default "info" }}

server:
listen_address: ":{{ include "scim.port" . }}"
certs:
tls_key_path: '/https-certs/tls.key'
tls_cert_path: '/https-certs/tls.crt'
tls_ca_cert_path: '/https-certs/ca.crt'
auth:
basic:
enabled: {{ .Values.auth.basic.enabled | default "true" }}
username: {{ .Values.auth.basic.username | default "scim" }}
bearer:
enabled: {{ .Values.auth.bearer.enabled | default "true" }}
directory:
{{- include "aserto-lib.rootDirectoryClient" . | nindent 6 }}
scim:
create_email_identities: {{ .Values.createEmailIdentities }}
create_role_groups: {{ .Values.createRoleGroups }}
user_object_type: {{ .Values.userObjectType }}
identity_object_type: {{ .Values.identityObjectType }}
identity_relation: {{ .Values.identityRelation }}
group_object_type: {{ .Values.groupObjectType }}
group_member_relation: {{ .Values.groupMemberRelation }}
group_mappings:
{{- .Values.groupMappings | toYaml | nindent 8 }}
user_mappings:
{{- .Values.userMappings | toYaml | nindent 8 }}
114 changes: 114 additions & 0 deletions helm/scim/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "scim.fullname" . }}
labels:
{{- include "scim.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "scim.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "scim.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "scim.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
volumes:
- name: config
secret:
secretName: {{ include "scim.fullname" . }}-config
items:
- key: config.yaml
path: config.yaml
- name: https-certs
{{- with (include "aserto-lib.httpsConfig" . | fromYaml) }}
{{- if .certSecret }}
secret:
secretName: {{ .certSecret }}
{{- else }}
emptyDir: {}
{{- end }}
{{- end }}

{{- with (include "aserto-lib.rootDirectoryCfg" . | fromYaml) }}
{{- if .grpcCertSecret }}
- name: root-ds-grpc-certs
secret:
secretName: {{ .grpcCertSecret }}
items:
- key: ca.crt
path: ca.crt
{{- end }}
{{- end }}

containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
args: ["run", "--config", "/config/config.yaml"]
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: https
containerPort: {{ include "scim.port" . }}
volumeMounts:
- name: config
mountPath: /config
readOnly: true
- name: https-certs
mountPath: /https-certs
{{- if (include "aserto-lib.httpsConfig" . | fromYaml).certSecret }}
readOnly: true
{{- end }}

{{- if (include "aserto-lib.rootDirectoryCfg" . | fromYaml).grpcCertSecret }}
- name: root-ds-grpc-certs
mountPath: /root-ds-grpc-certs
readOnly: true
{{- end }}
env:
- name: ASERTO_SCIM_SERVER_AUTH_BASIC_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.auth.secretName }}
key: {{ .Values.auth.secretKey }}
- name: ASERTO_SCIM_SERVER_AUTH_BEARER_TOKEN
valueFrom:
secretKeyRef:
name: {{ .Values.auth.secretName }}
key: {{ .Values.auth.secretKey }}
{{- with (include "aserto-lib.rootDirectoryApiKey" . | fromYaml) }}
- name: ASERTO_SCIM_DIRECTORY_API_KEY
valueFrom:
secretKeyRef:
name: {{ .secretName }}
key: {{ .secretKey }}
{{- end }}
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 helm/scim/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 "scim.fullname" . }}
labels:
{{- include "scim.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "scim.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 }}
Loading