Skip to content

Commit 9a56e2d

Browse files
Merge pull request #318 from linode/securityContextAffinity
[improvement] set securityContext and use affinity instead of nodeSelector
2 parents 1b9f2e7 + caacc51 commit 9a56e2d

File tree

3 files changed

+68
-27
lines changed

3 files changed

+68
-27
lines changed

deploy/ccm-linode-template.yaml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,17 @@ spec:
7777
labels:
7878
app: ccm-linode
7979
spec:
80+
affinity:
81+
nodeAffinity:
82+
requiredDuringSchedulingIgnoredDuringExecution:
83+
nodeSelectorTerms:
84+
- matchExpressions:
85+
- key: node-role.kubernetes.io/control-plane
86+
operator: Exists
87+
securityContext:
88+
seccompProfile:
89+
type: RuntimeDefault
8090
serviceAccountName: ccm-linode
81-
nodeSelector:
82-
# The CCM will only run on a Node labelled as a master, you may want to change this
83-
node-role.kubernetes.io/control-plane: ""
8491
tolerations:
8592
# The CCM can run on Nodes tainted as masters
8693
- key: "node-role.kubernetes.io/control-plane"
@@ -122,6 +129,11 @@ spec:
122129
secretKeyRef:
123130
name: ccm-linode
124131
key: region
132+
securityContext:
133+
allowPrivilegeEscalation: false
134+
capabilities:
135+
drop:
136+
- ALL
125137
volumes:
126138
- name: k8s
127139
hostPath:

deploy/chart/templates/daemonset.yaml

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,21 @@ spec:
1515
app: ccm-linode
1616
spec:
1717
serviceAccountName: ccm-linode
18-
{{- if .Values.nodeSelector }}
18+
{{- with .Values.securityContext }}
19+
securityContext:
20+
{{- toYaml . | nindent 8 }}
21+
{{- end }}
22+
{{- with .Values.nodeSelector }}
1923
nodeSelector:
20-
{{ toYaml .Values.nodeSelector | indent 8 }}
24+
{{- toYaml . | nindent 8 }}
25+
{{- end }}
26+
{{- with .Values.affinity }}
27+
affinity:
28+
{{- toYaml . | nindent 8 }}
2129
{{- end }}
22-
{{- if .Values.tolerations }}
30+
{{- with .Values.tolerations }}
2331
tolerations:
24-
{{ toYaml .Values.tolerations | indent 8 }}
32+
{{- toYaml . | nindent 8 }}
2533
{{- end }}
2634
hostNetwork: true
2735
containers:
@@ -33,8 +41,8 @@ spec:
3341
- --v=3
3442
- --secure-port=10253
3543
- --webhook-secure-port=0
36-
{{- if .Values.linodegoDebug }}
37-
- --linodego-debug={{ .Values.linodegoDebug }}
44+
{{- with .Values.linodegoDebug }}
45+
- --linodego-debug={{ . }}
3846
{{- end }}
3947
{{- if .Values.routeController }}
4048
- --enable-route-controller=true
@@ -44,36 +52,40 @@ spec:
4452
{{- if not (or .Values.routeController.vpcName .Values.routeController.vpcNames) }}
4553
{{- fail "Neither vpcName nor vpcNames is set. Please set one of them." }}
4654
{{- end }}
47-
{{- if .Values.routeController.vpcName }}
48-
- --vpc-name={{ .Values.routeController.vpcName }}
55+
{{- with .Values.routeController.vpcName }}
56+
- --vpc-name={{ . }}
4957
{{- end }}
50-
{{- if .Values.routeController.vpcNames }}
51-
- --vpc-names={{ .Values.routeController.vpcNames }}
58+
{{- with .Values.routeController.vpcNames }}
59+
- --vpc-names={{ . }}
5260
{{- end }}
5361
- --configure-cloud-routes={{ default true .Values.routeController.configureCloudRoutes }}
5462
- --cluster-cidr={{ required "A valid .Values.routeController.clusterCIDR is required" .Values.routeController.clusterCIDR }}
55-
{{- if .Values.routeController.routeReconciliationPeriod }}
56-
- --route-reconciliation-period={{ .Values.routeController.routeReconciliationPeriod }}
63+
{{- with .Values.routeController.routeReconciliationPeriod }}
64+
- --route-reconciliation-period={{ . }}
5765
{{- end }}
5866
{{- end }}
5967
{{- if .Values.sharedIPLoadBalancing }}
60-
{{- if .Values.sharedIPLoadBalancing.bgpNodeSelector }}
61-
- --bgp-node-selector={{ .Values.sharedIPLoadBalancing.bgpNodeSelector }}
68+
{{- with .Values.sharedIPLoadBalancing.bgpNodeSelector }}
69+
- --bgp-node-selector={{ . }}
6270
{{- end }}
63-
{{- if .Values.sharedIPLoadBalancing.ipHolderSuffix }}
64-
- --ip-holder-suffix={{ .Values.sharedIPLoadBalancing.ipHolderSuffix }}
71+
{{- with .Values.sharedIPLoadBalancing.ipHolderSuffix }}
72+
- --ip-holder-suffix={{ . }}
6573
{{- end}}
6674
- --load-balancer-type={{ required "A valid .Values.sharedIPLoadBalancing.loadBalancerType is required for shared IP load-balancing" .Values.sharedIPLoadBalancing.loadBalancerType }}
6775
{{- end }}
68-
{{- if .Values.tokenHealthChecker }}
69-
- --enable-token-health-checker={{ .Values.tokenHealthChecker }}
76+
{{- with .Values.tokenHealthChecker }}
77+
- --enable-token-health-checker={{ . }}
7078
{{- end }}
71-
{{- if .Values.nodeBalancerTags }}
72-
- --nodebalancer-tags={{ join " " .Values.nodeBalancerTags }}
79+
{{- with .Values.nodeBalancerTags }}
80+
- --nodebalancer-tags={{ join " " . }}
7381
{{- end }}
7482
{{- if .Values.allowUnauthorizedMetrics }}
7583
- --authorization-always-allow-paths="/metrics"
7684
{{- end }}
85+
{{- with .Values.containerSecurityContext }}
86+
securityContext:
87+
{{- toYaml . | nindent 12 }}
88+
{{- end }}
7789
volumeMounts:
7890
- mountPath: /etc/kubernetes
7991
name: k8s

deploy/chart/values.yaml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,27 @@ region: ""
1010
# apiTokenRef: "apiToken"
1111
# regionRef: "region"
1212

13-
# node-role.kubernetes.io/master - if set true, it deploys the svc on the master node
14-
nodeSelector:
15-
# The CCM will only run on a Node labelled as a master, you may want to change this
16-
node-role.kubernetes.io/control-plane: ""
13+
# Ensures the CCM runs on control plane nodes
14+
affinity:
15+
nodeAffinity:
16+
requiredDuringSchedulingIgnoredDuringExecution:
17+
nodeSelectorTerms:
18+
- matchExpressions:
19+
- key: node-role.kubernetes.io/control-plane
20+
operator: Exists
21+
22+
# DEPRECATED: use affinity instead
23+
nodeSelector: {}
24+
25+
securityContext:
26+
seccompProfile:
27+
type: RuntimeDefault
28+
29+
containerSecurityContext:
30+
allowPrivilegeEscalation: false
31+
capabilities:
32+
drop:
33+
- ALL
1734

1835
# Image repository must be 'linode/linode-cloud-controller-manager'. The tag can be changed/set to various ccm versions.
1936
# The pullPolicy is set to Always but can be changed when it is not required to always pull the new image

0 commit comments

Comments
 (0)