{%- set resourceName = kolla_kubernetes.cli.args.resource_name %}
{%- set netHostTrue = "yes" %}
{%- import "services/common/common-lib.yml.j2" as lib with context %}
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: iscsi-iscsid
  labels:
    component: iscsid
    system: iscsid
  namespace: {{ kolla_kubernetes_namespace }}
spec:
  template:
    metadata:
      labels:
        component: iscsid
        system: iscsid
      annotations:
        pod.alpha.kubernetes.io/init-containers: '[
          {
             "name": "initialize-iscsid",
             "image": "{{ kolla_toolbox_image_full }}",
             "command": [
                 "sh",
                 "-ce",
                 "cp -a /srv/configmap/..data/* /srv/pod-main-config/; "],
             "volumeMounts": [
                {
                   "name": "iscsid-configmap",
                   "mountPath": "/srv/configmap"
                },
                {
                   "name": "pod-main-config",
                   "mountPath": "/srv/pod-main-config"
                }
             ]
          }
        ]'
    spec:
      hostNetwork: True
      hostIPC: True
      nodeSelector:
{%- set selector = kolla_kubernetes_hostlabel_compute |
                         default(kolla_kubernetes_hostlabel_controller)
%}
          {{ selector.key }}: {{ selector.value }}
      containers:
        - image: {{ iscsid_image_full }}
          name: main
          securityContext:
            privileged: true
          env:
            - name: KOLLA_CONFIG_STRATEGY
              value: COPY_ALWAYS
          volumeMounts:
{{ lib.common_volume_mounts(indent=12) }}
            - mountPath: {{ container_config_directory }}
              name: pod-main-config
              readOnly: true
            - mountPath: /run
              name: run
            - mountPath: /dev
              name: dev
            - mountPath: /sys/fs/cgroup
              name: sys-fs-cgroup
            - mountPath: /lib/modules
              name: lib-modules
            - mountPath: /etc/iscsid
              name: iscsid-info
      volumes:
{{ lib.common_volumes(indent=8) }}
        - name: kolla-kubernetes-events
          emptyDir: {}
        - name: pod-main-config
          emptyDir: {}
        - name: iscsid-configmap
          configMap:
            name: iscsid
        - name: lib-modules
          hostPath:
            path: /lib/modules
        - name: run
          hostPath:
            path: /run
        - name: dev
          hostPath:
            path: /dev
        - name: sys-fs-cgroup
          hostPath:
            path: /sys/fs/cgroup
        - name: iscsid-info
          hostPath:
            path: /etc/iscsid
