edgedelta-agent.yaml

Example Agent Manifest

The following agent manifest can be used along with this ConfigMap to manage the Edge Delta agent using a local configuration.

apiVersion: v1
kind: Namespace
metadata:
  name: edgedelta
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: edgedelta
  namespace: edgedelta
  annotations:
    prometheus.io/scrape: "true"
  labels:
    k8s-app: edgedelta-logging
    version: v1
    kubernetes.io/cluster-service: "true"
spec:
  selector:
    matchLabels:
      k8s-app: edgedelta-logging
  updateStrategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 1
  template:
    metadata:
      labels:
        k8s-app: edgedelta-logging
        version: v1
        kubernetes.io/cluster-service: "true"
    spec:
      serviceAccountName: edgedelta
      hostPID: true
      hostNetwork: true
      containers:
      - name: edgedelta-agent
        image: gcr.io/edgedelta/agent:v0.1.95
        env:
          - name: ED_SKIP_CONF_DOWNLOAD
            value: "1"
          - name: ED_ORG_ID
            valueFrom:
              secretKeyRef:
                key: ed-org-id
                name: ed-org-id
          - name: ED_API_KEY
            valueFrom:
              # kubectl create secret generic ed-api-key \
              #   --namespace=edgedelta \
              #   --from-literal=ed-api-key="2c7a5780-..."
              secretKeyRef:
                key: ed-api-key
                name: ed-api-key
          # Uncomment if proxy setup needed
          # More details: https://github.com/golang/net/blob/master/http/httpproxy/proxy.go#L27
          # - name:  HTTP_PROXY
          #   value: my.proxy.com
          # - name:  NO_PROXY
          #   value: skip.proxy.com
          # pass node hostname to agent
          - name: ED_HOST_OVERRIDE
            valueFrom:
              fieldRef:
                fieldPath: spec.nodeName
          - name: ED_LEADER_ELECTION_ENABLED
            value: "1"
          - name: TRACER_SERVER_PORT
            value: "9595"
          - name: ED_ENABLE_TRAFFIC_TRACER
            value: "1"
          - name: ED_SERVICE_DNS_REQUIRED
            value: "1"
          - name: ED_COMPACT_SERVICE_ENDPOINT
            value: ed-compactor-svc.edgedelta.svc.cluster.local:9199
        command:
          - /edgedelta/edgedelta
          - -c
          - /config/config.yml          
        resources:
          limits:
            memory: 2048Mi
          requests:
            cpu: 200m
            memory: 256Mi
        volumeMounts:
          - name: edconfig
            mountPath: /config/          
          - name: varlog
            mountPath: /var/log
            readOnly: true
          - name: varlibdockercontainers
            # Some Kubernetes distributions may use /docker/containers instead of standard /var/lib/docker/containers
            # Update mountPath to match the actual container log folder path
            mountPath: /var/lib/docker/containers
            readOnly: true
          - name: persisting-cursor-storage
            mountPath: /var/lib/edgedelta
          - name: cgroup
            mountPath: /sys/fs/cgroup
          - name: debugfs
            mountPath: /sys/kernel/debug
          - name: netns
            mountPath: /var/run/netns
          - name: proc
            mountPath: /proc
        securityContext:
          privileged: true
        # Required for OpenShift or SELinux enabled K8s clusters
        # runAsUser: 0
      terminationGracePeriodSeconds: 10
      volumes:
        - name: edconfig
          configMap:
            name: edgedelta-agent-config        
        - name: varlog
          hostPath:
            path: /var/log
        - name: varlibdockercontainers
          hostPath:
            # Update path below if you changed volumeMounts varlibdockercontainers mountPath
            path: /var/lib/docker/containers
        - name: persisting-cursor-storage
          hostPath:
            path: /var/lib/edgedelta
            type: DirectoryOrCreate
        - name: cgroup
          hostPath:
            path: /sys/fs/cgroup
        - name: debugfs
          hostPath:
            path: /sys/kernel/debug
        - name: netns
          hostPath:
            path: /var/run/netns
        - name: proc
          hostPath:
            path: /proc
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: edgedelta
subjects:
- kind: ServiceAccount
  name: edgedelta
  namespace: edgedelta
roleRef:
  kind: ClusterRole
  name: edgedelta
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: edgedelta
  labels:
    k8s-app: edgedelta-logging
rules:
- apiGroups: [""] # "" indicates the core API group
  resources:
  - namespaces
  - pods
  - events
  - nodes
  - nodes/metrics
  - services
  verbs:
  - get
  - watch
  - list
- apiGroups: [""] # "" indicates the core API group
  resources:
  - events
  verbs:
  - create
- apiGroups: ["apps"]
  resources:
  - daemonsets
  - deployments
  - replicasets
  - statefulsets
  verbs:
  - watch
  - list
- apiGroups: ["batch"]
  resources:
  - jobs
  - cronjobs
  verbs:
  - watch
  - list
- apiGroups: ["coordination.k8s.io"]
  resources:
  - leases
  verbs:
  - get
  - list
  - watch
  - create
  - update
  - patch
  - delete
- apiGroups: ["metrics.k8s.io"]
  resources:
  - pods
  - nodes
  verbs:
  - get
  - list
  - watch
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: edgedelta
  namespace: edgedelta
  labels:
    k8s-app: edgedelta-logging
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: edgedelta-compactor
  namespace: edgedelta
  labels:
    k8s-app: edgedelta-compactor
    version: v1
    kubernetes.io/cluster-service: "true"
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: edgedelta-compactor
  serviceName: ed-compactor-svc
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        k8s-app: edgedelta-compactor
        version: v1
        kubernetes.io/cluster-service: "true"
    spec:
      serviceAccountName: edgedelta
      containers:
      - name: edgedelta-compactor
        image: gcr.io/edgedelta/agent:v0.1.95
        ports:
          - name: compactor
            containerPort: 9199
        env:
          - name: ED_AGENT_MODE
            value: compactor
          - name: ED_COMPACTOR_PORT
            value: "9199"
          - name: ED_COMPACTOR_DATA_DIR
            value: /var/edgedelta-compactor
          - name: ED_HOST_OVERRIDE
            valueFrom:
              fieldRef:
               fieldPath: metadata.name          
          - name: ED_API_KEY
            valueFrom:
              secretKeyRef:
                name: ed-api-key
                key: ed-api-key
          - name: ED_TRACE_FILES
            value: ""
        resources:
            limits:
              cpu: 2000m
              memory: 2000Mi
            requests:
              cpu: 1000m
              memory: 1000Mi
        imagePullPolicy: Always
        volumeMounts:
          - name: compactor-data
            mountPath: /var/edgedelta-compactor
      terminationGracePeriodSeconds: 60
      volumes:
  volumeClaimTemplates:
  - metadata:
      name: compactor-data
    spec:
      accessModes: [ "ReadWriteOnce" ]
      resources:
        requests:
          storage: 30Gi
---
kind: Service
apiVersion: v1
metadata:
  name: ed-compactor-svc
  namespace: edgedelta
spec:
  selector:
    k8s-app: edgedelta-compactor
  ports:
    - port: 9199
      name: compactor-port

See Also:

GitOps Principles Deployment of Edge Delta