-
Notifications
You must be signed in to change notification settings - Fork 334
api-gateway: allow controller to bind PodSecurityPolicy to ServiceAccounts that it creates #1672
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
Changes from all commits
dc422f6
706fa94
71045d9
d247baa
860fc31
d92bc7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -245,11 +245,21 @@ rules: | |
| - patch | ||
| - update | ||
| {{- if .Values.global.enablePodSecurityPolicies }} | ||
| - apiGroups: ["policy"] | ||
| resources: ["podsecuritypolicies"] | ||
| resourceNames: | ||
| - {{ template "consul.fullname" . }}-api-gateway-controller | ||
| - apiGroups: | ||
| - policy | ||
| resources: | ||
| - podsecuritypolicies | ||
| verbs: | ||
| - use | ||
| - apiGroups: | ||
| - rbac.authorization.k8s.io | ||
| resources: | ||
| - roles | ||
| - rolebindings | ||
| verbs: | ||
| - use | ||
| - create | ||
| - get | ||
| - list | ||
| - watch | ||
|
Comment on lines
+254
to
+263
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not a huge fan of allowing the API gateway controller to create
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks so much for the detail in the comment. I really appreciate it. |
||
| {{- end }} | ||
| {{- end }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,9 @@ spec: | |
| {{- if .Values.global.acls.manageSystemACLs }} | ||
| managed: true | ||
| method: {{ template "consul.fullname" . }}-k8s-auth-method | ||
| {{- if .Values.global.enablePodSecurityPolicies }} | ||
| podSecurityPolicy: {{ template "consul.fullname" . }}-api-gateway | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This specifies the name of the This is intentionally pretty flexible so that a user doesn't need a code release from us if they, for example, wanted to create their own |
||
| {{- end }} | ||
| {{- end }} | ||
| {{- if .Values.global.tls.enabled }} | ||
| scheme: https | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| {{- if and .Values.apiGateway.enabled .Values.global.enablePodSecurityPolicies }} | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the PSP that will be applied to all This is based on the PSP that we use for the API gateway controller with some slight modifications. Please review this for sensibility. |
||
| apiVersion: policy/v1beta1 | ||
| kind: PodSecurityPolicy | ||
| metadata: | ||
| name: {{ template "consul.fullname" . }}-api-gateway | ||
| namespace: {{ .Release.Namespace }} | ||
| labels: | ||
| app: {{ template "consul.name" . }} | ||
| chart: {{ template "consul.chart" . }} | ||
| heritage: {{ .Release.Service }} | ||
| release: {{ .Release.Name }} | ||
| component: api-gateway-controller | ||
| spec: | ||
| privileged: false | ||
| # Required to prevent escalations to root. | ||
| allowPrivilegeEscalation: false | ||
| # This is redundant with non-root + disallow privilege escalation, | ||
| # but we can provide it for defense in depth. | ||
| requiredDropCapabilities: | ||
| - ALL | ||
| # Allow core volume types. | ||
| volumes: | ||
| - 'configMap' | ||
| - 'emptyDir' | ||
| - 'projected' | ||
| - 'secret' | ||
| - 'downwardAPI' | ||
| allowedCapabilities: | ||
| - NET_BIND_SERVICE | ||
| hostNetwork: false | ||
| hostIPC: false | ||
| hostPID: false | ||
| hostPorts: | ||
| - max: 65535 | ||
| min: 1025 | ||
| runAsUser: | ||
| rule: 'RunAsAny' | ||
| seLinux: | ||
| rule: 'RunAsAny' | ||
| supplementalGroups: | ||
| rule: 'RunAsAny' | ||
| fsGroup: | ||
| rule: 'RunAsAny' | ||
| readOnlyRootFilesystem: true | ||
| {{- end }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was previously narrowed to the specific
PodSecurityPolicycreated for the API Gateway controller; however, the controller needs to be able to createRoles/RoleBindingsthat use whateverPSPis named in theGatewayClassConfig. Since you can't grant permissions that you don't have, the controller needs to be able to use more than just thePSPthat applies to itself.