################################################################################
# Copyright 2020 IBM Corp. 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: v1
kind: Namespace
metadata:
  name: "razeedeploy"
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: razeedeploy-sa
  namespace: "razeedeploy"
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: razeedeploy-admin-cr
rules:
- apiGroups:
  - '*'
  resources:
  - '*'
  verbs:
  - '*'
- nonResourceURLs:
  - '*'
  verbs:
  - '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: razeedeploy-rb
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: razeedeploy-admin-cr
subjects:
- kind: ServiceAccount
  name: razeedeploy-sa
  namespace: "razeedeploy"
---
apiVersion: batch/v1
kind: Job
metadata:
  name: "razeedeploy-job-1783037706441"
  namespace: "razeedeploy"
spec:
  template:
    spec:
      serviceAccountName: razeedeploy-sa
      securityContext:
        runAsUser: 1000
        runAsGroup: 1000
        fsGroup: 1000
      containers:
      - name: "razeedeploy-job-1783037706441"
        image: "us.icr.io/armada-master/razeedeploy-delta:3.0.12_29e2eca"
        env:
        - name: USER_AGENT_NAME
          value: razee-io/razeedeploy-delta
        - name: USER_AGENT_VERSION
          value: "3.0.12"
        command: ["./node_modules/.bin/razeedeploy-delta", "remove", "--namespace=razeedeploy"]
        args: ["--razeedash-url=https://config.satellite.cloud.ibm.com/api/v2","--clustersubscription=4.0.9_29e2eca","--mustachetemplate=4.0.12_29e2eca","--remoteresource=4.0.11_29e2eca","--watch-keeper=2.0.8_29e2eca","--file-source=https://s3.us.cloud-object-storage.appdomain.cloud/razee-io","--file-path={{install_version}}/us/resource.yaml"]
        # see README.md for args options. https://github.com/razee-io/razeedeploy-delta/blob/master/README.md
        resources:
          limits:
            memory: 200Mi
          requests:
            memory: 75Mi
      restartPolicy: Never
  backoffLimit: 2
  # Fail job if not complete in 2h
  activeDeadlineSeconds: 7200
  # Delete finished jobs after 2h
  ttlSecondsAfterFinished: 7200
