-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add secrets to sessions (#3591)
* wip: charts for secrets storage * add platform init script * fix init container mount, add helm hook * fix dockerfile * comment secret storage for now * update secrets storage chart * update deploy action * docs: add placeholder page for secrets documentation * wip: charts for secrets storage (#3585) * wip: charts for secrets storage * add platform init script * fix init container mount, add helm hook * fix dockerfile * comment secret storage for now * update secrets storage chart * update deploy action * fix secret mount * fix env var name --------- Co-authored-by: Ralf Grubenmann <[email protected]> * add network policy to allow notebooks access to secrets svc * fix deploy action * add secrets-storage values * fix secrets-storage rbac * add network policy for sidecar to data svc * Update changelog * Address some comments * change secrets generation, remove unneeded secret * remove leftover reference --------- Co-authored-by: Mohammad Alisafaee <[email protected]> Co-authored-by: Ralf Grubenmann <[email protected]>
- Loading branch information
Showing
18 changed files
with
670 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
helm-chart/renku/templates/secrets-storage/deployment.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: {{ template "renku.fullname" . }}-secrets-storage | ||
labels: | ||
app: renku-secrets-storage | ||
chart: {{ template "renku.chart" . }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
spec: | ||
{{- if not .Values.secretsStorage.autoscaling.enabled }} | ||
replicas: {{ .Values.secretsStorage.replicaCount }} | ||
{{- end }} | ||
strategy: | ||
{{- toYaml .Values.secretsStorage.updateStrategy | nindent 4 }} | ||
selector: | ||
matchLabels: | ||
app: renku-secrets-storage | ||
release: {{ .Release.Name }} | ||
template: | ||
metadata: | ||
labels: | ||
app: renku-secrets-storage | ||
release: {{ .Release.Name }} | ||
{{- with .Values.secretsStorage.podAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 8 }} | ||
{{- end }} | ||
spec: | ||
securityContext: | ||
{{- toYaml .Values.podSecurityContext | nindent 8 }} | ||
automountServiceAccountToken: {{ .Values.global.debug }} | ||
initContainers: | ||
{{- include "certificates.initContainer" . | nindent 8 }} | ||
containers: | ||
- name: secrets-storage | ||
image: "{{ .Values.secretsStorage.image.repository }}:{{ .Values.secretsStorage.image.tag }}" | ||
imagePullPolicy: {{ .Values.secretsStorage.image.pullPolicy }} | ||
securityContext: | ||
{{- toYaml .Values.securityContext | nindent 12 }} | ||
ports: | ||
- name: http | ||
containerPort: 8000 | ||
protocol: TCP | ||
env: | ||
- name: VERSION | ||
value: {{ .Values.secretsStorage.image.tag | quote }} | ||
- name: DB_HOST | ||
value: {{ template "postgresql.fullname" . }} | ||
- name: DB_USER | ||
value: {{ .Values.global.db.common.username }} | ||
- name: DB_PASSWORD | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ .Values.global.db.common.passwordSecretName }} | ||
key: password | ||
- name: KEYCLOAK_URL | ||
value: {{ (printf "%s://%s/auth/" (include "renku.http" .) .Values.global.renku.domain) | quote }} | ||
- name: KEYCLOAK_TOKEN_SIGNATURE_ALGS | ||
value: "RS256" | ||
- name: KEYCLOAK_CLIENT_ID | ||
value: {{ include "renku.dataService.keycloak.clientId" . | quote }} | ||
- name: KEYCLOAK_CLIENT_SECRET | ||
valueFrom: | ||
secretKeyRef: | ||
name: {{ include "renku.fullname" . }} | ||
key: dataServiceKeycloakClientSecret | ||
- name: SECRETS_SERVICE_PRIVATE_KEY_PATH | ||
value: /secrets/privateKey/privateKey | ||
{{- include "certificates.env.python" $ | nindent 12 }} | ||
livenessProbe: | ||
httpGet: | ||
path: /api/secrets/version | ||
port: http | ||
initialDelaySeconds: 10 | ||
periodSeconds: 10 | ||
failureThreshold: 6 | ||
readinessProbe: | ||
httpGet: | ||
path: /api/secrets/version | ||
port: http | ||
initialDelaySeconds: 10 | ||
periodSeconds: 2 | ||
failureThreshold: 2 | ||
startupProbe: | ||
httpGet: | ||
path: /api/secrets/version | ||
port: http | ||
periodSeconds: 5 | ||
failureThreshold: 60 | ||
resources: | ||
{{ toYaml .Values.secretsStorage.resources | nindent 12 }} | ||
volumeMounts: | ||
- mountPath: "/secrets/privateKey" | ||
name: secret-service-private-key | ||
readOnly: true | ||
{{- include "certificates.volumeMounts.system" . | nindent 12 }} | ||
volumes: | ||
- name: secret-service-private-key | ||
secret: | ||
secretName: {{ template "renku.fullname" . }}-secret-service-private-key | ||
items: | ||
- key: privateKey | ||
path: privateKey | ||
{{- include "certificates.volumes" . | nindent 8 }} | ||
{{- with .Values.secretsStorage.nodeSelector }} | ||
nodeSelector: | ||
{{ toYaml . | nindent 8 }} | ||
{{- end }} | ||
serviceAccountName: {{ template "renku.fullname" . }}-secrets-storage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{{- if .Values.secretsStorage.autoscaling.enabled }} | ||
{{- if semverCompare ">=1.23.0-0" .Capabilities.KubeVersion.GitVersion -}} | ||
apiVersion: autoscaling/v2 | ||
{{- else -}} | ||
apiVersion: autoscaling/v2beta2 | ||
{{- end }} | ||
kind: HorizontalPodAutoscaler | ||
metadata: | ||
name: {{ template "renku.fullname" . }}-secrets-storage | ||
labels: | ||
app: renku-secrets-storage | ||
chart: {{ template "renku.chart" . }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
spec: | ||
scaleTargetRef: | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
name: {{ template "renku.fullname" . }}-secrets-storage | ||
minReplicas: {{ .Values.secretsStorage.autoscaling.minReplicas }} | ||
maxReplicas: {{ .Values.secretsStorage.autoscaling.maxReplicas }} | ||
metrics: | ||
{{- if .Values.secretsStorage.autoscaling.targetCPUUtilizationPercentage }} | ||
- type: Resource | ||
resource: | ||
name: cpu | ||
target: | ||
type: Utilization | ||
averageUtilization: {{ .Values.secretsStorage.autoscaling.targetCPUUtilizationPercentage }} | ||
{{- end }} | ||
{{- if .Values.secretsStorage.autoscaling.targetMemoryUtilizationPercentage }} | ||
- type: Resource | ||
resource: | ||
name: memory | ||
target: | ||
type: Utilization | ||
averageUtilization: {{ .Values.secretsStorage.autoscaling.targetMemoryUtilizationPercentage }} | ||
{{- end }} | ||
{{- end }} |
22 changes: 22 additions & 0 deletions
22
helm-chart/renku/templates/secrets-storage/network-policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: {{ template "renku.fullname" . }}-secrets-storage | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
app: {{ template "renku.fullname" . }}-secrets-storage | ||
release: {{ .Release.Name }} | ||
policyTypes: | ||
- Ingress | ||
ingress: | ||
- from: | ||
# Only allow ingress to secrets storage from notebooks | ||
- podSelector: | ||
matchLabels: | ||
app: {{ template "renku.notebooks.name" . }} | ||
release: {{ .Release.Name }} | ||
ports: | ||
- protocol: TCP | ||
port: http | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{{- if or (gt (int .Values.secretsStorage.replicaCount) 1) (and .Values.secretsStorage.autoscaling.enabled (gt (int .Values.secretsStorage.autoscaling.minReplicas) 1)) }} | ||
apiVersion: policy/v1 | ||
kind: PodDisruptionBudget | ||
metadata: | ||
name: {{ template "renku.fullname" . }}-secrets-storage | ||
labels: | ||
app: renku-secrets-storage | ||
chart: {{ template "renku.chart" . }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
spec: | ||
minAvailable: 50% | ||
selector: | ||
matchLabels: | ||
app: renku-secrets-storage | ||
release: {{ .Release.Name }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{{- $namespaces := list -}} | ||
{{ if .Values.notebooks.sessionsNamespace }} | ||
{{- $namespaces = list .Release.Namespace .Values.notebooks.sessionsNamespace | uniq -}} | ||
{{ else }} | ||
{{- $namespaces = list .Release.Namespace -}} | ||
{{ end }} | ||
{{ range $namespaces }} | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ template "renku.fullname" $ }}-secrets-storage | ||
namespace: {{ . }} | ||
labels: | ||
app: {{ template "renku.name" $ }} | ||
chart: {{ template "renku.chart" $ }} | ||
release: {{ $.Release.Name }} | ||
heritage: {{ $.Release.Service }} | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- secrets | ||
verbs: | ||
- create | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ template "renku.fullname" $ }}-secrets-storage | ||
labels: | ||
app: {{ template "renku.name" $ }} | ||
chart: {{ template "renku.chart" $ }} | ||
release: {{ $.Release.Name }} | ||
heritage: {{ $.Release.Service }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ template "renku.fullname" $ }}-secrets-storage | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ template "renku.fullname" $ }}-secrets-storage | ||
namespace: {{ $.Release.Namespace }} | ||
{{ end }} | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ template "renku.fullname" . }}-secrets-storage | ||
labels: | ||
app: {{ template "renku.name" . }} | ||
chart: {{ template "renku.chart" . }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: {{ template "renku.fullname" . }}-secrets-storage | ||
labels: | ||
app: renku-secrets-storage | ||
chart: {{ template "renku.chart" . }} | ||
release: {{ .Release.Name }} | ||
heritage: {{ .Release.Service }} | ||
spec: | ||
type: {{ .Values.secretsStorage.service.type }} | ||
ports: | ||
- port: {{ .Values.secretsStorage.service.port }} | ||
targetPort: http | ||
protocol: TCP | ||
name: http | ||
selector: | ||
app: {{ template "renku.name" . }}-secrets-storage | ||
release: {{ .Release.Name }} |
Oops, something went wrong.