---
apiVersion: batch/v1
kind: Job
metadata:
  labels:
    run: create-rolebinding
  name: create-rolebinding
spec:
  template:
    metadata:
      labels:
        run: create-rolebinding
    spec:
      containers:
      - name: curl
        image: curlimages/curl:7.70.0
        command: ["/bin/sh", "-c"]
        args: ["curl -s --fail -X POST $(ENDPOINT) -H \"Content-Type: application/json;charset=utf-8\" -H \"Authorization: Basic $(BASIC_AUTH)\" --data '{\"generated_for_user\":\"test-user\",\"roleName\":\"template-namespaced-resources___developer\",\"namespace\":\"permission-manager\",\"roleKind\":\"ClusterRole\",\"subjects\":[{\"kind\":\"ServiceAccount\",\"name\":\"test-user\",\"namespace\":\"permission-manager\"}],\"rolebindingName\":\"test-user___template-namespaced-resources___developer___permission-manager\"}'"]
        env:
          - name: ENDPOINT
            value: http://permission-manager.permission-manager.svc.cluster.local:4000/api/create-rolebinding
          - name: BASIC_AUTH
            value: YWRtaW46MXYyZDFlMmU2N2RT
      restartPolicy: OnFailure
