-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sysctl configure daemonset
- Loading branch information
1 parent
f0aa735
commit 37d8726
Showing
7 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
charts/lagoon-remote/templates/sysctl-configure.clusterrole.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- if .Values.sysctlConfigure.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ include "lagoon-remote.sysctlConfigure.fullname" . }} | ||
labels: | ||
{{- include "lagoon-remote.sysctlConfigure.labels" . | nindent 4 }} | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes | ||
verbs: | ||
- get | ||
- patch | ||
{{- end }} |
16 changes: 16 additions & 0 deletions
16
charts/lagoon-remote/templates/sysctl-configure.clusterrolebinding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- if .Values.sysctlConfigure.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ include "lagoon-remote.sysctlConfigure.fullname" . }} | ||
labels: | ||
{{- include "lagoon-remote.sysctlConfigure.labels" . | nindent 4 }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: {{ include "lagoon-remote.sysctlConfigure.fullname" . }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "lagoon-remote.sysctlConfigure.serviceAccountName" . }} | ||
namespace: {{ .Release.Namespace | quote }} | ||
{{- end }} |
53 changes: 53 additions & 0 deletions
53
charts/lagoon-remote/templates/sysctl-configure.daemonset.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{{- if .Values.sysctlConfigure.enabled -}} | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: {{ include "lagoon-remote.sysctlConfigure.fullname" . }} | ||
labels: | ||
{{- include "lagoon-remote.sysctlConfigure.labels" . | nindent 4 }} | ||
spec: | ||
selector: | ||
matchLabels: | ||
{{- include "lagoon-remote.sysctlConfigure.selectorLabels" . | nindent 6 }} | ||
template: | ||
metadata: | ||
name: {{ include "lagoon-remote.sysctlConfigure.fullname" . }} | ||
labels: | ||
{{- include "lagoon-remote.sysctlConfigure.selectorLabels" . | nindent 8 }} | ||
spec: | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: k8s.lagoon.sh/sysctl-configured | ||
operator: DoesNotExist | ||
serviceAccount: {{ include "lagoon-remote.sysctlConfigure.serviceAccountName" . }} | ||
containers: | ||
- name: sysctl | ||
image: "{{ .Values.sysctlConfigure.image.repository }}:{{ .Values.sysctlConfigure.image.tag | default .Chart.AppVersion}}" | ||
imagePullPolicy: {{ .Values.sysctlConfigure.image.pullPolicy }} | ||
command: | ||
env: | ||
- name: THIS_NODE_NAME | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: spec.nodeName | ||
command: | ||
- sh | ||
- -c | ||
- | | ||
set -xe | ||
{{- $index := 0 }} | ||
{{- range $sys, $value := .Values.sysctlConfigure.sysctl }} | ||
CURRENT{{ $index }}=$(sysctl -n {{ $sys }}) | ||
if [ "{{ $value }}" -gt "$CURRENT{{ $index }}" ]; then | ||
sysctl -w {{ $sys }}={{ $value }} | ||
fi | ||
{{- $index = add $index 1 }} | ||
{{- end }} | ||
kubectl label node "$THIS_NODE_NAME" k8s.lagoon.sh/sysctl-configured=$(date +%s) | ||
securityContext: | ||
runAsUser: 0 | ||
privileged: true | ||
{{- end }} |
8 changes: 8 additions & 0 deletions
8
charts/lagoon-remote/templates/sysctl-configure.serviceaccount.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{{- if .Values.sysctlConfigure.enabled -}} | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: {{ include "lagoon-remote.sysctlConfigure.serviceAccountName" . }} | ||
labels: | ||
{{- include "lagoon-remote.sysctlConfigure.labels" . | nindent 4 }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters