apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: flinkdeployments.flink.apache.org
spec:
  group: flink.apache.org
  names:
    kind: FlinkDeployment
    listKind: FlinkDeploymentList
    plural: flinkdeployments
    singular: flinkdeployment
    shortNames:
    - fd
    - flinkdeploy
  scope: Namespaced
  versions:
  - name: v1beta1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        x-kubernetes-preserve-unknown-fields: true
    subresources:
      status: {}
    additionalPrinterColumns:
    - name: Job Status
      type: string
      jsonPath: .status.jobStatus
    - name: Flink Version
      type: string
      jsonPath: .spec.flinkVersion
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: flinksessionjobs.flink.apache.org
spec:
  group: flink.apache.org
  names:
    kind: FlinkSessionJob
    listKind: FlinkSessionJobList
    plural: flinksessionjobs
    singular: flinksessionjob
    shortNames:
    - fsj
    - flinksessionjob
  scope: Namespaced
  versions:
  - name: v1beta1
    served: true
    storage: true
    schema:
      openAPIV3Schema:
        type: object
        x-kubernetes-preserve-unknown-fields: true
    subresources:
      status: {}
    additionalPrinterColumns:
    - name: Job Status
      type: string
      jsonPath: .status.jobStatus
    - name: Flink Deployment
      type: string
      jsonPath: .spec.deploymentName
    - name: Age
      type: date
      jsonPath: .metadata.creationTimestamp
---
apiVersion: v1
kind: Namespace
metadata:
  name: flink-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: flink-kubernetes-operator
  namespace: flink-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: flink-kubernetes-operator
rules:
- apiGroups:
  - ""
  resources:
  - configmaps
  verbs:
  - create
  - delete
  - deletecollection
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - ""
  resources:
  - events
  verbs:
  - create
  - get
  - patch
- apiGroups:
  - ""
  resources:
  - nodes
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - ""
  resources:
  - namespaces
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - ""
  resources:
  - persistentvolumeclaims
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - ""
  resources:
  - pods
  verbs:
  - create
  - delete
  - deletecollection
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - ""
  resources:
  - secrets
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - ""
  resources:
  - serviceaccounts
  verbs:
  - create
  - delete
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - ""
  resources:
  - services
  verbs:
  - create
  - delete
  - deletecollection
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - apps
  resources:
  - deployments
  verbs:
  - create
  - delete
  - deletecollection
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - batch
  resources:
  - jobs
  - cronjobs
  verbs:
  - create
  - delete
  - deletecollection
  - get
  - list
  - patch
  - update
  - watch
- apiGroups:
  - flink.apache.org
  resources:
  - flinkdeployments
  - flinkdeployments/status
  - flinksessionjobs
  - flinksessionjobs/status
  verbs:
  - create
  - delete
  - deletecollection
  - get
  - list
  - patch
  - update
  - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: flink-kubernetes-operator
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: flink-kubernetes-operator
subjects:
- kind: ServiceAccount
  name: flink-kubernetes-operator
  namespace: flink-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: flink-kubernetes-operator
  namespace: flink-system
  labels:
    app: flink-kubernetes-operator
spec:
  replicas: 1
  selector:
    matchLabels:
      app: flink-kubernetes-operator
  template:
    metadata:
      labels:
        app: flink-kubernetes-operator
    spec:
      serviceAccountName: flink-kubernetes-operator
      containers:
      - name: flink-kubernetes-operator
        image: apache/flink-kubernetes-operator:1.8.0
        command: ["/docker-entrypoint.sh"]
        args: ["operator"]
        env:
        - name: POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: OPERATOR_NAME
          value: flink-kubernetes-operator
        - name: LEADER_ELECTION_ID
          value: flink-kubernetes-operator
        - name: LEADER_ELECTION_NAMESPACE
          value: flink-system
        ports:
        - containerPort: 8085
          name: metrics
        resources:
          requests:
            cpu: 100m
            memory: 128Mi
          limits:
            cpu: 500m
            memory: 512Mi
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8085
          initialDelaySeconds: 15
          periodSeconds: 20
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8085
