# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: rover-daemonset
  labels:
    app: rover
spec:
  selector:
    matchLabels:
      app: rover
  template:
    metadata:
      labels:
        app: rover
    spec:
      serviceAccountName: skywalking-rover-sa
      containers:
        - name: rover
          image: ${SW_ROVER_IMAGE}
          imagePullPolicy: Always
          securityContext:
            capabilities:
              add:
                - SYS_PTRACE
                - SYS_ADMIN
            privileged: true
          volumeMounts:
            - name: host
              mountPath: /host
              readOnly: true
          env:
            - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ACTIVE
              value: "true"
            - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_NODE_NAME
              valueFrom:
                fieldRef:
                  fieldPath: spec.nodeName
            - name: ROVER_BACKEND_ADDR
              value: ${BACKEND_SERVICE}:11800
            - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_ENVOY_SERVICE_NAME
              value: agentless::{{.Pod.LabelValue "service.istio.io/canonical-name,app.kubernetes.io/name,app"}}
            - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_ISTIO_APPLICATION_SERVICE_NAME
              value: agentless::{{.Pod.LabelValue "service.istio.io/canonical-name,app.kubernetes.io/name,app"}}
            - name: ROVER_PROCESS_DISCOVERY_KUBERNETES_ANALYZER_K8S_SERVICE_NAME
              value: skywalking-showcase::{{.Pod.ServiceName}}.{{.Pod.Namespace}}
      hostPID: true
      hostNetwork: true
      dnsPolicy: ClusterFirstWithHostNet
      volumes:
        - name: host
          hostPath:
            path: /
            type: Directory