apiVersion: v1
kind: Service
metadata:
  annotations:
    prometheus.io/port: "8443"
    prometheus.io/scheme: https
    prometheus.io/scrape: "true"
  labels:
    app.kubernetes.io/name: redskyops
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
    app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
    control-plane: controller-manager
  name: "{{ .Release.Name }}-controller-manager-metrics-service"
spec:
  ports:
  - name: https
    port: 8443
    targetPort: https
  selector:
    app.kubernetes.io/name: redskyops
    control-plane: controller-manager
---
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
  labels:
    app.kubernetes.io/name: redskyops
    helm.sh/chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}"
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
    app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
    control-plane: controller-manager
  name: "{{ .Release.Name }}-controller-manager"
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: redskyops
      control-plane: controller-manager
  template:
    metadata:
      labels:
        app.kubernetes.io/name: redskyops
        app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
        control-plane: controller-manager
    spec:
      containers:
      - args:
        - --secure-listen-address=0.0.0.0:8443
        - --upstream=http://127.0.0.1:8080/
        - --logtostderr=true
        - --v=10
        image: gcr.io/kubebuilder/kube-rbac-proxy:v0.4.0
        name: kube-rbac-proxy
        ports:
        - containerPort: 8443
          name: https
      - args:
        - --metrics-addr=127.0.0.1:8080
        command:
        - /manager
        image: {{ .Values.redskyImage }}:{{ .Values.redskyTag }}
        name: manager
        resources:
          limits:
            cpu: 100m
            memory: 30Mi
          requests:
            cpu: 100m
            memory: 20Mi
        securityContext:
          allowPrivilegeEscalation: false
          readOnlyRootFilesystem: true
          runAsGroup: 65532
          runAsNonRoot: true
          runAsUser: 65532
        volumeMounts:
        - mountPath: /home/nonroot
          name: client-config
          readOnly: true
      terminationGracePeriodSeconds: 10
      volumes:
      - name: client-config
        secret:
          items:
          - key: client.yaml
            path: .redsky
          secretName: client-config
