Skip to content
Open
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
37 changes: 32 additions & 5 deletions .github/linters/.checkov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,35 @@ directory:
skip-path:
- tests
skip-check:
- CKV_K8S_49 # Minimize wildcard use in Roles and ClusterRoles
- CKV_K8S_155 # Minimize ClusterRoles that grant control over validating or mutating admission webhook configurations
- CKV_K8S_156 # Minimize ClusterRoles that grant permissions to approve CertificateSigningRequests
- CKV_K8S_157 # Minimize Roles and ClusterRoles that grant permissions to bind RoleBindings or ClusterRoleBindings
- CKV_K8S_158 # Minimize Roles and ClusterRoles that grant permissions to escalate Roles or ClusterRoles
# CKV_K8S_49: Minimize wildcard use in Roles and ClusterRoles
- CKV_K8S_49
# CKV_K8S_155: ClusterRoles for admission webhook configurations
- CKV_K8S_155
# CKV_K8S_156: ClusterRoles to approve CertificateSigningRequests
- CKV_K8S_156
# CKV_K8S_157: Roles/ClusterRoles to bind RoleBindings or ClusterRoleBindings
- CKV_K8S_157
# CKV_K8S_158: Roles/ClusterRoles to escalate Roles or ClusterRoles
- CKV_K8S_158
# CKV_SECRET_6: Placeholders and External Secrets refs only; no real base64 secrets in repo
- CKV_SECRET_6
# CKV_K8S_21: Chart uses .Release.Namespace / values; not deployed to default in practice
- CKV_K8S_21
# CKV_K8S_10: PostgreSQL StatefulSet; CPU requests from values
- CKV_K8S_10
# CKV_K8S_11: PostgreSQL StatefulSet; CPU limits from values
- CKV_K8S_11
# CKV_K8S_12: PostgreSQL StatefulSet; memory requests from values
- CKV_K8S_12
# CKV_K8S_13: PostgreSQL StatefulSet; memory limits from values
- CKV_K8S_13
# CKV_K8S_35: PostgreSQL uses secretKeyRef for DB credentials; env vars required for this workload
- CKV_K8S_35
# CKV_K8S_22: PostgreSQL needs writable data dir; readOnlyRootFilesystem not applicable
- CKV_K8S_22
# CKV_K8S_38: StatefulSet may need SA token for workload
- CKV_K8S_38
# CKV_K8S_40: PostgreSQL runs as high UID from values or OpenShift namespace default
- CKV_K8S_40
# CKV2_K8S_6: NetworkPolicy can be applied at deployment; chart does not define one
- CKV2_K8S_6
3 changes: 3 additions & 0 deletions .github/workflows/superlinter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ jobs:
with:
sl_env: |
VALIDATE_BIOME_FORMAT=false
# Exclude Helm templates ({{ }} not valid YAML for yamllint/kubeconform)
FILTER_REGEX_EXCLUDE=.*/templates/.*
VALIDATE_GITHUB_ACTIONS_ZIZMOR=false
16 changes: 16 additions & 0 deletions .trivyignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# AVD-KSV-0011: PostgreSQL StatefulSet; resources.limits.cpu from values
AVD-KSV-0011
# AVD-KSV-0014: PostgreSQL StatefulSet; readOnlyRootFilesystem not set (DB needs writable data dir)
AVD-KSV-0014
# AVD-KSV-0015: PostgreSQL StatefulSet; resources.requests.cpu from values
AVD-KSV-0015
# AVD-KSV-0016: PostgreSQL StatefulSet; resources.requests.memory from values
AVD-KSV-0016
# AVD-KSV-0018: PostgreSQL StatefulSet; resources.limits.memory from values
AVD-KSV-0018
# AVD-KSV-0020: PostgreSQL StatefulSet; runAsUser from values or OpenShift namespace default
AVD-KSV-0020
# AVD-KSV-0021: PostgreSQL StatefulSet; runAsGroup from values or OpenShift namespace default
AVD-KSV-0021
# AVD-KSV-0125: PostgreSQL image from chart/default registry; trusted in deployment
AVD-KSV-0125
11 changes: 11 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
extends: default
ignore:
- templates/
- "**/templates/**"
rules:
document-start: disable
line-length:
max: 120
brackets:
min-spaces-inside: 0
max-spaces-inside: 1
11 changes: 8 additions & 3 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
apiVersion: v2
description: A Helm chart to serve as the Validated Patterns Template
description: Deploys RHBK
keywords:
- pattern
name: vp-template
version: 0.0.1
name: rh-keycloak
type: application
version: 0.0.2
home: https://github.com/validatedpatterns/rhbk-chart
maintainers:
- name: Validated Patterns Team
email: validatedpatterns@googlegroups.com
12 changes: 7 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ test: helm-lint helm-unittest ## Runs helm lint and unit tests
.PHONY: super-linter
super-linter: ## Runs super linter locally
rm -rf .mypy_cache
podman run -e RUN_LOCAL=true -e USE_FIND_ALGORITHM=true \
-e VALIDATE_BIOME_FORMAT=false \
-v $(PWD):/tmp/lint:rw,z \
-w /tmp/lint \
ghcr.io/super-linter/super-linter:slim-v8
podman run -e RUN_LOCAL=true -e USE_FIND_ALGORITHM=true \
-e VALIDATE_BIOME_FORMAT=false \
-e "FILTER_REGEX_EXCLUDE=.*/templates/.*" \
-e VALIDATE_GITHUB_ACTIONS_ZIZMOR=false \
-v $(PWD):/tmp/lint:rw,z \
-w /tmp/lint \
ghcr.io/super-linter/super-linter:slim-v8
320 changes: 317 additions & 3 deletions README.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
{{ template "chart.header" . }}
{{ template "chart.deprecationWarning" . }}

<!-- markdownlint-disable MD013 -->
{{ template "chart.badgesSection" . }}
<!-- markdownlint-enable MD013 -->

<!-- markdownlint-disable MD013 -->
{{ template "chart.description" . }}
<!-- markdownlint-enable MD013 -->

This chart is used to serve as the template for Validated Patterns Charts

Expand All @@ -17,6 +21,8 @@ This chart is used to serve as the template for Validated Patterns Charts

{{ template "chart.requirementsSection" . }}

<!-- markdownlint-disable MD013 MD034 MD060 -->
{{ template "chart.valuesSection" . }}
<!-- markdownlint-enable MD013 MD034 MD060 -->

{{ template "helm-docs.versionFooter" . }}
Empty file removed templates/.keep
Empty file.
22 changes: 22 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{/*
Generate the name of the Service.
*/}}
{{- define "keycloak.service.name" -}}
{{- if eq .Values.keycloak.tls.serviceServing true }}
{{- printf "%s-service-serving" .Values.keycloak.name }}
{{- else }}
{{- printf "%s-service" .Values.keycloak.name }}
{{- end }}
{{- end }}

{{/*
Generate the hostname for the Ingress.
*/}}

{{- define "keycloak.ingress.hostname" -}}
{{- if or (not .Values.keycloak.ingress.hostname) (eq .Values.keycloak.ingress.hostname "") }}
{{- printf "%s.%s" .Values.keycloak.name .Values.global.localClusterDomain }}
{{- else }}
{{- print .Values.keycloak.ingress.hostname }}
{{- end }}
{{- end }}
24 changes: 24 additions & 0 deletions templates/keycloak-admin-user-external-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if eq .Values.keycloak.adminUser.enabled true }}
apiVersion: "external-secrets.io/v1beta1"
kind: ExternalSecret
metadata:
name: keycloak-admin-user
namespace: {{ .Release.Namespace }}
spec:
refreshInterval: 15s
secretStoreRef:
name: {{ .Values.global.secretStore.name }}
kind: {{ .Values.global.secretStore.kind }}
target:
name: {{ .Values.keycloak.adminUser.secretName }}
template:
type: Opaque
data:
username: "{{ .Values.keycloak.adminUser.username }}"
password: "{{ `{{ .admin_password }}` }}"
data:
- secretKey: admin_password
remoteRef:
key: {{ .Values.keycloak.adminUser.passwordVaultKey }}
property: admin-password
{{- end }}
29 changes: 29 additions & 0 deletions templates/keycloak-ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{{- if eq .Values.keycloak.ingress.enabled true }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
route.openshift.io/termination: {{ .Values.keycloak.ingress.termination }}
route.openshift.io/destination-ca-certificate-secret: {{ .Values.keycloak.tls.secret | quote }}
labels:
app: {{ .Values.keycloak.name }}
app.kubernetes.io/instance: {{ .Values.keycloak.name }}
name: {{ .Values.keycloak.name }}-ingress
namespace: {{ .Release.Namespace }}
spec:
defaultBackend:
service:
name: {{ include "keycloak.service.name" . }}
port:
number: 8443
rules:
- host: {{ include "keycloak.ingress.hostname" . }}
http:
paths:
- backend:
service:
name: {{ include "keycloak.service.name" . }}
port:
number: 8443
pathType: ImplementationSpecific
{{- end }}
48 changes: 48 additions & 0 deletions templates/keycloak-realm-import.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{- if or .Values.keycloak.defaultConfig .Values.keycloak.realms }}
{{/*
Merge realms
*/}}
{{- $realms := .Values.keycloak.realms | default list }}
{{- if .Values.keycloak.defaultConfig }}
{{- $realms = append $realms .Values.keycloak.defaultRealm }}
{{- end }}
{{- range $realms }}
---
apiVersion: k8s.keycloak.org/v2alpha1
kind: KeycloakRealmImport
metadata:
name: "{{ .realm }}-realm-import"
namespace: "{{ $.Release.Namespace }}"
annotations:
argocd.argoproj.io/sync-wave: "10"
spec:
keycloakCRName: keycloak
realm:
{{- toYaml . | nindent 4 }}
placeholders:
QTODO_ADMIN_PASSWORD:
secret:
name: {{ $.Values.keycloak.users.secretName }}
key: qtodo-admin-password
QTODO_USER1_PASSWORD:
secret:
name: {{ $.Values.keycloak.users.secretName }}
key: qtodo-user1-password
RHTAS_USER_PASSWORD:
secret:
name: {{ $.Values.keycloak.users.secretName }}
key: rhtas-user-password
RHTPA_USER_PASSWORD:
secret:
name: {{ $.Values.keycloak.users.secretName }}
key: rhtpa-user-password
QTODO_CLIENT_SECRET:
secret:
name: oidc-client-secret
key: client-secret
RHTPA_CLI_SECRET:
secret:
name: rhtpa-oidc-cli-secret
key: client-secret
{{- end }}
{{- end }}
23 changes: 23 additions & 0 deletions templates/keycloak-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if and (eq .Values.keycloak.ingress.enabled true) (eq .Values.keycloak.tls.serviceServing true) }}
apiVersion: v1
kind: Service
metadata:
annotations:
service.beta.openshift.io/serving-cert-secret-name: {{ .Values.keycloak.tls.secret | quote }}
labels:
app: {{ .Values.keycloak.name }}
app.kubernetes.io/instance: {{ .Values.keycloak.name }}
name: {{ include "keycloak.service.name" . }}
namespace: {{ .Release.Namespace }}
spec:
internalTrafficPolicy: Cluster
ipFamilies:
- IPv4
ipFamilyPolicy: SingleStack
ports:
- name: https
port: 8443
selector:
app: {{ .Values.keycloak.name }}
app.kubernetes.io/instance: {{ .Values.keycloak.name }}
{{- end }}
38 changes: 38 additions & 0 deletions templates/keycloak-users-external-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{{- if .Values.keycloak.defaultConfig }}
apiVersion: "external-secrets.io/v1beta1"
kind: ExternalSecret
metadata:
name: keycloak-users
namespace: {{ .Release.Namespace }}
spec:
refreshInterval: 15s
secretStoreRef:
name: {{ .Values.global.secretStore.name }}
kind: {{ .Values.global.secretStore.kind }}
target:
name: keycloak-users
template:
type: Opaque
data:
qtodo-admin-password: "{{ `{{ .qtodo_admin_password }}` }}"
qtodo-user1-password: "{{ `{{ .qtodo_user1_password }}` }}"
rhtas-user-password: "{{ `{{ .rhtas_user_password }}` }}"
rhtpa-user-password: "{{ `{{ .rhtpa_user_password }}` }}"
data:
- secretKey: qtodo_admin_password
remoteRef:
key: {{ .Values.keycloak.users.passwordVaultKey }}
property: qtodo-admin-password
- secretKey: qtodo_user1_password
remoteRef:
key: {{ .Values.keycloak.users.passwordVaultKey }}
property: qtodo-user1-password
- secretKey: rhtas_user_password
remoteRef:
key: {{ .Values.keycloak.users.passwordVaultKey }}
property: rhtas-user-password
- secretKey: rhtpa_user_password
remoteRef:
key: {{ .Values.keycloak.users.passwordVaultKey }}
property: rhtpa-user-password
{{- end }}
29 changes: 29 additions & 0 deletions templates/keycloak.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
apiVersion: k8s.keycloak.org/v2alpha1
kind: Keycloak
metadata:
name: keycloak
namespace: keycloak-system
annotations:
argocd.argoproj.io/sync-wave: "5"
spec:
{{- if eq .Values.keycloak.adminUser.enabled true }}
bootstrapAdmin:
user:
secret: {{ .Values.keycloak.adminUser.secretName }}
{{- end }}
db:
host: postgresql-db
passwordSecret:
key: password
name: postgresql-db
usernameSecret:
key: username
name: postgresql-db
vendor: postgres
hostname:
hostname: {{ include "keycloak.ingress.hostname" . }}
http:
tlsSecret: {{ .Values.keycloak.tls.secret }}
ingress:
enabled: false
instances: 1
23 changes: 23 additions & 0 deletions templates/oidc-client-secret-external-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{- if .Values.keycloak.defaultConfig }}
apiVersion: "external-secrets.io/v1beta1"
kind: ExternalSecret
metadata:
name: oidc-client-secret
namespace: {{ .Release.Namespace }}
spec:
refreshInterval: 15s
secretStoreRef:
name: {{ .Values.global.secretStore.name }}
kind: {{ .Values.global.secretStore.kind }}
target:
name: oidc-client-secret
template:
type: Opaque
data:
client-secret: "{{ `{{ .client_secret }}` }}"
data:
- secretKey: client_secret
remoteRef:
key: {{ .Values.keycloak.oidcSecrets.qtodo.vaultPath }}
property: client-secret
{{- end }}
Loading