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

Added configurable securityContext and follow restricted PSS #210

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion charts/connect/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: connect
version: 1.16.0
version: 1.17.0
description: A Helm chart for deploying 1Password Connect and the 1Password Connect Kubernetes Operator
keywords:
- "1Password"
Expand Down
213 changes: 109 additions & 104 deletions charts/connect/README.md

Large diffs are not rendered by default.

16 changes: 10 additions & 6 deletions charts/connect/templates/connect-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ spec:
{{- if .Values.connect.priorityClassName }}
priorityClassName: {{ .Values.connect.priorityClassName }}
{{- end }}
{{- with .Values.connect.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.connect.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
Expand All @@ -61,10 +65,10 @@ spec:
- name: {{ .Values.connect.api.name }}
image: {{ .Values.connect.api.imageRepository }}:{{ tpl .Values.connect.version . }}
imagePullPolicy: {{ .Values.connect.imagePullPolicy }}
{{- with .Values.connect.api.securityContext }}
securityContext:
runAsUser: 999
runAsGroup: 999
allowPrivilegeEscalation: false
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.connect.api.resources | nindent 12 }}
env:
Expand Down Expand Up @@ -123,10 +127,10 @@ spec:
- name: connect-sync
image: {{ .Values.connect.sync.imageRepository }}:{{ tpl .Values.connect.version . }}
imagePullPolicy: {{ .Values.connect.imagePullPolicy }}
{{- with .Values.connect.sync.securityContext }}
securityContext:
runAsUser: 999
runAsGroup: 999
allowPrivilegeEscalation: false
{{- toYaml . | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.connect.sync.resources | nindent 12 }}
env:
Expand Down
13 changes: 7 additions & 6 deletions charts/connect/templates/operator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ spec:
{{- if .Values.operator.priorityClassName }}
priorityClassName: {{ .Values.operator.priorityClassName }}
{{- end }}
{{- with .Values.operator.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.operator.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
Expand All @@ -50,13 +54,10 @@ spec:
- name: {{ .Values.connect.applicationName }}
image: {{ .Values.operator.imageRepository }}:{{ .Values.operator.version | default "latest" }}
imagePullPolicy: {{ .Values.connect.imagePullPolicy }}
{{- with .Values.operator.securityContext }}
securityContext:
runAsUser: 65532
runAsGroup: 65532
allowPrivilegeEscalation: false
capabilities:
drop:
- all
{{- toYaml . | nindent 12 }}
{{- end }}
command: [ "/manager" ]
args: [ --zap-log-level={{ .Values.operator.logLevel }}]
env:
Expand Down
8 changes: 8 additions & 0 deletions charts/connect/templates/tests/health-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,16 @@ metadata:
helm.sh/hook-weight: "1"
spec:
restartPolicy: Never
{{- with .Values.acceptanceTests.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 4 }}
{{- end }}
containers:
- name: curl
image: curlimages/curl
command: ["curl", "{{- include "onepassword-connect.url" . }}/health"]
{{- with .Values.acceptanceTests.securityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
8 changes: 8 additions & 0 deletions charts/connect/templates/tests/secret-read.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ metadata:
helm.sh/hook-weight: "3"
spec:
restartPolicy: Never
{{- with .Values.acceptanceTests.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 4 }}
{{- end }}
containers:
- name: secret-assertion
image: alpine
Expand All @@ -30,4 +34,8 @@ spec:
secretKeyRef:
name: "{{ .Release.Name }}-test-secret"
key: password
{{- with .Values.acceptanceTests.securityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}
66 changes: 66 additions & 0 deletions charts/connect/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ connect:
#
annotations: {}

# Container securityContext to be added to the Connect API containers.
# See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container
securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false

# The 1Password Connect Sync Specific Values
sync:
name: connect-sync
Expand All @@ -50,6 +59,15 @@ connect:
httpPort: 8081
logLevel: info

# Container securityContext to be added to the Connect Sync containers.
# See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container
securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false

# The name of 1Password Connect Application
applicationName: onepassword-connect

Expand Down Expand Up @@ -156,6 +174,16 @@ connect:
# Additional labels to be added to the Connect API pods.
podLabels: {}

# Pod securityContext to be added to the Connect API pods.
# See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
podSecurityContext:
fsGroup: 999
runAsUser: 999
runAsGroup: 999
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault

# List of tolerations to be added to the Connect API pods.
tolerations: []

Expand Down Expand Up @@ -261,6 +289,25 @@ operator:
# The 1Password Operator version to pull
version: "1.8.1"

# Pod securityContext to be added to the 1Password Operator pods.
# See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
podSecurityContext:
fsGroup: 65532
runAsUser: 65532
runAsGroup: 65532
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault

# Container securityContext to be added to the 1Password Operator containers.
# See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container
securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false

# Node selector stanza for the Operator pod
# See: https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector
nodeSelector: {}
Expand Down Expand Up @@ -379,3 +426,22 @@ operator:
acceptanceTests:
enabled: false
fixtures: {}

# Pod securityContext to be added to the 1Password Acceptance Tests pods.
# See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
podSecurityContext:
fsGroup: 65532
runAsUser: 65532
runAsGroup: 65532
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault

# Container securityContext to be added to the 1Password Acceptance Tests containers.
# See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container
securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
2 changes: 1 addition & 1 deletion charts/secrets-injector/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ maintainers:
email: [email protected]
icon: https://avatars.githubusercontent.com/u/38230737
appVersion: "1.0.2"
version: 1.1.0
version: 1.2.0
22 changes: 12 additions & 10 deletions charts/secrets-injector/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ $ helm install --set injector.applicationName=injector injector ./secrets-inject

### Values

| Key | Type | Default | Description |
|---------------------------|---------|-------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| injector.applicationName | string | `"secrets-injector"` | The name of 1Password Kubernetes Secrets Injector Application |
| injector.imagePullPolicy | string | `"IfNotPresent"` | The 1Password Secrets Injector docker image policy. `"IfNotPresent"` means the image is pulled only if it is not already present locally. |
| injector.imagePullSecrets | array | `[]` | Global list of secret names to use as image pull secrets for all pod specs in the chart. Secrets must exist in the same namespace |
| injector.imageRepository | string | `"1password/kubernetes-secrets-injector"` | The 1Password Secrets Injector docker image repository |
| injector.port | string | `443` | The port the Secrets Injector exposes |
| injector.targetPort | integer | `8443` | The port the Secrets Injector API sends requests to the pod |
| injector.version | string | `{{.Chart.AppVersion}}` | The 1Password Secrets Injector version to pull. |
| injector.customEnvVars | array | `[]` | Custom Environment Variables for the 1Password Secrets Injector container that are not specified in this helm chart. |
| Key | Type | Default | Description |
|-----------------------------|---------|-------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| injector.applicationName | string | `"secrets-injector"` | The name of 1Password Kubernetes Secrets Injector Application |
| injector.imagePullPolicy | string | `"IfNotPresent"` | The 1Password Secrets Injector docker image policy. `"IfNotPresent"` means the image is pulled only if it is not already present locally. |
| injector.imagePullSecrets | array | `[]` | Global list of secret names to use as image pull secrets for all pod specs in the chart. Secrets must exist in the same namespace |
| injector.imageRepository | string | `"1password/kubernetes-secrets-injector"` | The 1Password Secrets Injector docker image repository |
| injector.port | string | `443` | The port the Secrets Injector exposes |
| injector.targetPort | integer | `8443` | The port the Secrets Injector API sends requests to the pod |
| injector.version | string | `{{.Chart.AppVersion}}` | The 1Password Secrets Injector version to pull. |
| injector.customEnvVars | array | `[]` | Custom Environment Variables for the 1Password Secrets Injector container that are not specified in this helm chart. |
| injector.podSecurityContext | object | `{"fsGroup":65532,"runAsUser":65532,"runAsGroup":65532,"runAsNonRoot":true,"seccompProfile":{"type":"RuntimeDefault"}}` | Pod `securityContext` for the 1Password Secrets Injector pod. |
| injector.securityContext | object | `{"capabilities":{"drop":["ALL"]},"readOnlyRootFilesystem":true,"allowPrivilegeEscalation":false}` | Container `securityContext` for the 1Password Secrets Injector container. |

#### Custom Environment Variables

Expand Down
16 changes: 15 additions & 1 deletion charts/secrets-injector/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ metadata:
labels:
app: {{ .Values.injector.applicationName }}
annotations:
helm.sh/hook: pre-install
helm.sh/hook: pre-install,pre-upgrade
helm.sh/hook-weight: "1"
spec:
selector:
Expand All @@ -18,6 +18,10 @@ spec:
app: {{ .Values.injector.applicationName }}
spec:
serviceAccountName: {{ .Values.injector.applicationName }}
{{- with .Values.injector.podSecurityContext }}
securityContext:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Values.injector.applicationName }}
image: {{ .Values.injector.imageRepository }}:{{ tpl .Values.injector.version . }}
Expand All @@ -40,9 +44,19 @@ spec:
preStop:
exec:
command: [ "/bin/sh", "-c", "/prestop.sh" ]
{{- with .Values.injector.securityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
{{- end }}
volumeMounts:
- name: tmp
mountPath: /tmp
{{- with .Values.injector.imagePullSecrets }}
imagePullSecrets:
{{- range . }}
- name: {{ . | quote }}
{{- end }}
{{- end }}
volumes:
- name: tmp
emptyDir: {}
19 changes: 19 additions & 0 deletions charts/secrets-injector/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,22 @@ injector:
# - name: VARIABLE_NAME
# value: VARIABLE_VALUE
customEnvVars: []

# Pod securityContext to be added to the 1Password secrets injector pods.
# See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
podSecurityContext:
fsGroup: 65532
runAsUser: 65532
runAsGroup: 65532
runAsNonRoot: true
seccompProfile:
type: RuntimeDefault

# Container securityContext to be added to the 1Password secrets injector containers.
# See: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-container
securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false