apiVersion: v1
kind: ConfigMap
metadata:
  annotations:
    operator.openyurt.io/skip-reconcile: "true"
  name: yurt-operator-yurt-hub-template
  namespace: kube-system
data:
  yurt-hub-static-cloud-pod: |
    apiVersion: v1
    kind: Pod
    metadata:
      labels:
        k8s-app: yurt-hub
      name: yurt-hub
      namespace: kube-system
    spec:
      volumes:
      - name: hub-dir
        hostPath:
          path: /var/lib/yurthub
          type: DirectoryOrCreate
      - name: kubernetes
        hostPath:
          path: /etc/kubernetes
          type: Directory
      - name: pem-dir
        hostPath:
          path: /var/lib/kubelet/pki
          type: Directory
      containers:
      - name: yurt-hub
        image: {{ .image }}
        volumeMounts:
        - name: hub-dir
          mountPath: /var/lib/yurthub
        - name: kubernetes
          mountPath: /etc/kubernetes
        - name: pem-dir
          mountPath: /var/lib/kubelet/pki
        command:
        - yurthub
        args:
        - --v=2
        - --server-addr={{ .apiServerAddress }}
        - --node-name=$(NODE_NAME)
        - --working-mode=cloud
        livenessProbe:
          httpGet:
            host: 127.0.0.1
            path: /v1/healthz
            port: 10267
          initialDelaySeconds: 300
          periodSeconds: 5
          failureThreshold: 3
        resources:
          requests:
            cpu: 150m
            memory: 150Mi
          limits:
            memory: 300Mi
        securityContext:
          capabilities:
            add: ["NET_ADMIN", "NET_RAW"]
        env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
      hostNetwork: true
      priorityClassName: system-node-critical
      priority: 2000001000
  yurt-hub-static-edge-pod: |
    apiVersion: v1
    kind: Pod
    metadata:
      labels:
        k8s-app: yurt-hub
      name: yurt-hub
      namespace: kube-system
    spec:
      volumes:
      - name: hub-dir
        hostPath:
          path: /var/lib/yurthub
          type: DirectoryOrCreate
      - name: kubernetes
        hostPath:
          path: /etc/kubernetes
          type: Directory
      - name: pem-dir
        hostPath:
          path: /var/lib/kubelet/pki
          type: Directory
      containers:
      - name: yurt-hub
        image: {{ .image }}
        volumeMounts:
        - name: hub-dir
          mountPath: /var/lib/yurthub
        - name: kubernetes
          mountPath: /etc/kubernetes
        - name: pem-dir
          mountPath: /var/lib/kubelet/pki
        command:
        - yurthub
        args:
        - --v=2
        - --server-addr={{ .apiServerAddress }}
        - --node-name=$(NODE_NAME)
        - --working-mode=edge
        livenessProbe:
          httpGet:
            host: 127.0.0.1
            path: /v1/healthz
            port: 10267
          initialDelaySeconds: 300
          periodSeconds: 5
          failureThreshold: 3
        resources:
          requests:
            cpu: 150m
            memory: 150Mi
          limits:
            memory: 300Mi
        securityContext:
          capabilities:
            add: ["NET_ADMIN", "NET_RAW"]
        env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
      hostNetwork: true
      priorityClassName: system-node-critical
      priority: 2000001000
  yurt-hub-config: |
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: yurt-hub-cfg
      namespace: kube-system
      annotations:
        operator.openyurt.io/skip-reconcile: "true"
    data:
      cache_agents: ""
  yurt-hub-cluster-role: |
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRole
    metadata:
      name: yurt-hub
    rules:
      - apiGroups:
          - ""
        resources:
          - events
        verbs:
          - get
      - apiGroups:
          - apps.openyurt.io
        resources:
          - nodepools
        verbs:
          - list
          - watch
      - apiGroups:
          - ""
        resources:
          - configmaps
        resourceNames:
          - yurt-hub-cfg
        verbs:
          - list
          - watch
  yurt-hub-cluster-role-binding: |
    apiVersion: rbac.authorization.k8s.io/v1
    kind: ClusterRoleBinding
    metadata:
      name: yurt-hub
    roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: yurt-hub
    subjects:
      - apiGroup: rbac.authorization.k8s.io
        kind: Group
        name: system:nodes
  yurt-kubelet-config: |
    apiVersion: v1
    clusters:
    - cluster:
        server: http://127.0.0.1:10261
      name: default-cluster
    contexts:
    - context:
        cluster: default-cluster
        namespace: default
        user: default-auth
      name: default-context
    current-context: default-context
    kind: Config
    preferences: {}
