diff --git a/changes/24033-helm-customization-options b/changes/24033-helm-customization-options new file mode 100644 index 0000000000..1aafbedcde --- /dev/null +++ b/changes/24033-helm-customization-options @@ -0,0 +1 @@ +Helm chart: Supported customization options such as the Google cloud_sql_proxy in the fleet-migration job. diff --git a/charts/fleet/Chart.yaml b/charts/fleet/Chart.yaml index 5ddc8cd562..c8e2ee9e5d 100644 --- a/charts/fleet/Chart.yaml +++ b/charts/fleet/Chart.yaml @@ -4,7 +4,7 @@ name: fleet keywords: - fleet - osquery -version: v6.2.4 +version: v6.3.0 home: https://github.com/fleetdm/fleet sources: - https://github.com/fleetdm/fleet.git diff --git a/charts/fleet/templates/job-migration.yaml b/charts/fleet/templates/job-migration.yaml index cd2e963712..96737d07e7 100644 --- a/charts/fleet/templates/job-migration.yaml +++ b/charts/fleet/templates/job-migration.yaml @@ -33,10 +33,16 @@ spec: release: {{ .Release.Name }} spec: restartPolicy: Never + shareProcessNamespace: true containers: - name: fleet-migration - command: [/usr/bin/fleet] - args: ["prepare","db","--no-prompt"] + command: ["/bin/sh", "-c"] + args: + - | + /usr/bin/fleet prepare db --no-prompt; + {{- if .Values.gke.cloudSQL.enableProxy }} + sql_proxy_pid=$(pgrep cloud_sql_proxy) && kill -INT $sql_proxy_pid; + {{- end }} image: "{{ .Values.imageRepository }}:{{ .Values.imageTag }}" resources: limits: @@ -117,7 +123,12 @@ spec: securityContext: allowPrivilegeEscalation: false capabilities: + {{- if .Values.gke.cloudSQL.enableProxy }} + add: + - SYS_PTRACE + {{- else }} drop: [ALL] + {{- end }} privileged: false readOnlyRootFilesystem: true runAsGroup: 3333 @@ -129,6 +140,31 @@ spec: readOnly: true mountPath: /secrets/mysql {{- end }} + {{- if .Values.gke.cloudSQL.enableProxy }} + - name: cloudsql-proxy + image: "{{ .Values.gke.cloudSQL.imageRepository }}:{{ .Values.gke.cloudSQL.imageTag }}" + command: + - "/cloud_sql_proxy" + - "-verbose={{ .Values.gke.cloudSQL.verbose}}" + - "-instances={{ .Values.gke.cloudSQL.instanceName }}=tcp:3306" + resources: + limits: + cpu: 0.5 # 500Mhz + memory: 150Mi + requests: + cpu: 0.1 # 100Mhz + memory: 50Mi + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: [ALL] + privileged: false + readOnlyRootFilesystem: true + runAsGroup: 3333 + runAsUser: 3333 + runAsNonRoot: true + {{- end }} + serviceAccountName: fleet volumes: {{- if .Values.database.tls.enabled }} - name: mysql-tls diff --git a/charts/fleet/templates/rbac.yaml b/charts/fleet/templates/rbac.yaml index fc689d1a2f..a0a43f5d43 100644 --- a/charts/fleet/templates/rbac.yaml +++ b/charts/fleet/templates/rbac.yaml @@ -1,6 +1,10 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": before-hook-creation + "helm.sh/hook-weight": "-1" labels: app: fleet chart: fleet @@ -24,6 +28,10 @@ rules: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": before-hook-creation + "helm.sh/hook-weight": "-1" labels: app: fleet chart: fleet diff --git a/charts/fleet/templates/sa.yaml b/charts/fleet/templates/sa.yaml index 67fba2c97b..351ab3f3f2 100644 --- a/charts/fleet/templates/sa.yaml +++ b/charts/fleet/templates/sa.yaml @@ -1,8 +1,11 @@ apiVersion: v1 kind: ServiceAccount metadata: -{{- if or .Values.serviceAccountAnnotations .Values.gke.workloadIdentityEmail }} annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-delete-policy": before-hook-creation + "helm.sh/hook-weight": "-1" + {{- if or .Values.serviceAccountAnnotations .Values.gke.workloadIdentityEmail }} {{- with .Values.serviceAccountAnnotations}} {{ toYaml . | trim | indent 2}} {{- end }}