Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
feat: add securityContext
Browse files Browse the repository at this point in the history
  • Loading branch information
lenglet-k authored and eshepelyuk committed Dec 27, 2023
1 parent 1c4cc9d commit c1e4733
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 5 deletions.
8 changes: 8 additions & 0 deletions templates/deployment-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@ spec:
initContainers:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.registry.podSecurityContext }}
securityContext:
{{- toYaml .| nindent 8 }}
{{- end }}
containers:
- name: registry
{{- with .Values.registry.securityContext }}
securityContext:
{{- toYaml .| nindent 12 }}
{{- end }}
image: {{ include "apicurio-registry.image" .Values.registry }}
{{- with .Values.registry.nodeSelector }}
nodeSelector:
Expand Down
8 changes: 8 additions & 0 deletions templates/deployment-sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,16 @@ spec:
initContainers:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- with .Values.sync.podSecurityContext }}
securityContext:
{{- toYaml .| nindent 8 }}
{{- end }}
containers:
- name: sync
{{- with .Values.sync.securityContext }}
securityContext:
{{- toYaml .| nindent 12 }}
{{- end }}
image: {{ .Values.sync.image.registry }}/{{ .Values.sync.image.repository }}:{{ .Values.sync.image.tag }}
{{- with .Values.sync.nodeSelector }}
nodeSelector:
Expand Down
20 changes: 20 additions & 0 deletions test/lint/registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,23 @@ tests:
values don't meet the specifications of the schema(s) in the following chart(s):
apicurio-registry:
- registry.extraLabels: Invalid type. Expected: object, given: integer
- it: podSecurityContext is not object
set:
registry:
podSecurityContext: "qwe"
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
apicurio-registry:
- registry.podSecurityContext: Invalid type. Expected: object, given: string
- it: securityContext is not object
set:
registry:
securityContext: "qwe"
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
apicurio-registry:
- registry.securityContext: Invalid type. Expected: object, given: string
20 changes: 20 additions & 0 deletions test/lint/sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,23 @@ tests:
values don't meet the specifications of the schema(s) in the following chart(s):
apicurio-registry:
- sync.extraVolumeMounts: Invalid type. Expected: array, given: string
- it: podSecurityContext is not object
set:
sync:
podSecurityContext: "qwe"
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
apicurio-registry:
- sync.podSecurityContext: Invalid type. Expected: object, given: string
- it: securityContext is not object
set:
sync:
securityContext: "qwe"
asserts:
- failedTemplate:
errorMessage: |
values don't meet the specifications of the schema(s) in the following chart(s):
apicurio-registry:
- sync.securityContext: Invalid type. Expected: object, given: string
22 changes: 21 additions & 1 deletion test/unit/deployment_registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,24 @@ tests:
app.kubernetes.io/component: registry
app.kubernetes.io/instance: RELEASE-NAME
app.kubernetes.io/name: apicurio-registry
testLabel: myLabel
testLabel: myLabel
- it: podSecurityContext
set:
registry:
podSecurityContext:
runAsUser: 1001
asserts:
- equal:
path: spec.template.spec.securityContext
value:
runAsUser: 1001
- it: container securityContext
set:
registry:
securityContext:
runAsUser: 1001
asserts:
- equal:
path: spec.template.spec.containers[0].securityContext
value:
runAsUser: 1001
22 changes: 21 additions & 1 deletion test/unit/deployment_sync.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,24 @@ tests:
asserts:
- equal:
path: spec.template.spec.imagePullSecrets[0].name
value: mysecret
value: mysecret
- it: podSecurityContext
set:
sync:
podSecurityContext:
runAsUser: 1001
asserts:
- equal:
path: spec.template.spec.securityContext
value:
runAsUser: 1001
- it: container securityContext
set:
sync:
securityContext:
runAsUser: 1001
asserts:
- equal:
path: spec.template.spec.containers[0].securityContext
value:
runAsUser: 1001
18 changes: 16 additions & 2 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
}
}
},
"podSecurityContext": {
"type": "object",
"title": "The pod securityContext Schema",
"properties": {}
},
"securityContext": {
"type": "object",
"title": "The container securityContext Schema",
"properties": {}
},
"persistence": {
"kafka": {
"type": "object", "additionalProperties": false,
Expand Down Expand Up @@ -113,7 +123,9 @@
"sql": {"$ref": "#/definitions/persistence/sql"},
"imagePullSecrets": {"$ref": "#/definitions/imagePullSecrets"},
"ingress": {"$ref": "#/definitions/ingress"},
"extraLabels": {"$ref": "#/definitions/labels", "title": "deployment and pod resources labels for registry"}
"extraLabels": {"$ref": "#/definitions/labels", "title": "deployment and pod resources labels for registry"},
"podSecurityContext": {"$ref": "#/definitions/podSecurityContext"},
"securityContext": {"$ref": "#/definitions/securityContext"}
}
},
"sync": {
Expand All @@ -129,7 +141,9 @@
"extraVolumeMounts": {"$ref": "#/definitions/volumeMounts", "title": "extra volume mounts for registry content sync"},
"extraVolumes": {"$ref": "#/definitions/volumes", "title": "extra volumes for registry content sync"},
"registryUrl": {"type": ["null", "string"], "default": null},
"extraLabels": {"$ref": "#/definitions/labels", "title": "deployment and pod resources labels for sync"}
"extraLabels": {"$ref": "#/definitions/labels", "title": "deployment and pod resources labels for sync"},
"podSecurityContext": {"$ref": "#/definitions/podSecurityContext"},
"securityContext": {"$ref": "#/definitions/securityContext"}
}
}
}
Expand Down
18 changes: 17 additions & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ registry:
annotations: {}
labels: {}

# add podSecurityContext policy
podSecurityContext: {}
# fsGroup: 185
# runAsUser: 185
# runAsNonRoot: true

# securityContext policy
securityContext: {}
sync:
enabled: true
# set imagePullSecret to pull image from an authenticated registry
Expand Down Expand Up @@ -90,4 +98,12 @@ sync:
# secret:
# secretName: kafka-user
# add extraLabels in deployment and pod objects
extraLabels: {}
extraLabels: {}
# add podSecurityContext policy
podSecurityContext: {}
# fsGroup: 185
# runAsUser: 185
# runAsNonRoot: true

# securityContext policy
securityContext: {}

0 comments on commit c1e4733

Please sign in to comment.