################
# CREATE CONFIGMAP IN ADVANCE e.g.
# kubectl create configmap alto-inspect-vars --from-literal=alto.ip=1.1.1.1 -n kube-system
# ##############
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: alto-inspect
  namespace: kube-system
spec:
  selector:
    matchLabels:
      app: alto-inspect
  template:
    metadata:
      labels:
        app: alto-inspect
    spec:
      hostNetwork: true
      containers:
        - name: alto-inspect
          image: scotty2hotty/k8s-visibility:v1
          env: 
            - name: FW_IP
              valueFrom:
                configMapKeyRef:
                  # The ConfigMap containing the value you want to assign to FW_IP
                  name: alto-inspect-vars
                  # Specify the key associated with the value
                  key: alto.ip
            - name: PYTHONPATH
              value: "/usr/local/lib/python2.7"
          command: [ "/bin/bash", "-c" ]
          args:
            - echo starting;
              echo \n >> /root/strongswan-cfg/ipsec.conf/root/strongswan-cfg/ipsec.conf;
              echo "    right=$FW_IP" >> /root/strongswan-cfg/ipsec.conf;
              /root/nwcfg/runall.sh;
          securityContext:
            privileged: true
            capabilities:
              add: ["SYS_ADMIN"]
          volumeMounts:
            - name: docker-sock-mount
              mountPath: /var/run/docker.sock
            - name: docker-netns-mount
              mountPath: /var/run/netns/
            - name: docker-lib-modules
              mountPath: /lib/modules/
      volumes:
        - name: docker-sock-mount
          hostPath:
            path: /var/run/docker.sock
          # directory location on host
        - name: docker-netns-mount
          hostPath:
            path: /var/run/docker/netns/
        - name: docker-lib-modules
          hostPath:
            path: /lib/modules/
