Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More options #1

Merged
merged 2 commits into from
Nov 19, 2024
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ Create a new namespace:
kubectl create ns trustify
```

Use it as default:

```bash
kubectl config set-context --current --namespace=trustify
```

Install the infrastructure services:

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ spec:
if [[ -n "$ID" || "$ID" == "[]" ]]; then
kcadm update "users/$ID" -r "${REALM}" -s enabled=true
else
kcadm create users -r "${REALM}" -s "username=${CHICKEN_ADMIN}" -s enabled=true
kcadm create users -r "${REALM}" -s "username=${CHICKEN_ADMIN}" -s enabled=true -s [email protected] -s emailVerified=true -s firstName=Admin -s lastName=Admin
fi

# set role
Expand Down
2 changes: 1 addition & 1 deletion charts/trustify/templates/helpers/_common.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ Byte-size as a string value.
Arguments: int or string
*/}}
{{- define "trustification.common.byteSizeValue" }}
{{ . | quote }}
{{- . | quote }}
{{- end }}
72 changes: 62 additions & 10 deletions charts/trustify/templates/helpers/_storage.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,98 @@ Arguments (dict):
* module - module object
*/}}
{{ define "trustification.storage.envVars" -}}
{{- if .module.storage}}
{{- if .module.storage }}
{{- include "_trustification.storage.envVars" ( set (deepCopy .) "storage" .module.storage ) }}
{{- else }}
{{- include "_trustification.storage.envVars" ( set (deepCopy .) "storage" .root.Values.storage ) }}
{{- end }}
{{- end }}

{{/* Internal: env-vars for the evaluated storage */}}
{{ define "_trustification.storage.envVars"}}
{{- if .storage.filessytem }}

{{- include "_trustification.storage.common.envVars" ( set (deepCopy .) "storage" .storage ) }}

{{- if .storage.filesystem }}
{{- include "_trustification.storage.filesystem.envVars" ( set (deepCopy .) "storage" .storage.filesystem ) }}
{{- else if .storage.s3 }}
{{- include "_trustification.storage.s3.envVars" ( set (deepCopy .) "storage" .storage.s3 ) }}
{{- else }}
{{- fail "Storage must either be set to .filesystem or .s3" }}
{{- end }}
{{- end }}

{{/* common storage configuration */}}
{{- define "_trustification.storage.common.envVars" -}}
{{- with .storage.compression }}
- name: TRUSTD_STORAGE_COMPRESSION
value: {{ . | quote }}
{{- end }}
{{- end }}

{{/* filesystem storage configuration */}}
{{- define "_trustification.storage.s3.envVars" -}}
{{- define "_trustification.storage.filesystem.envVars" -}}
- name: TRUSTD_STORAGE_STRATEGY
value: fs

- name: TRUSTD_STORAGE_FS_PATH
value: /data/storage
{{- end }}

{{/* S3 storage configuration */}}
{{- define "_trustification.storage.s3.envVars" -}}

- name: STORAGE_ACCESS_KEY
{{- include "trustification.common.envVarValue" .storage.accessKey | nindent 2 }}
- name: TRUSTD_STORAGE_STRATEGY
value: s3

- name: STORAGE_SECRET_KEY
- name: TRUSTD_S3_ACCESS_KEY
{{- include "trustification.common.envVarValue" .storage.accessKey | nindent 2 }}
- name: TRUSTD_S3_SECRET_KEY
{{- include "trustification.common.envVarValue" .storage.secretKey | nindent 2 }}

{{ if .storage.endpoint }}
- name: STORAGE_ENDPOINT
- name: TRUSTD_S3_ENDPOINT
value: {{ .storage.endpoint | quote }}
- name: STORAGE_REGION
- name: TRUSTD_S3_REGION
value: "eu-west-1" # just a dummy value
{{ else }}
- name: STORAGE_REGION
- name: TRUSTD_S3_REGION
value: "{{ .storage.region }}"
{{ end }}

- name: STORAGE_BUCKET
- name: TRUSTD_S3_BUCKET
value: {{ .storage.bucket | quote }}

{{- end }}

{{/*
Volume mounts for the filesystem storage.

Arguments (dict):
* root - .
* module - module object
*/}}
{{- define "trustification.storage.volumeMount" }}
{{ $storage := .module.storage | default .root.Values.storage }}
{{- if $storage.filesystem }}
- name: storage
mountPath: /data/storage
{{- end }}
{{- end }}

{{/*
Volume for the filesystem storage.

Arguments (dict):
* root - .
* name - name of the service
* module - module object
*/}}
{{- define "trustification.storage.volume" }}
{{ $storage := .module.storage | default .root.Values.storage }}
{{- if $storage.filesystem }}
- name: storage
persistentVolumeClaim:
claimName: {{ include "trustification.common.name" ( set (deepCopy .) "name" "storage" ) }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{- if and .Values.modules.server.enabled }}
{{- $res := dict "root" . "name" "storage" -}}

{{- if .Values.storage }}
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: {{ include "trustification.common.name" $res }}
labels:
{{- include "trustification.common.labels" $res | nindent 4 }}

spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: {{ include "trustification.common.byteSizeValue" .Values.storage.filesystem.size }}

{{- with .Values.storage.filesystem.storageClassName }}
storageClassName: {{ . | quote }}
{{- end }}

{{- end }}

{{- end }}
20 changes: 18 additions & 2 deletions charts/trustify/templates/services/server/030-Deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ spec:
- api
- --auth-configuration
- "/etc/config/auth.yaml"
- --working-dir
- "/data/workdir"

env:

Expand All @@ -56,9 +58,17 @@ spec:
- name: UI_CLIENT_ID
value: {{ include "trustification.oidc.frontendClientId" . }}

{{/* FIXME: adapt env-var */}}
{{- with $mod.module.analyticsWriteKey }}
- name: UI_ANALYTICS_WRITE_KEY
value: {{ . | quote }}
{{- end }}

{{- with $mod.module.uploadLimit }}
- name: PUBLISH_LIMIT
- name: TRUSTD_SBOM_UPLOAD_LIMIT
value: {{ include "trustification.common.byteSizeValue" . }}
- name: TRUSTD_ADVISORY_UPLOAD_LIMIT
value: {{ include "trustification.common.byteSizeValue" . }}
- name: TRUSTD_DATASET_ENTRY_LIMIT
value: {{ include "trustification.common.byteSizeValue" . }}
{{- end }}

Expand All @@ -75,13 +85,19 @@ spec:
protocol: TCP

volumeMounts:
- name: workdir
mountPath: /data/workdir
{{- include "trustification.application.httpServerVolumesMounts" $mod | nindent 12 }}
{{- include "trustification.authenticator.volumeMount" $mod | nindent 12 }}
{{- include "trustification.storage.volumeMount" $mod | nindent 12 }}
{{- include "trustification.application.extraVolumeMounts" $mod | nindent 12 }}

volumes:
- name: workdir
emptyDir: {}
{{- include "trustification.application.httpServerVolumes" $mod | nindent 8 }}
{{- include "trustification.authenticator.volume" $mod | nindent 8 }}
{{- include "trustification.storage.volume" $mod | nindent 8 }}
{{- include "trustification.application.extraVolumes" $mod | nindent 8 }}

{{ end }}
21 changes: 20 additions & 1 deletion charts/trustify/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@
"port": {
"type": "integer",
"description": "Port on which infrastructure services are exposed.\n"
},
"initialDelaySeconds": {
"type": "integer",
"minimum": 0,
"description": "The initial delay seconds for the infrastructure probes.\n"
}
}
},
Expand Down Expand Up @@ -167,6 +172,17 @@
},
{
"$ref": "#/definitions/Postgres"
},
{
"type": "object",
"properties": {
"analyticsWriteKey": {
"type": "string"
},
"uploadLimit": {
"$ref": "#/definitions/ByteSize"
}
}
}
]
},
Expand Down Expand Up @@ -701,7 +717,10 @@
],
"properties": {
"size": {
"$ref": "#/definitions/ByteSize"
"$ref": "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.29.0/_definitions.json#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity"
},
"storageClassName": {
"type": "string"
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions charts/trustify/values.schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ properties:
- $ref: "#/definitions/Tracing"
- $ref: "#/definitions/HttpApplication"
- $ref: "#/definitions/Postgres"
- type: object
properties:
analyticsWriteKey:
type: string
uploadLimit:
$ref: "#/definitions/ByteSize"

createDatabase:
description: |
Expand Down Expand Up @@ -553,7 +559,9 @@ definitions:
- size
properties:
size:
$ref: "#/definitions/ByteSize"
$ref: "https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/v1.29.0/_definitions.json#/definitions/io.k8s.apimachinery.pkg.api.resource.Quantity"
storageClassName:
type: string

S3StorageConfig:
type: object
Expand Down Expand Up @@ -659,4 +667,3 @@ definitions:
$ref: "#/definitions/ByteSize"
jsonLimit:
$ref: "#/definitions/ByteSize"

2 changes: 1 addition & 1 deletion values-minikube.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ tracing: { }

storage:
filesystem:
size: 32GiB
size: 32Gi

database:
host: infrastructure-postgresql
Expand Down