Linkerd and Pod Security Policies (PSP)
The Linkerd control plane comes with its own minimally privileged Pod Security Policy and the associated RBAC resources. This Pod Security Policy is enforced only if the PodSecurityPolicy admission controller is enabled.
To view the definition of the control plane’s Pod Security Policy, run:
kubectl describe psp -l linkerd.io/control-plane-ns=linkerd
Adjust the value of the above label to match your control plane’s namespace.
Notice that to minimize attack surface, all Linux capabilities are dropped from the control plane’s Pod Security Policy, with the exception of the NET_ADMIN and NET_RAW capabilities. These capabilities provide the proxy-init init container with runtime privilege to rewrite the pod’s iptable. Note that adding these capabilities to the Pod Security Policy doesn’t make the container a privileged container. The control plane’s Pod Security Policy prevents container privilege escalation with the allowPrivilegeEscalation: false policy. To understand the full implication of the NET_ADMIN and NET_RAW capabilities, refer to the Linux capabilities manual.
More information on the iptables rules used by the proxy-init init container can be found on the Architecture page.
If your environment disallows the operation of containers with escalated Linux capabilities, Linkerd can be installed with its CNI plugin, which doesn’t require the NET_ADMIN and NET_RAW capabilities.
Linkerd doesn’t provide any default Pod Security Policy for the data plane because the policies will vary depending on the security requirements of your application. The security context requirement for the Linkerd proxy sidecar container will be very similar to that defined in the control plane’s Pod Security Policy.
For example, the following Pod Security Policy and RBAC will work with the injected emojivoto demo application:
apiVersion: policy/v1beta1kind: PodSecurityPolicymetadata:name: linkerd-emojivoto-data-planespec:allowPrivilegeEscalation: falsefsGroup:ranges:- max: 65535min: 10001rule: MustRunAsreadOnlyRootFilesystem: trueallowedCapabilities:- NET_ADMIN- NET_RAW- NET_BIND_SERVICErequiredDropCapabilities:- ALLrunAsUser:rule: RunAsAnyseLinux:rule: RunAsAnysupplementalGroups:ranges:- max: 65535min: 10001rule: MustRunAsvolumes:- configMap- emptyDir- projected- secret- downwardAPI- persistentVolumeClaim---apiVersion: rbac.authorization.k8s.io/v1kind: Rolemetadata:name: emojivoto-pspnamespace: emojivotorules:- apiGroups: ['policy','extensions']resources: ['podsecuritypolicies']verbs: ['use']resourceNames: ['linkerd-emojivoto-data-plane']---apiVersion: rbac.authorization.k8s.io/v1kind: RoleBindingmetadata:name: emojivoto-pspnamespace: emojivotoroleRef:apiGroup: rbac.authorization.k8s.iokind: Rolename: emojivoto-pspsubjects:- kind: ServiceAccountname: defaultnamespace: emojivoto- kind: ServiceAccountname: emojinamespace: emojivoto- kind: ServiceAccountname: votingnamespace: emojivoto- kind: ServiceAccountname: webnamespace: emojivoto
Note that the Linkerd proxy only requires the NET_ADMIN and NET_RAW capabilities when running without Linkerd CNI, and it’s run with UID 2102.
