apiVersion: v1
kind: ServiceAccount
metadata:
  name: gitops-agent
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: gitops-agent
rules:
- apiGroups:
  - '*'
  resources:
  - '*'
  verbs:
  - '*'
- nonResourceURLs:
  - '*'
  verbs:
  - '*'
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: gitops-agent
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: gitops-agent
subjects:
- kind: ServiceAccount
  name: gitops-agent
  namespace: gitops-agent
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: gitops-agent
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: gitops-agent
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: gitops-agent
    spec:
      containers:
      - command:
        - gitops
        - /tmp/git/repo
        - --path
        - guestbook
        image: argoproj/gitops-agent:latest
        name: gitops-agent
        volumeMounts:
        - mountPath: /tmp/git
          name: git
      - args:
        - --webhook-url
        - http://localhost:9001/api/v1/sync
        - --dest
        - repo
        env:
        - name: GIT_SYNC_REPO
          value: https://github.com/argoproj/argocd-example-apps
        image: registry.k8s.io/git-sync:v3.1.6
        name: git-sync
        volumeMounts:
        - mountPath: /tmp/git
          name: git
      serviceAccountName: gitops-agent
      volumes:
      - emptyDir: {}
        name: git
