apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
  name: remotes.gitkube.sh
spec:
  group: gitkube.sh
  version: v1alpha1
  scope: Namespaced
  names:
    plural: remotes
    singular: remote
    kind: Remote
    shortNames:
    - rem
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: gitkube
  namespace: kube-system
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: gitkube
subjects:
- kind: ServiceAccount
  name: gitkube
  namespace: kube-system
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
---
kind: ConfigMap
apiVersion: v1
metadata:
  name: gitkube-ci-conf
  namespace: kube-system
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: gitkubed
  name: gitkubed
  namespace: kube-system
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: gitkubed
    spec:
      serviceAccountName: gitkube
      containers:
      - command:
        - bash
        - /sshd-lib/start_sshd.sh
        image: hasura/gitkubed:v0.3.0
        imagePullPolicy: IfNotPresent
        name: sshd
        ports:
        - containerPort: 22
          protocol: TCP
        readinessProbe:
          initialDelaySeconds: 5
          periodSeconds: 2
          tcpSocket:
            port: 22
        resources:
          limits:
            cpu: 200m
            memory: 500Mi
          requests:
            cpu: 100m
            memory: 500Mi
        volumeMounts:
        - mountPath: /var/run/docker.sock
          name: docker-sock
        - mountPath: /hasura-data/group
          name: host-group
          readOnly: true
        - mountPath: /sshd-conf
          name: gitkube-ci-conf
      terminationGracePeriodSeconds: 30
      volumes:
      - hostPath:
          path: /var/run/docker.sock
        name: docker-sock
      - hostPath:
          path: /etc/group
        name: host-group
      - configMap:
          defaultMode: 420
          name: gitkube-ci-conf
        name: gitkube-ci-conf
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: gitkube-controller
  name: gitkube-controller
  namespace: kube-system
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: gitkube-controller
    spec:
      serviceAccountName: gitkube
      containers:
      - image: hasura/gitkube-controller:v0.3.0
        imagePullPolicy: IfNotPresent
        name: controller
        resources:
          requests:
            cpu: 50m
            memory: 200Mi
        env:
        - name: GITKUBE_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
     

