Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

6.7 KB
Raw Blame
{{- $openShiftAgent := and .Values.openShift.enabled .Values.openShift.kubernetesAgent.enabled }}
{{- if or .Values.agent.enabled $openShiftAgent }}
{{- $kind := ternary "deployment" (default "DaemonSet" .Values.agent.kind | lower) $openShiftAgent }}
{{- $isDaemon := eq $kind "daemonset" }}
{{- $dockerSocketEnabled := and .Values.agent.dockerSocket.enabled (not $openShiftAgent) }}
{{- $workloadName := printf "%s-agent" (include "pulse.fullname" .) }}
apiVersion: apps/v1
kind: {{ if $isDaemon }}DaemonSet{{ else }}Deployment{{ end }}
metadata:
  name: {{ $workloadName }}
  labels:
    {{- include "pulse.labels" . | nindent 4 }}
    app.kubernetes.io/component: agent
spec:
  {{- if not $isDaemon }}
  replicas: {{ ternary 1 .Values.agent.replicaCount $openShiftAgent }}
  {{- end }}
  selector:
    matchLabels:
      {{- include "pulse.selectorLabels" . | nindent 6 }}
      app.kubernetes.io/component: agent
  {{- if $isDaemon }}
  updateStrategy:
    type: RollingUpdate
  {{- end }}
  template:
    metadata:
      labels:
        {{- include "pulse.selectorLabels" . | nindent 8 }}
        app.kubernetes.io/component: agent
        {{- with .Values.agent.podLabels }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
      {{- if .Values.agent.podAnnotations }}
      annotations:
        {{- toYaml .Values.agent.podAnnotations | nindent 8 }}
      {{- end }}
    spec:
      serviceAccountName: {{ include "pulse.agentServiceAccountName" . }}
      {{- $podSecurityContext := .Values.agent.podSecurityContext }}
      {{- if $podSecurityContext }}
      securityContext:
        {{- toYaml $podSecurityContext | nindent 8 }}
      {{- end }}
      containers:
        - name: pulse-agent
          image: "{{ .Values.agent.image.repository }}:{{ default .Chart.AppVersion .Values.agent.image.tag }}"
          imagePullPolicy: {{ .Values.agent.image.pullPolicy }}
          {{- if .Values.agent.command }}
          command:
            {{- toYaml .Values.agent.command | nindent 12 }}
          {{- end }}
          {{- if $openShiftAgent }}
          args:
            - --enable-kubernetes
            - --enable-host=false
          {{- else if .Values.agent.args }}
          args:
            {{- toYaml .Values.agent.args | nindent 12 }}
          {{- end }}
          {{- $openShiftSecurityContext := dict
            "allowPrivilegeEscalation" false
            "capabilities" (dict "drop" (list "ALL"))
            "privileged" false
            "readOnlyRootFilesystem" true
            "runAsNonRoot" true }}
          {{- $openShiftSecurityContext = mergeOverwrite $openShiftSecurityContext .Values.agent.securityContext }}
          {{- $csec := ternary
            (omit $openShiftSecurityContext "runAsUser" "runAsGroup")
            .Values.agent.securityContext
            $openShiftAgent }}
          {{- if $csec }}
          securityContext:
            {{- toYaml $csec | nindent 12 }}
          {{- end }}
          {{- $envList := list }}
          {{- range .Values.agent.env }}
          {{- $envList = append $envList . }}
          {{- end }}
          {{- range .Values.agent.extraEnv }}
          {{- $envList = append $envList . }}
          {{- end }}
          {{- if $openShiftAgent }}
          {{- $clusterID := default (printf "%s-openshift" (include "pulse.fullname" .)) .Values.openShift.kubernetesAgent.clusterID }}
          {{- $envList = append $envList (dict "name" "PULSE_AGENT_ID" "value" $clusterID) }}
          {{- end }}
          {{- $secret := .Values.agent.secretEnv }}
          {{- $secretKeys := list }}
          {{- if $secret.keys }}
          {{- $secretKeys = $secret.keys }}
          {{- else if $secret.data }}
          {{- $secretKeys = keys $secret.data }}
          {{- end }}
          {{- $root := . }}
          {{- range $key := $secretKeys }}
          {{- $envList = append $envList (dict "name" $key "valueFrom" (dict "secretKeyRef" (dict "name" (include "pulse.agentSecretName" $root) "key" $key))) }}
          {{- end }}
          {{- if $envList }}
          env:
            {{- toYaml $envList | nindent 12 }}
          {{- end }}
          {{- $envFrom := concat .Values.agent.envFrom .Values.agent.extraEnvFrom }}
          {{- if $envFrom }}
          envFrom:
            {{- range $envFrom }}
            {{- toYaml . | nindent 12 }}
            {{- end }}
          {{- end }}
          {{- if or $dockerSocketEnabled .Values.agent.extraVolumeMounts }}
          volumeMounts:
            {{- if $dockerSocketEnabled }}
            - name: docker-socket
              mountPath: {{ .Values.agent.dockerSocket.path }}
            {{- end }}
            {{- with .Values.agent.extraVolumeMounts }}
            {{- toYaml . | nindent 12 }}
            {{- end }}
          {{- end }}
          {{- with .Values.agent.resources }}
          resources:
            {{- toYaml . | nindent 12 }}
          {{- end }}
          {{- if .Values.agent.livenessProbe.enabled }}
          livenessProbe:
            httpGet:
              path: {{ .Values.agent.livenessProbe.path }}
              port: {{ .Values.agent.healthPort }}
            initialDelaySeconds: {{ .Values.agent.livenessProbe.initialDelaySeconds }}
            periodSeconds: {{ .Values.agent.livenessProbe.periodSeconds }}
            timeoutSeconds: {{ .Values.agent.livenessProbe.timeoutSeconds }}
            failureThreshold: {{ .Values.agent.livenessProbe.failureThreshold }}
          {{- end }}
          {{- if .Values.agent.readinessProbe.enabled }}
          readinessProbe:
            httpGet:
              path: {{ .Values.agent.readinessProbe.path }}
              port: {{ .Values.agent.healthPort }}
            initialDelaySeconds: {{ .Values.agent.readinessProbe.initialDelaySeconds }}
            periodSeconds: {{ .Values.agent.readinessProbe.periodSeconds }}
            timeoutSeconds: {{ .Values.agent.readinessProbe.timeoutSeconds }}
            failureThreshold: {{ .Values.agent.readinessProbe.failureThreshold }}
          {{- end }}
      {{- if or $dockerSocketEnabled .Values.agent.extraVolumes }}
      volumes:
        {{- if $dockerSocketEnabled }}
        - name: docker-socket
          hostPath:
            path: {{ .Values.agent.dockerSocket.path }}
            {{- with .Values.agent.dockerSocket.hostPathType }}
            type: {{ . }}
            {{- end }}
        {{- end }}
        {{- with .Values.agent.extraVolumes }}
        {{- toYaml . | nindent 8 }}
        {{- end }}
      {{- end }}
      {{- with .Values.agent.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.agent.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.agent.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
{{- end }}