Skip to content

Commit be44880

Browse files
committed
feat(chart): Improved default security context
Signed-off-by: Steve Hipwell <[email protected]>
1 parent fe32aae commit be44880

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

charts/karpenter/README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,18 @@ cosign verify public.ecr.aws/karpenter/karpenter:1.1.0 \
4545
| additionalLabels | object | `{}` | Additional labels to add into metadata. |
4646
| affinity | object | `{"nodeAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":{"nodeSelectorTerms":[{"matchExpressions":[{"key":"karpenter.sh/nodepool","operator":"DoesNotExist"}]}]}},"podAntiAffinity":{"requiredDuringSchedulingIgnoredDuringExecution":[{"topologyKey":"kubernetes.io/hostname"}]}}` | Affinity rules for scheduling the pod. If an explicit label selector is not provided for pod affinity or pod anti-affinity one will be created from the pod selector labels. |
4747
| controller.containerName | string | `"controller"` | Distinguishing container name (containerName: karpenter-controller). |
48-
| controller.env | list | `[]` | Additional environment variables for the controller pod. |
48+
| controller.env | list | `[]` | Additional environment variables for the controller container. |
4949
| controller.envFrom | list | `[]` | |
50-
| controller.extraVolumeMounts | list | `[]` | Additional volumeMounts for the controller pod. |
50+
| controller.extraVolumeMounts | list | `[]` | Additional volumeMounts for the controller container. |
5151
| controller.healthProbe.port | int | `8081` | The container port to use for http health probe. |
5252
| controller.image.digest | string | `"sha256:51bca600197c7c6e6e0838549664b2c12c3f8dd4b23744ab28202ae97ca5aed1"` | SHA256 digest of the controller image. |
5353
| controller.image.repository | string | `"public.ecr.aws/karpenter/controller"` | Repository path to the controller image. |
5454
| controller.image.tag | string | `"1.1.0"` | Tag of the controller image. |
5555
| controller.metrics.port | int | `8080` | The container port to use for metrics. |
56-
| controller.resources | object | `{}` | Resources for the controller pod. |
56+
| controller.resources | object | `{}` | Resources for the controller container. |
57+
| controller.securityContext.appArmorProfile | object | `nil` | The AppArmor options to use by the controller container. |
58+
| controller.securityContext.seLinuxOptions | object | `nil` | The SELinux context to be applied to the controller container. |
59+
| controller.securityContext.seccompProfile | object | `{"type":"RuntimeDefault"}` | The seccomp options to use by the controller container. |
5760
| controller.sidecarContainer | list | `[]` | Additional sidecarContainer config |
5861
| controller.sidecarVolumeMounts | list | `[]` | Additional volumeMounts for the sidecar - this will be added to the volume mounts on top of extraVolumeMounts |
5962
| dnsConfig | object | `{}` | Configure DNS Config for the pod |
@@ -72,10 +75,11 @@ cosign verify public.ecr.aws/karpenter/karpenter:1.1.0 \
7275
| podDisruptionBudget.maxUnavailable | int | `1` | |
7376
| podDisruptionBudget.name | string | `"karpenter"` | |
7477
| podLabels | object | `{}` | Additional labels for the pod. |
75-
| podSecurityContext | object | `{"fsGroup":65532}` | SecurityContext for the pod. |
78+
| podSecurityContext | object | `{"fsGroup":65532,"runAsNonRoot":true,"seccompProfile":{"type":"RuntimeDefault"}}` | SecurityContext for the pod. |
7679
| priorityClassName | string | `"system-cluster-critical"` | PriorityClass name for the pod. |
7780
| replicas | int | `2` | Number of replicas. |
7881
| revisionHistoryLimit | int | `10` | The number of old ReplicaSets to retain to allow rollback. |
82+
| schedulerName | string | `"default-scheduler"` | Specify which Kubernetes scheduler should dispatch the pod. |
7983
| service.annotations | object | `{}` | Additional annotations for the Service. |
8084
| serviceAccount.annotations | object | `{}` | Additional annotations for the ServiceAccount. |
8185
| serviceAccount.create | bool | `true` | Specifies if a ServiceAccount should be created. |
@@ -89,7 +93,6 @@ cosign verify public.ecr.aws/karpenter/karpenter:1.1.0 \
8993
| settings.clusterCABundle | string | `""` | Cluster CA bundle for TLS configuration of provisioned nodes. If not set, this is taken from the controller's TLS configuration for the API server. |
9094
| settings.clusterEndpoint | string | `""` | Cluster endpoint. If not set, will be discovered during startup (EKS only) |
9195
| settings.clusterName | string | `""` | Cluster name. |
92-
| settings.eksControlPlane | bool | `false` | Marking this true means that your cluster is running with an EKS control plane and Karpenter should attempt to discover cluster details from the DescribeCluster API |
9396
| settings.featureGates | object | `{"nodeRepair":false,"spotToSpotConsolidation":false}` | Feature Gate configuration values. Feature Gates will follow the same graduation process and requirements as feature gates in Kubernetes. More information here https://kubernetes.io/docs/reference/command-line-tools-reference/feature-gates/#feature-gates-for-alpha-or-beta-features |
9497
| settings.featureGates.nodeRepair | bool | `false` | nodeRepair is ALPHA and is disabled by default. Setting this to true will enable node repair. |
9598
| settings.featureGates.spotToSpotConsolidation | bool | `false` | spotToSpotConsolidation is ALPHA and is disabled by default. Setting this to true will enable spot replacement consolidation for both single and multi-node consolidation. |

charts/karpenter/templates/deployment.yaml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,29 @@ spec:
6262
containers:
6363
- name: {{ .Values.controller.containerName | default "controller" }}
6464
securityContext:
65+
privileged: false
66+
allowPrivilegeEscalation: false
67+
readOnlyRootFilesystem: true
68+
runAsNonRoot: true
6569
runAsUser: 65532
6670
runAsGroup: 65532
67-
runAsNonRoot: true
68-
seccompProfile:
69-
type: RuntimeDefault
70-
allowPrivilegeEscalation: false
7171
capabilities:
7272
drop:
7373
- ALL
74-
readOnlyRootFilesystem: true
74+
{{- with .Values.controller.securityContext }}
75+
{{- with .appArmorProfile }}
76+
appArmorProfile:
77+
{{- toYaml . | nindent 14}}
78+
{{- end }}
79+
{{- with .seLinuxOptions }}
80+
seLinuxOptions:
81+
{{- toYaml . | nindent 14}}
82+
{{- end }}
83+
{{- with .seccompProfile }}
84+
seccompProfile:
85+
{{- toYaml . | nindent 14}}
86+
{{- end }}
87+
{{- end }}
7588
image: {{ include "karpenter.controller.image" . }}
7689
imagePullPolicy: {{ .Values.imagePullPolicy }}
7790
env:

charts/karpenter/values.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,10 @@ podDisruptionBudget:
5151
maxUnavailable: 1
5252
# -- SecurityContext for the pod.
5353
podSecurityContext:
54+
runAsNonRoot: true
5455
fsGroup: 65532
56+
seccompProfile:
57+
type: RuntimeDefault
5558
# -- PriorityClass name for the pod.
5659
priorityClassName: system-cluster-critical
5760
# -- Override the default termination grace period for the pod.
@@ -111,12 +114,20 @@ controller:
111114
tag: 1.1.0
112115
# -- SHA256 digest of the controller image.
113116
digest: sha256:51bca600197c7c6e6e0838549664b2c12c3f8dd4b23744ab28202ae97ca5aed1
114-
# -- Additional environment variables for the controller pod.
117+
securityContext:
118+
# -- (object) The AppArmor options to use by the controller container.
119+
appArmorProfile:
120+
# -- (object) The SELinux context to be applied to the controller container.
121+
seLinuxOptions:
122+
# -- The seccomp options to use by the controller container.
123+
seccompProfile:
124+
type: RuntimeDefault
125+
# -- Additional environment variables for the controller container.
115126
env: []
116127
# - name: AWS_REGION
117128
# value: eu-west-1
118129
envFrom: []
119-
# -- Resources for the controller pod.
130+
# -- Resources for the controller container.
120131
resources: {}
121132
# We usually recommend not to specify default resources and to leave this as a conscious
122133
# choice for the user. This also increases chances charts run on environments with little
@@ -128,8 +139,7 @@ controller:
128139
# limits:
129140
# cpu: 1
130141
# memory: 1Gi
131-
132-
# -- Additional volumeMounts for the controller pod.
142+
# -- Additional volumeMounts for the controller container.
133143
extraVolumeMounts: []
134144
# - name: aws-iam-token
135145
# mountPath: /var/run/secrets/eks.amazonaws.com/serviceaccount

0 commit comments

Comments
 (0)