apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: netclient
  labels:
    app: netclient
spec:
  selector:
    matchLabels:
      app: netclient
  replicas: 1
  template:
    metadata:
      labels:
        app: netclient
    spec:
      hostNetwork: true
      containers:
      - name: netclient
        image: gravitl/netclient:v0.7.2
        command: ['bash', '-c', "netclient checkin -n $NETWORK; sleep $SLEEP"]
        env:
        - name: ACCESS_TOKEN
          value: "XXXX"
        - name: NETWORK
          value: "YYYY"
        - name: SLEEP
          value: 30
        volumeMounts:
        - mountPath: /etc/netclient
          name: etc-netclient
        - mountPath: /usr/bin/wg
          name: wg
        securityContext:
          privileged: true
      initContainers:
      - name: netclient-join
        image: gravitl/netclient:v0.7.2
        command: ['bash', '-c', "netclient join -t $ACCESS_TOKEN --daemon off"]
        env:
        - name: ACCESS_TOKEN
          value: "XXXX"
        volumeMounts:
        - mountPath: /etc/netclient
          name: etc-netclient
        - mountPath: /usr/bin/wg
          name: wg
        securityContext:
          privileged: true
  volumes:
  - hostPath:
      path: /etc/netclient
      type: DirectoryOrCreate
    name: etc-netclient
  - hostPath:
      path: /usr/bin/wg
      type: File
    name: wg
