# Copyright (c) 2022, Nadun De Silva. All Rights Reserved.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#   http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: replicator
  labels:
    controller: replicator
  annotations:
    checkov.io/skip1: CKV_K8S_9=The readiness probe not required since controller does not accept requests
    checkov.io/skip2: CKV_K8S_14=The image will be set by the pipeline in the release
    checkov.io/skip3: CKV_K8S_38=The service account required for authentication requests for copying resources
    checkov.io/skip4: CKV_K8S_43=The image will be set by the pipeline in the release
spec:
  replicas: 1
  selector:
    matchLabels:
      controller: replicator
  template:
    metadata:
      labels:
        controller: replicator
    spec:
      containers:
      - name: replicator
        image: nadunrds/k8s-replicator
        env:
        - name: CONTROLLER_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        volumeMounts:
        - name: conf-vol
          mountPath: /etc/replicator
        resources:
          requests:
            memory: "128Mi"
            cpu: "250m"
          limits:
            memory: "256Mi"
            cpu: "500m"
        livenessProbe:
          httpGet:
            path: /health
            port: 8080
        securityContext:
          runAsUser: 10500
          runAsGroup: 10500
          allowPrivilegeEscalation: false
          readOnlyRootFilesystem: true
          capabilities:
            drop:
            - all
      volumes:
      - name: conf-vol
        configMap:
          name: replicator
      serviceAccountName: replicator
      securityContext:
        seccompProfile:
          type: RuntimeDefault
