apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: log-shipper
  namespace: observability
spec:
  selector:
    matchLabels:
      app: log-shipper
  template:
    metadata:
      labels:
        app: log-shipper
    spec:
      serviceAccountName: log-shipper
      hostPID: true
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001
      containers:
        - name: shipper
          image: registry.example.com/log-shipper:3.4.1
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
          volumeMounts:
            - name: pod-logs
              mountPath: /var/log/pods
              readOnly: true
        - name: debug
          image: nicolaka/netshoot
          securityContext:
            privileged: true
            runAsUser: 0
            capabilities:
              add: ["SYS_ADMIN"]
          volumeMounts:
            - name: containerd
              mountPath: /run/containerd/containerd.sock
      volumes:
        - name: pod-logs
          hostPath:
            path: /var/log/pods
        - name: containerd
          hostPath:
            path: /run/containerd/containerd.sock
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: log-shipper
  namespace: observability
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: log-shipper-debug
subjects:
  - kind: ServiceAccount
    name: log-shipper
    namespace: observability
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
