apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: kube-keepalived-vip
  namespace: keepalived
  labels:
    k8s-app: kube-keepalived-vip
spec:
  selector:
    matchLabels:
      k8s-app: kube-keepalived-vip
  template:
    metadata:
      labels:
        k8s-app: kube-keepalived-vip
        app: nginx-sidecar
    spec:
      serviceAccount: kube-vip
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: lb
                operator: NotIn
                values:
                - nginx
      hostNetwork: true
      containers:
        - name: nginx-sidecar
          image: onlineshop/nginx
          ports:
          - containerPort: 80
        - image: 10.10.101.175/library/kube-keepalived-vip:0.35
          name: kube-keepalived-vip
          imagePullPolicy: Always
          livenessProbe:
            httpGet:
              path: /health
              port: 8080
            initialDelaySeconds: 15
            timeoutSeconds: 3
          securityContext:
            privileged: true
          volumeMounts:
            - mountPath: /lib/modules
              name: modules
              readOnly: true
            - mountPath: /dev
              name: dev
          # use downward API
          env:
            - name: POD_NAME
              valueFrom:
                fieldRef:
                  fieldPath: metadata.name
            - name: POD_NAMESPACE
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
          # to use unicast
          args:
            - --services-configmap=default/vip-configmap
            # unicast uses the ip of the nodes instead of multicast
            # this is useful if running in cloud providers (like AWS)
            #- --use-unicast=true
      volumes:
        - name: modules
          hostPath:
            path: /lib/modules
        - name: dev
          hostPath:
            path: /dev
      #nodeSelector:
      #      #  type: worker
