apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: {{ include "mastodon-helm.fullname" . }}-tootctl
  labels:
    component: tootctl
    {{- include "mastodon-helm.labels" . | nindent 4 }}
spec:
  selector:
    matchLabels:
      component: tootctl
      {{- include "mastodon-helm.labels" . | nindent 6 }}
  template:
    metadata:
      name: {{ include "mastodon-helm.fullname" . }}-tootctl
      labels:
        component: tootctl
        {{- include "mastodon-helm.labels" . | nindent 8 }}
    spec:
      {{- with .Values.imagePullSecrets }}
      imagePullSecrets:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      volumes:
        - name: data
          {{- .Values.volumes.data | nindent 10 }}
        - name: tmp
          emptyDir:
            medium: Memory
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.web.repository }}:{{ .Values.web.tag | default .Chart.AppVersion }}"
          imagePullPolicy: {{ .Values.web.pullPolicy }}
          command:
            - "/bin/sh"
            - "-c"
            - "while true; do sleep 60; done"
          envFrom:
            - secretRef:
                name: {{ include "mastodon-helm.fullname" . }}
          volumeMounts:
            - mountPath: "/mastodon/public/system"
              name: data
            - mountPath: "/opt/mastodon/tmp"
              name: tmp
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}
