apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: nginx-lb
  namespace: kube-system
  labels:
    k8s-app: nginx-lb
spec:
  selector:
    matchLabels:
      name: nginx-lb
  template:
    metadata:
      labels:
        name: nginx-lb
    spec:
      volumes:
      - name: nginx-lb-conf
        hostPath:
          type: File
          path: /etc/kubernetes/nginx-lb/nginx-lb.conf
      - name: nginx-lb-conf-default
        hostPath:
          type: File
          path: /etc/kubernetes/nginx-lb/nginx-lb.conf.default
      containers:
      - name: nginx-lb
        image: nginx:latest
        imagePullPolicy: IfNotPresent
        livenessProbe:
          failureThreshold: 8
          tcpSocket:
            port: 16443
          periodSeconds: 10  
          initialDelaySeconds: 15
          timeoutSeconds: 15
        volumeMounts:
        - name: nginx-lb-conf
          mountPath: /etc/nginx/nginx.conf
          readOnly: true
        - name: nginx-lb-conf-default
          mountPath: /etc/nginx/conf.d/default.conf
      hostNetwork: true
      nodeSelector:
        node-role.kubernetes.io/master: "true"
      tolerations:
        - key: "node-role.kubernetes.io/master"
          effect: "NoSchedule"
