Skip to content

Deploy a collector fleet on Kubernetes

This guide deploys a collector fleet on Kubernetes: one collector pod per node, enrolled with LinkMesh for central config and throughput. The collector is upstream otelcol-contrib, run by the upstream opampsupervisor, both from the official OpenTelemetry release images. LinkMesh ships no collector distribution of its own; it is the control plane that pushes the pipeline config over OpAMP and reads back throughput.

If your hosts are plain Linux (VMs, bare metal, EC2 instances), the Add a collector flow with the per-host installer is simpler. This page is the Kubernetes version of the same runtime.

Some platforms refuse what the node collectors need from the node, so the Add Collector wizard renders the install in one variant per platform. It pre-selects OpenShift or GKE Autopilot when your collectors have already reported that platform; EKS Fargate cannot be detected and is always picked by hand. The commands in Deploy the fleet below are the Standard variant.

PlatformWhat the variant doesNot available
StandardAny conformant Kubernetes cluster: kind, k3s, RKE2, kubeadm, GKE Standard, EKS and AKS node groups. Also starts on OpenShift.Nothing
OpenShiftRuns the node collectors under a SecurityContextConstraints of their own, the narrowest one that admits them. OpenShift monitoring already collects cluster state and node metrics: read those from it rather than collecting them twice.Nothing
GKE AutopilotAutopilot refuses writable host directories, so nothing is mounted from the node. Read positions and queued data are kept in the pod and are lost when it is replaced.
  • Kubernetes Pod Logs (pod log files are on the node)
  • Kubernetes Node Metrics and the kubelet and cAdvisor scrapes
  • Host Metrics and the system journal
EKS FargateFargate runs no DaemonSets and mounts nothing from the node, so this is one collector pod. A Fargate profile must select the linkmesh namespace. Kubernetes attributes are added only for pods on the collector's own node, which on Fargate is the collector itself.
  • Kubernetes Pod Logs (pod log files are on the node)
  • Kubernetes Node Metrics and the kubelet and cAdvisor scrapes
  • Host Metrics and the system journal

A variant other than Standard tells LinkMesh which one it is, through an attribute in the OpAMP supervisor’s agent description. The stack view then marks what the platform cannot collect as not available, with no action offered, even where the platform cannot be detected. On OpenShift it reads cluster state, capacity and host metrics as Provided by OpenShift: OpenShift monitoring already collects them. On EKS Fargate, a Fargate profile must select the linkmesh namespace so that the collector pod runs on Fargate.

The rendered variants, with the same placeholders as below:

OpenShift
# Deploy an otelcol-contrib + OpAMP collector fleet on Kubernetes.
# An initContainer stages the upstream supervisor binary into the upstream
# collector image (neither image contains both); the supervisor then applies
# the config LinkMesh pushes over OpAMP to the collector alongside it.
#
# OpenShift variant.
# The collectors run under a SecurityContextConstraints of their own
# (linkmesh-otelcol below) that allows only what they ask for. OpenShift
# monitoring already collects cluster state and node metrics: read those from
# it rather than collecting them twice.
kubectl create namespace linkmesh --dry-run=client -o yaml | kubectl apply -f -

kubectl apply -n linkmesh -f - <<'EOF'
apiVersion: v1
kind: ServiceAccount
metadata: { name: linkmesh-otelcol, namespace: linkmesh }
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata: { name: linkmesh-otelcol }
rules:
# The k8sattributes processor LinkMesh attaches to every Kubernetes source
# reads pods and namespaces, and names each pod's owner (Deployment,
# StatefulSet, DaemonSet, Job, CronJob). Without these the collector runs but
# logs "pods is forbidden" continuously and enriches nothing. The workload
# reads are granted for the whole node role up front, so that turning on a
# later enrichment never needs this manifest re-applied. Read-only throughout.
- apiGroups: [""]
  resources: ["pods", "namespaces", "nodes"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
  resources: ["replicasets", "deployments", "statefulsets", "daemonsets"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
  resources: ["jobs", "cronjobs"]
  verbs: ["get", "list", "watch"]
# Kubernetes Node Metrics (kubeletstats) reads its own node's kubelet
# (nodes/stats). The Kubernetes kubelet and container metrics sources scrape
# its /metrics and /metrics/cadvisor, which the kubelet authorizes as
# nodes/metrics — nodes/proxy does not cover them.
- apiGroups: [""]
  resources: ["nodes/stats", "nodes/proxy", "nodes/metrics"]
  verbs: ["get"]
# The Platform node-exporter source scrapes the node-exporter OpenShift
# monitoring already runs on each node. Its proxy lets a ServiceAccount read
# /metrics only when RBAC allows get on that URL. This also allows reading the
# API server's own /metrics. Read-only.
- nonResourceURLs: ["/metrics"]
  verbs: ["get"]
# On OpenShift, LinkMesh reads the cluster's Infrastructure object to tell
# which platform it runs on. The read goes to the object's status subresource,
# which needs its own grant. Elsewhere this API does not exist and the rule
# grants nothing.
- apiGroups: ["config.openshift.io"]
  resources: ["infrastructures", "infrastructures/status"]
  verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata: { name: linkmesh-otelcol }
roleRef: { apiGroup: rbac.authorization.k8s.io, kind: ClusterRole, name: linkmesh-otelcol }
subjects:
- { kind: ServiceAccount, name: linkmesh-otelcol, namespace: linkmesh }
---
# The default SCC (restricted-v2) refuses this DaemonSet: it mounts host
# directories and prepares one of them as root. This SCC admits it and allows
# nothing the pods below do not ask for: no privileged container, no privilege
# escalation, no host network, PID, IPC or port, no added capability.
apiVersion: security.openshift.io/v1
kind: SecurityContextConstraints
metadata: { name: linkmesh-otelcol }
allowHostDirVolumePlugin: true
allowPrivilegedContainer: false
allowPrivilegeEscalation: false
allowHostNetwork: false
allowHostPID: false
allowHostIPC: false
allowHostPorts: false
readOnlyRootFilesystem: false
allowedCapabilities: null
defaultAddCapabilities: null
requiredDropCapabilities: ["AUDIT_WRITE", "DAC_OVERRIDE", "FOWNER", "FSETID", "KILL", "MKNOD", "NET_BIND_SERVICE", "NET_RAW", "SETFCAP", "SETGID", "SETPCAP", "SETUID", "SYS_CHROOT"]
runAsUser: { type: RunAsAny }
seLinuxContext: { type: RunAsAny }
fsGroup: { type: MustRunAs }
supplementalGroups: { type: MustRunAs }
volumes: ["configMap", "emptyDir", "hostPath", "projected"]
# Nobody is given this SCC directly. The collector's service account may use
# it through the Role below, and only in this namespace.
users: []
groups: []
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata: { name: linkmesh-otelcol-scc }
rules:
- apiGroups: ["security.openshift.io"]
  resources: ["securitycontextconstraints"]
  resourceNames: ["linkmesh-otelcol"]
  verbs: ["use"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata: { name: linkmesh-otelcol-scc }
roleRef: { apiGroup: rbac.authorization.k8s.io, kind: Role, name: linkmesh-otelcol-scc }
subjects:
- { kind: ServiceAccount, name: linkmesh-otelcol, namespace: linkmesh }
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: linkmesh-supervisor
data:
  supervisor.yaml: |
    server:
      endpoint: "wss://linkmesh.example.com/v1/opamp"
      headers:
        Authorization: "Bearer <ENROLLMENT_TOKEN>"
    capabilities:
      accepts_remote_config: true
      reports_effective_config: true
      reports_health: true
      reports_own_metrics: true
      reports_available_components: true
    agent:
      # Native path inside the collector image this pod runs (see the
      # initContainer below — the supervisor is the staged binary, the
      # collector is the image's own).
      executable: /otelcol-contrib
      # LinkMesh reads which Kubernetes platform the collector runs on while
      # the collector starts. Off a cloud that takes several seconds, longer
      # than the supervisor's default wait of 5s for a new config, which would
      # then be reported as failed although it works. The attribute below
      # tells LinkMesh this supervisor waits long enough.
      config_apply_timeout: 30s
      description:
        non_identifying_attributes:
          linkmesh.config_apply_timeout: "30s"
          # The node this pod runs on. LinkMesh uses it to find the agent on
          # the same node for Live Capture (the enrichment check). The
          # supervisor resolves ${env:...} from the pod's environment.
          k8s.node.name: "${env:K8S_NODE_NAME}"
          # Which platform variant of this manifest was applied. LinkMesh uses
          # it to show which sources cannot run here.
          linkmesh.k8s.install_preset: "openshift"
    storage:
      directory: /var/lib/otelcol-supervisor
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: linkmesh-otelcol
spec:
  selector:
    matchLabels: { app: linkmesh-otelcol }
  # A new pod must not start on a node until the old one has gone: both would
  # open the same state files under /var/lib/linkmesh/otelcol, the second
  # would wait on the first one's lock, and both would claim one identity. This is the DaemonSet default,
  # stated so nobody turns on maxSurge without reading this.
  updateStrategy:
    type: RollingUpdate
    rollingUpdate: { maxUnavailable: 1, maxSurge: 0 }
  template:
    metadata:
      labels: { app: linkmesh-otelcol }
    spec:
      serviceAccountName: linkmesh-otelcol
      # Run on control-plane nodes too. On a cluster that runs its own control
      # plane (kubeadm, kind, RKE2, k3s with tainted servers) that node holds
      # etcd, the API server and the scheduler; without this it gets no node
      # metrics and no pod logs while cluster-wide metrics still look complete.
      # Managed control planes (GKE, EKS, AKS) have no such node. Other taints
      # (GPU or dedicated pools) are not tolerated: add them here if wanted.
      tolerations:
      - { key: node-role.kubernetes.io/control-plane, operator: Exists, effect: NoSchedule }
      initContainers:
      # Copies the supervisor out of its own release image into a volume the
      # collector image can execute it from. Required because neither upstream
      # image is a complete runtime on its own: this image has no collector in
      # it anywhere, and the collector image has no supervisor. The binary is
      # statically linked, so it runs unchanged in the (distroless) collector
      # image. Keep this tag and the collector tag below equal.
      - name: stage-supervisor
        image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-opampsupervisor:0.165.0
        command: ["cp", "/usr/local/bin/opampsupervisor", "/opt/linkmesh/opampsupervisor"]
        securityContext:
          allowPrivilegeEscalation: false
          capabilities: { drop: ["ALL"] }
        resources:
          requests: { cpu: 10m, memory: 32Mi }
          limits: { cpu: 100m, memory: 128Mi }
        volumeMounts:
        - { name: supervisor-bin, mountPath: /opt/linkmesh }
      # The node directory below is created by the kubelet as root, and the
      # collector runs as uid 10001, so without this it could not write its
      # read positions there and would refuse to start. Root for this one
      # command only, holding no capability but CHOWN: every capability a
      # container runtime grants by default is dropped by name except that
      # one. (Dropping ALL and adding CHOWN back would be the same, but
      # OpenShift refuses any added capability.)
      - name: own-node-state
        image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-opampsupervisor:0.165.0
        command: ["sh", "-c", "mkdir -p /state/supervisor /state/filelog-storage /state/sending-queue && chown 10001:10001 /state/supervisor /state/filelog-storage /state/sending-queue"]
        securityContext:
          runAsUser: 0
          runAsNonRoot: false
          allowPrivilegeEscalation: false
          capabilities:
            drop: ["AUDIT_WRITE", "DAC_OVERRIDE", "FOWNER", "FSETID", "KILL", "MKNOD", "NET_BIND_SERVICE", "NET_RAW", "SETFCAP", "SETGID", "SETPCAP", "SETUID", "SYS_CHROOT"]
          # See the supervisor container below.
          seLinuxOptions: { type: spc_t }
        resources:
          requests: { cpu: 10m, memory: 32Mi }
          limits: { cpu: 100m, memory: 128Mi }
        volumeMounts:
        - { name: node-state, mountPath: /state }
      containers:
      - name: supervisor
        # Upstream OTel collector release image, one pinned version (matches
        # what this server is tested against). PID 1 is the staged supervisor;
        # it starts and manages this image's own /otelcol-contrib.
        image: otel/opentelemetry-collector-contrib:0.165.0
        command: ["/opt/linkmesh/opampsupervisor"]
        args: ["--config", "/etc/otelcol-supervisor/supervisor.yaml"]
        # On nodes that enforce SELinux (OpenShift, RHEL) the host directories
        # mounted below carry labels a container with the default type may not
        # write, so the collector could not keep its read positions there.
        # spc_t is the type the container runtime gives a container that works
        # on host files. Nodes without SELinux ignore it.
        securityContext:
          allowPrivilegeEscalation: false
          capabilities: { drop: ["ALL"] }
          seLinuxOptions: { type: spc_t }
        # The supervisor and the collector share this one container. Every
        # value is set on purpose: in a namespace with a LimitRange, any value
        # left out is taken from its default (often 250m CPU / 256Mi), and the
        # collector is then throttled and, tailing busy pod logs, OOM-killed.
        # That includes the CPU limit — leaving it out gets the LimitRange's
        # default, not "unlimited". The limits fit under a per-container
        # LimitRange max of 500m / 512Mi. Above its max, the namespace refuses
        # the pod and the DaemonSet shows only events, no pods. Under a
        # stricter max, lower these limits to it. With no max and a lot of
        # pod logs, raise memory to 1Gi after checking kubectl top pod.
        resources:
          requests: { cpu: 100m, memory: 256Mi }
          limits: { cpu: 500m, memory: 512Mi }
        env:
        # Which node this pod is on. Kubernetes Node Metrics targets this
        # node's kubelet with it, and the k8sattributes processor scopes its
        # pod cache to this node with it. It is NOT optional: once any
        # Kubernetes source is activated, a collector without it refuses to
        # start ("'node_from_env_var' is configured but envvar K8S_NODE_NAME
        # is not set") and takes every other source on it down too.
        - name: K8S_NODE_NAME
          valueFrom: { fieldRef: { fieldPath: spec.nodeName } }
        # This node's IP. Kubernetes Node Metrics dials the kubelet by it,
        # because a node NAME is not resolvable in every cluster's DNS
        # (OpenShift/CRC, bare metal). Without it the collector falls back to
        # the node name.
        - name: K8S_NODE_IP
          valueFrom: { fieldRef: { fieldPath: status.hostIP } }
        volumeMounts:
        - { name: supervisor-bin, mountPath: /opt/linkmesh, readOnly: true }
        - { name: cfg, mountPath: /etc/otelcol-supervisor }
        # The supervisor's own state, on the NODE: its persisted instance id,
        # which LinkMesh derives this collector's identity from, and the last
        # config it was given. A replaced pod (rollout, drain, image bump) is
        # therefore the same collector, not a new one. On a pod-scoped volume
        # every replacement enrolled as a brand-new collector, while the old
        # one lingered offline in the cluster's group holding a licence seat.
        - { name: node-state, mountPath: /var/lib/otelcol-supervisor, subPath: supervisor }
        # A File Tail or Kubernetes Pod Logs source's read position, and a
        # destination's durable queue. Also on the node, so a pod log line
        # written while the pod was being replaced is read, not skipped. Kept
        # in their own directories so state written before the
        # identity moved to the node is still found.
        - { name: node-state, mountPath: /var/lib/otelcol-supervisor/filelog-storage, subPath: filelog-storage }
        - { name: node-state, mountPath: /var/lib/otelcol-supervisor/sending-queue, subPath: sending-queue }
        # The collector image is DISTROLESS and its whole filesystem is three
        # files — /otelcol-contrib, /etc/otelcol-contrib/config.yaml and the CA
        # bundle. There is no /tmp in it, so without this mount the collector
        # has nowhere to write a temp file at all. A File destination left on
        # its catalogue default (/tmp/otel-output.json) then fails to start the
        # pipeline, and because the supervisor is PID 1 and absorbs the crash
        # the POD stays Running while the agent subprocess restarts forever.
        - { name: tmp, mountPath: /tmp }
        # Pod logs are files on the node. Without this mount a Kubernetes Pod
        # Logs source matches nothing inside the container and collects zero
        # records while looking perfectly healthy. Read-only on purpose.
        # containerd/CRI-O write the real files here; on a node where
        # /var/log/pods holds symlinks, mount their targets as well.
        - { name: podlogs, mountPath: /var/log/pods, readOnly: true }
      volumes:
      # Where the initContainer drops the supervisor binary. Pod-scoped on
      # purpose — it is re-staged from the image on every pod start, so it can
      # never drift from the image tag above.
      - { name: supervisor-bin, emptyDir: {} }
      - { name: cfg, configMap: { name: linkmesh-supervisor } }
      - { name: podlogs, hostPath: { path: /var/log/pods } }
      # Scratch space, pod-scoped and not persisted. A File destination writing
      # here is for first-setup inspection, which is what the catalogue entry
      # says it is for — point it at a hostPath or a PVC if the output has to
      # outlive the pod.
      - { name: tmp, emptyDir: {} }
      # The collector's identity, read positions and durable queues (mounted
      # above). One directory per node, reused by whichever collector pod runs
      # there next. Node-scoped is right for a DaemonSet only: one pod per
      # node, so one writer. After uninstalling, remove it by hand if the disk
      # matters; a later install on this node then enrols a new collector
      # instead of reviving the old one.
      - { name: node-state, hostPath: { path: /var/lib/linkmesh/otelcol, type: DirectoryOrCreate } }
EOF
GKE Autopilot
# Deploy an otelcol-contrib + OpAMP collector fleet on Kubernetes.
# An initContainer stages the upstream supervisor binary into the upstream
# collector image (neither image contains both); the supervisor then applies
# the config LinkMesh pushes over OpAMP to the collector alongside it.
#
# GKE Autopilot variant.
# Autopilot refuses writable host directories, so nothing is mounted from the
# node. Read positions and queued data are kept in the pod and are lost when
# it is replaced.
# Not available on this platform:
#   - Kubernetes Pod Logs (pod log files are on the node)
#   - Kubernetes Node Metrics and the kubelet and cAdvisor scrapes
#   - Host Metrics and the system journal
kubectl create namespace linkmesh --dry-run=client -o yaml | kubectl apply -f -

kubectl apply -n linkmesh -f - <<'EOF'
apiVersion: v1
kind: ServiceAccount
metadata: { name: linkmesh-otelcol, namespace: linkmesh }
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata: { name: linkmesh-otelcol }
rules:
# The k8sattributes processor LinkMesh attaches to every Kubernetes source
# reads pods and namespaces, and names each pod's owner (Deployment,
# StatefulSet, DaemonSet, Job, CronJob). Without these the collector runs but
# logs "pods is forbidden" continuously and enriches nothing. The workload
# reads are granted for the whole node role up front, so that turning on a
# later enrichment never needs this manifest re-applied. Read-only throughout.
- apiGroups: [""]
  resources: ["pods", "namespaces", "nodes"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
  resources: ["replicasets", "deployments", "statefulsets", "daemonsets"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
  resources: ["jobs", "cronjobs"]
  verbs: ["get", "list", "watch"]
# On OpenShift, LinkMesh reads the cluster's Infrastructure object to tell
# which platform it runs on. The read goes to the object's status subresource,
# which needs its own grant. Elsewhere this API does not exist and the rule
# grants nothing.
- apiGroups: ["config.openshift.io"]
  resources: ["infrastructures", "infrastructures/status"]
  verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata: { name: linkmesh-otelcol }
roleRef: { apiGroup: rbac.authorization.k8s.io, kind: ClusterRole, name: linkmesh-otelcol }
subjects:
- { kind: ServiceAccount, name: linkmesh-otelcol, namespace: linkmesh }
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: linkmesh-supervisor
data:
  supervisor.yaml: |
    server:
      endpoint: "wss://linkmesh.example.com/v1/opamp"
      headers:
        Authorization: "Bearer <ENROLLMENT_TOKEN>"
    capabilities:
      accepts_remote_config: true
      reports_effective_config: true
      reports_health: true
      reports_own_metrics: true
      reports_available_components: true
    agent:
      # Native path inside the collector image this pod runs (see the
      # initContainer below — the supervisor is the staged binary, the
      # collector is the image's own).
      executable: /otelcol-contrib
      # LinkMesh reads which Kubernetes platform the collector runs on while
      # the collector starts. Off a cloud that takes several seconds, longer
      # than the supervisor's default wait of 5s for a new config, which would
      # then be reported as failed although it works. The attribute below
      # tells LinkMesh this supervisor waits long enough.
      config_apply_timeout: 30s
      description:
        non_identifying_attributes:
          linkmesh.config_apply_timeout: "30s"
          # The node this pod runs on. LinkMesh uses it to find the agent on
          # the same node for Live Capture (the enrichment check). The
          # supervisor resolves ${env:...} from the pod's environment.
          k8s.node.name: "${env:K8S_NODE_NAME}"
          # Which platform variant of this manifest was applied. LinkMesh uses
          # it to show which sources cannot run here.
          linkmesh.k8s.install_preset: "gke-autopilot"
    storage:
      directory: /var/lib/otelcol-supervisor
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: linkmesh-otelcol
spec:
  selector:
    matchLabels: { app: linkmesh-otelcol }
  template:
    metadata:
      labels: { app: linkmesh-otelcol }
    spec:
      serviceAccountName: linkmesh-otelcol
      # Pod Security "restricted" admits the pod only with all of these. This
      # variant mounts nothing from the node, so it needs no privilege.
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001
        runAsGroup: 10001
        seccompProfile: { type: RuntimeDefault }
      # Run on control-plane nodes too. On a cluster that runs its own control
      # plane (kubeadm, kind, RKE2, k3s with tainted servers) that node holds
      # etcd, the API server and the scheduler; without this it gets no node
      # metrics and no pod logs while cluster-wide metrics still look complete.
      # Managed control planes (GKE, EKS, AKS) have no such node. Other taints
      # (GPU or dedicated pools) are not tolerated: add them here if wanted.
      tolerations:
      - { key: node-role.kubernetes.io/control-plane, operator: Exists, effect: NoSchedule }
      initContainers:
      # Copies the supervisor out of its own release image into a volume the
      # collector image can execute it from. Required because neither upstream
      # image is a complete runtime on its own: this image has no collector in
      # it anywhere, and the collector image has no supervisor. The binary is
      # statically linked, so it runs unchanged in the (distroless) collector
      # image. Keep this tag and the collector tag below equal.
      - name: stage-supervisor
        image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-opampsupervisor:0.165.0
        command: ["cp", "/usr/local/bin/opampsupervisor", "/opt/linkmesh/opampsupervisor"]
        securityContext:
          allowPrivilegeEscalation: false
          capabilities: { drop: ["ALL"] }
        resources:
          requests: { cpu: 10m, memory: 32Mi }
          limits: { cpu: 100m, memory: 128Mi }
        volumeMounts:
        - { name: supervisor-bin, mountPath: /opt/linkmesh }
      containers:
      - name: supervisor
        # Upstream OTel collector release image, one pinned version (matches
        # what this server is tested against). PID 1 is the staged supervisor;
        # it starts and manages this image's own /otelcol-contrib.
        image: otel/opentelemetry-collector-contrib:0.165.0
        command: ["/opt/linkmesh/opampsupervisor"]
        args: ["--config", "/etc/otelcol-supervisor/supervisor.yaml"]
        securityContext:
          allowPrivilegeEscalation: false
          capabilities: { drop: ["ALL"] }
        # The supervisor and the collector share this one container. Every
        # value is set on purpose: in a namespace with a LimitRange, any value
        # left out is taken from its default (often 250m CPU / 256Mi), and the
        # collector is then throttled and, tailing busy pod logs, OOM-killed.
        # That includes the CPU limit — leaving it out gets the LimitRange's
        # default, not "unlimited". The limits fit under a per-container
        # LimitRange max of 500m / 512Mi. Above its max, the namespace refuses
        # the pod and the DaemonSet shows only events, no pods. Under a
        # stricter max, lower these limits to it. With no max and a lot of
        # pod logs, raise memory to 1Gi after checking kubectl top pod.
        resources:
          requests: { cpu: 100m, memory: 256Mi }
          limits: { cpu: 500m, memory: 512Mi }
        env:
        # Which node this pod is on. Kubernetes Node Metrics targets this
        # node's kubelet with it, and the k8sattributes processor scopes its
        # pod cache to this node with it. It is NOT optional: once any
        # Kubernetes source is activated, a collector without it refuses to
        # start ("'node_from_env_var' is configured but envvar K8S_NODE_NAME
        # is not set") and takes every other source on it down too.
        - name: K8S_NODE_NAME
          valueFrom: { fieldRef: { fieldPath: spec.nodeName } }
        # This node's IP. Kubernetes Node Metrics dials the kubelet by it,
        # because a node NAME is not resolvable in every cluster's DNS
        # (OpenShift/CRC, bare metal). Without it the collector falls back to
        # the node name.
        - name: K8S_NODE_IP
          valueFrom: { fieldRef: { fieldPath: status.hostIP } }
        volumeMounts:
        - { name: supervisor-bin, mountPath: /opt/linkmesh, readOnly: true }
        - { name: cfg, mountPath: /etc/otelcol-supervisor }
        - { name: data, mountPath: /var/lib/otelcol-supervisor }
        # The collector image is DISTROLESS and its whole filesystem is three
        # files — /otelcol-contrib, /etc/otelcol-contrib/config.yaml and the CA
        # bundle. There is no /tmp in it, so without this mount the collector
        # has nowhere to write a temp file at all. A File destination left on
        # its catalogue default (/tmp/otel-output.json) then fails to start the
        # pipeline, and because the supervisor is PID 1 and absorbs the crash
        # the POD stays Running while the agent subprocess restarts forever.
        - { name: tmp, mountPath: /tmp }
      volumes:
      # Where the initContainer drops the supervisor binary. Pod-scoped on
      # purpose — it is re-staged from the image on every pod start, so it can
      # never drift from the image tag above.
      - { name: supervisor-bin, emptyDir: {} }
      - { name: cfg, configMap: { name: linkmesh-supervisor } }
      # Scratch space, pod-scoped and not persisted. A File destination writing
      # here is for first-setup inspection, which is what the catalogue entry
      # says it is for — point it at a hostPath or a PVC if the output has to
      # outlive the pod.
      - { name: tmp, emptyDir: {} }
      # The supervisor's own state, and with it a destination's durable queue
      # and a File Tail source's read position. This platform mounts nothing
      # from the node, so all of it is lost when the pod is replaced.
      - { name: data, emptyDir: {} }
EOF
EKS Fargate
# Deploy an otelcol-contrib + OpAMP collector fleet on Kubernetes.
# An initContainer stages the upstream supervisor binary into the upstream
# collector image (neither image contains both); the supervisor then applies
# the config LinkMesh pushes over OpAMP to the collector alongside it.
#
# EKS Fargate variant.
# Fargate runs no DaemonSets and mounts nothing from the node, so this is one
# collector pod. A Fargate profile must select the linkmesh namespace.
# Kubernetes attributes are added only for pods on the collector's own node,
# which on Fargate is the collector itself.
# Not available on this platform:
#   - Kubernetes Pod Logs (pod log files are on the node)
#   - Kubernetes Node Metrics and the kubelet and cAdvisor scrapes
#   - Host Metrics and the system journal
kubectl create namespace linkmesh --dry-run=client -o yaml | kubectl apply -f -

kubectl apply -n linkmesh -f - <<'EOF'
apiVersion: v1
kind: ServiceAccount
metadata: { name: linkmesh-otelcol, namespace: linkmesh }
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata: { name: linkmesh-otelcol }
rules:
# The k8sattributes processor LinkMesh attaches to every Kubernetes source
# reads pods and namespaces, and names each pod's owner (Deployment,
# StatefulSet, DaemonSet, Job, CronJob). Without these the collector runs but
# logs "pods is forbidden" continuously and enriches nothing. The workload
# reads are granted for the whole node role up front, so that turning on a
# later enrichment never needs this manifest re-applied. Read-only throughout.
- apiGroups: [""]
  resources: ["pods", "namespaces", "nodes"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
  resources: ["replicasets", "deployments", "statefulsets", "daemonsets"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
  resources: ["jobs", "cronjobs"]
  verbs: ["get", "list", "watch"]
# On OpenShift, LinkMesh reads the cluster's Infrastructure object to tell
# which platform it runs on. The read goes to the object's status subresource,
# which needs its own grant. Elsewhere this API does not exist and the rule
# grants nothing.
- apiGroups: ["config.openshift.io"]
  resources: ["infrastructures", "infrastructures/status"]
  verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata: { name: linkmesh-otelcol }
roleRef: { apiGroup: rbac.authorization.k8s.io, kind: ClusterRole, name: linkmesh-otelcol }
subjects:
- { kind: ServiceAccount, name: linkmesh-otelcol, namespace: linkmesh }
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: linkmesh-supervisor
data:
  supervisor.yaml: |
    server:
      endpoint: "wss://linkmesh.example.com/v1/opamp"
      headers:
        Authorization: "Bearer <ENROLLMENT_TOKEN>"
    capabilities:
      accepts_remote_config: true
      reports_effective_config: true
      reports_health: true
      reports_own_metrics: true
      reports_available_components: true
    agent:
      # Native path inside the collector image this pod runs (see the
      # initContainer below — the supervisor is the staged binary, the
      # collector is the image's own).
      executable: /otelcol-contrib
      # LinkMesh reads which Kubernetes platform the collector runs on while
      # the collector starts. Off a cloud that takes several seconds, longer
      # than the supervisor's default wait of 5s for a new config, which would
      # then be reported as failed although it works. The attribute below
      # tells LinkMesh this supervisor waits long enough.
      config_apply_timeout: 30s
      description:
        non_identifying_attributes:
          linkmesh.config_apply_timeout: "30s"
          # The node this pod runs on. LinkMesh uses it to find the agent on
          # the same node for Live Capture (the enrichment check). The
          # supervisor resolves ${env:...} from the pod's environment.
          k8s.node.name: "${env:K8S_NODE_NAME}"
          # Which platform variant of this manifest was applied. LinkMesh uses
          # it to show which sources cannot run here.
          linkmesh.k8s.install_preset: "eks-fargate"
    storage:
      directory: /var/lib/otelcol-supervisor
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: linkmesh-otelcol
spec:
  # Fargate runs no DaemonSets: one collector pod, on its own Fargate node.
  replicas: 1
  selector:
    matchLabels: { app: linkmesh-otelcol }
  template:
    metadata:
      labels: { app: linkmesh-otelcol }
    spec:
      serviceAccountName: linkmesh-otelcol
      # Pod Security "restricted" admits the pod only with all of these. This
      # variant mounts nothing from the node, so it needs no privilege.
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001
        runAsGroup: 10001
        seccompProfile: { type: RuntimeDefault }
      initContainers:
      # Copies the supervisor out of its own release image into a volume the
      # collector image can execute it from. Required because neither upstream
      # image is a complete runtime on its own: this image has no collector in
      # it anywhere, and the collector image has no supervisor. The binary is
      # statically linked, so it runs unchanged in the (distroless) collector
      # image. Keep this tag and the collector tag below equal.
      - name: stage-supervisor
        image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-opampsupervisor:0.165.0
        command: ["cp", "/usr/local/bin/opampsupervisor", "/opt/linkmesh/opampsupervisor"]
        securityContext:
          allowPrivilegeEscalation: false
          capabilities: { drop: ["ALL"] }
        resources:
          requests: { cpu: 10m, memory: 32Mi }
          limits: { cpu: 100m, memory: 128Mi }
        volumeMounts:
        - { name: supervisor-bin, mountPath: /opt/linkmesh }
      containers:
      - name: supervisor
        # Upstream OTel collector release image, one pinned version (matches
        # what this server is tested against). PID 1 is the staged supervisor;
        # it starts and manages this image's own /otelcol-contrib.
        image: otel/opentelemetry-collector-contrib:0.165.0
        command: ["/opt/linkmesh/opampsupervisor"]
        args: ["--config", "/etc/otelcol-supervisor/supervisor.yaml"]
        securityContext:
          allowPrivilegeEscalation: false
          capabilities: { drop: ["ALL"] }
        # The supervisor and the collector share this one container. Every
        # value is set on purpose: in a namespace with a LimitRange, any value
        # left out is taken from its default (often 250m CPU / 256Mi), and the
        # collector is then throttled and, tailing busy pod logs, OOM-killed.
        # That includes the CPU limit — leaving it out gets the LimitRange's
        # default, not "unlimited". The limits fit under a per-container
        # LimitRange max of 500m / 512Mi. Above its max, the namespace refuses
        # the pod and the DaemonSet shows only events, no pods. Under a
        # stricter max, lower these limits to it. With no max and a lot of
        # pod logs, raise memory to 1Gi after checking kubectl top pod.
        resources:
          requests: { cpu: 100m, memory: 256Mi }
          limits: { cpu: 500m, memory: 512Mi }
        env:
        # Which node this pod is on. Kubernetes Node Metrics targets this
        # node's kubelet with it, and the k8sattributes processor scopes its
        # pod cache to this node with it. It is NOT optional: once any
        # Kubernetes source is activated, a collector without it refuses to
        # start ("'node_from_env_var' is configured but envvar K8S_NODE_NAME
        # is not set") and takes every other source on it down too.
        - name: K8S_NODE_NAME
          valueFrom: { fieldRef: { fieldPath: spec.nodeName } }
        # This node's IP. Kubernetes Node Metrics dials the kubelet by it,
        # because a node NAME is not resolvable in every cluster's DNS
        # (OpenShift/CRC, bare metal). Without it the collector falls back to
        # the node name.
        - name: K8S_NODE_IP
          valueFrom: { fieldRef: { fieldPath: status.hostIP } }
        volumeMounts:
        - { name: supervisor-bin, mountPath: /opt/linkmesh, readOnly: true }
        - { name: cfg, mountPath: /etc/otelcol-supervisor }
        - { name: data, mountPath: /var/lib/otelcol-supervisor }
        # The collector image is DISTROLESS and its whole filesystem is three
        # files — /otelcol-contrib, /etc/otelcol-contrib/config.yaml and the CA
        # bundle. There is no /tmp in it, so without this mount the collector
        # has nowhere to write a temp file at all. A File destination left on
        # its catalogue default (/tmp/otel-output.json) then fails to start the
        # pipeline, and because the supervisor is PID 1 and absorbs the crash
        # the POD stays Running while the agent subprocess restarts forever.
        - { name: tmp, mountPath: /tmp }
      volumes:
      # Where the initContainer drops the supervisor binary. Pod-scoped on
      # purpose — it is re-staged from the image on every pod start, so it can
      # never drift from the image tag above.
      - { name: supervisor-bin, emptyDir: {} }
      - { name: cfg, configMap: { name: linkmesh-supervisor } }
      # Scratch space, pod-scoped and not persisted. A File destination writing
      # here is for first-setup inspection, which is what the catalogue entry
      # says it is for — point it at a hostPath or a PVC if the output has to
      # outlive the pod.
      - { name: tmp, emptyDir: {} }
      # The supervisor's own state, and with it a destination's durable queue
      # and a File Tail source's read position. This platform mounts nothing
      # from the node, so all of it is lost when the pod is replaced.
      - { name: data, emptyDir: {} }
EOF
  • A Kubernetes cluster (any flavour — kind, k3s, EKS, GKE, AKS, on-prem).
  • kubectl configured for the cluster.
  • A running LinkMesh server, reachable from your pods over WSS (OpAMP). One instance is enough; to run several behind a load balancer, see Run a highly-available deployment.
  • Your server’s public base URL handy, e.g. https://linkmesh.example.com.
  • That same URL configured on the server as externalUrl — see Quickstart step 2. It must be an address your pods resolve (an Ingress hostname or a Service DNS name, never a pod IP). Skip it and the fleet enrols and ships data correctly while every collector shows throughput 0 / CPU 0 / memory 0.

Open Collectors → + Add Collector → Install Now in the LinkMesh UI and pick Kubernetes on the Platform & token step. The Install step then shows the manifest, pre-filled with your server URL and the token.

Before it generates the token, the wizard asks for the cluster name — lowercase letters, digits and dashes, for example prod-eu. It names the collector group the cluster lands in, and it is the k8s.cluster.name on every record the cluster exports, so give each cluster its own. If a Kubernetes cluster of that name exists already, the token adds the new collectors to that cluster’s fleet and group. To rename it later, click Edit ownership on the node group’s Kubernetes tab (see Cluster name); records exported before keep the old name.

Because a DaemonSet enrols many pods (and reschedules them), use a reusable enrollment token rather than a single-use one: one token enrols every pod, and a rescheduled pod re-attaches without minting anything new. Mint reusable, scoped tokens under Settings → Enrollment Tokens; see Enrollment tokens for TTL, scope, and revocation.

The commands below are the ones the Add Collector wizard shows for the Kubernetes snippet, with https://linkmesh.example.com in place of your server URL and <ENROLLMENT_TOKEN> in place of the token. Copy them from the wizard instead and both are already filled in. The wizard also appends the LinkMesh agent, on the same token; see Onboard from the cluster inventory.

Run the upstream otelcol-contrib image with the upstream opampsupervisor as its main process. No upstream image contains both binaries, so an init container copies the supervisor out of its own release image into the pod; the supervisor is statically linked and runs unchanged in the collector image. It connects to LinkMesh over OpAMP, starts the image’s own /otelcol-contrib, and applies the config the server pushes. Both images are pinned to the same version.

The manifest is self-contained: it grants the ServiceAccount the read-only RBAC the Kubernetes receivers need (kubelet metrics, pod and namespace lookup for attribute enrichment), mounts /var/log/pods for pod logs, and passes the node name and IP to the collector — so activating a Kubernetes Pod Logs or node metrics source in the UI works with no further edits to the cluster.

# Deploy an otelcol-contrib + OpAMP collector fleet on Kubernetes.
# An initContainer stages the upstream supervisor binary into the upstream
# collector image (neither image contains both); the supervisor then applies
# the config LinkMesh pushes over OpAMP to the collector alongside it.
kubectl create namespace linkmesh --dry-run=client -o yaml | kubectl apply -f -

kubectl apply -n linkmesh -f - <<'EOF'
apiVersion: v1
kind: ServiceAccount
metadata: { name: linkmesh-otelcol, namespace: linkmesh }
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata: { name: linkmesh-otelcol }
rules:
# The k8sattributes processor LinkMesh attaches to every Kubernetes source
# reads pods and namespaces, and names each pod's owner (Deployment,
# StatefulSet, DaemonSet, Job, CronJob). Without these the collector runs but
# logs "pods is forbidden" continuously and enriches nothing. The workload
# reads are granted for the whole node role up front, so that turning on a
# later enrichment never needs this manifest re-applied. Read-only throughout.
- apiGroups: [""]
  resources: ["pods", "namespaces", "nodes"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
  resources: ["replicasets", "deployments", "statefulsets", "daemonsets"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
  resources: ["jobs", "cronjobs"]
  verbs: ["get", "list", "watch"]
# Kubernetes Node Metrics (kubeletstats) reads its own node's kubelet
# (nodes/stats). The Kubernetes kubelet and container metrics sources scrape
# its /metrics and /metrics/cadvisor, which the kubelet authorizes as
# nodes/metrics — nodes/proxy does not cover them.
- apiGroups: [""]
  resources: ["nodes/stats", "nodes/proxy", "nodes/metrics"]
  verbs: ["get"]
# On OpenShift, LinkMesh reads the cluster's Infrastructure object to tell
# which platform it runs on. The read goes to the object's status subresource,
# which needs its own grant. Elsewhere this API does not exist and the rule
# grants nothing.
- apiGroups: ["config.openshift.io"]
  resources: ["infrastructures", "infrastructures/status"]
  verbs: ["get"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata: { name: linkmesh-otelcol }
roleRef: { apiGroup: rbac.authorization.k8s.io, kind: ClusterRole, name: linkmesh-otelcol }
subjects:
- { kind: ServiceAccount, name: linkmesh-otelcol, namespace: linkmesh }
---
# OpenShift only: the DaemonSet mounts host directories and prepares them as
# root, which the default SCC (restricted-v2) refuses, so no pod would ever
# start. This lets the collector's ServiceAccount use the built-in SCC
# hostmount-anyuid-v2, the narrowest one that admits it: host mounts, any uid
# and a chosen SELinux type, but no privileged container, host network, host
# PID/IPC or host port. Elsewhere the API group does not exist and this grants
# nothing.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata: { name: linkmesh-otelcol-scc }
rules:
- apiGroups: ["security.openshift.io"]
  resources: ["securitycontextconstraints"]
  resourceNames: ["hostmount-anyuid-v2"]
  verbs: ["use"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata: { name: linkmesh-otelcol-scc }
roleRef: { apiGroup: rbac.authorization.k8s.io, kind: Role, name: linkmesh-otelcol-scc }
subjects:
- { kind: ServiceAccount, name: linkmesh-otelcol, namespace: linkmesh }
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: linkmesh-supervisor
data:
  supervisor.yaml: |
    server:
      endpoint: "wss://linkmesh.example.com/v1/opamp"
      headers:
        Authorization: "Bearer <ENROLLMENT_TOKEN>"
    capabilities:
      accepts_remote_config: true
      reports_effective_config: true
      reports_health: true
      reports_own_metrics: true
      reports_available_components: true
    agent:
      # Native path inside the collector image this pod runs (see the
      # initContainer below — the supervisor is the staged binary, the
      # collector is the image's own).
      executable: /otelcol-contrib
      # LinkMesh reads which Kubernetes platform the collector runs on while
      # the collector starts. Off a cloud that takes several seconds, longer
      # than the supervisor's default wait of 5s for a new config, which would
      # then be reported as failed although it works. The attribute below
      # tells LinkMesh this supervisor waits long enough.
      config_apply_timeout: 30s
      description:
        non_identifying_attributes:
          linkmesh.config_apply_timeout: "30s"
          # The node this pod runs on. LinkMesh uses it to find the agent on
          # the same node for Live Capture (the enrichment check). The
          # supervisor resolves ${env:...} from the pod's environment.
          k8s.node.name: "${env:K8S_NODE_NAME}"
    storage:
      directory: /var/lib/otelcol-supervisor
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: linkmesh-otelcol
spec:
  selector:
    matchLabels: { app: linkmesh-otelcol }
  # A new pod must not start on a node until the old one has gone: both would
  # open the same state files under /var/lib/linkmesh/otelcol, the second
  # would wait on the first one's lock, and both would claim one identity. This is the DaemonSet default,
  # stated so nobody turns on maxSurge without reading this.
  updateStrategy:
    type: RollingUpdate
    rollingUpdate: { maxUnavailable: 1, maxSurge: 0 }
  template:
    metadata:
      labels: { app: linkmesh-otelcol }
      # The supervisor stops and restarts the collector it runs, by signal,
      # inside this one container. On Ubuntu nodes whose kernel stacks
      # AppArmor labels (7.0.0-42 and later) the runtime's default profile
      # refuses that signal, and the supervisor exits at start with "error
      # when stopping the collector: permission denied", so the pod
      # crash-loops. The runtime default does not help: it is that same
      # profile. Unconfined is set for the supervisor container only; the
      # init containers keep the default. An annotation and not the
      # appArmorProfile field, because Kubernetes before 1.30 refuses the
      # whole DaemonSet over the unknown field. Nodes without AppArmor
      # (OpenShift, RHEL) ignore it.
      annotations:
        container.apparmor.security.beta.kubernetes.io/supervisor: unconfined
    spec:
      serviceAccountName: linkmesh-otelcol
      # Run on control-plane nodes too. On a cluster that runs its own control
      # plane (kubeadm, kind, RKE2, k3s with tainted servers) that node holds
      # etcd, the API server and the scheduler; without this it gets no node
      # metrics and no pod logs while cluster-wide metrics still look complete.
      # Managed control planes (GKE, EKS, AKS) have no such node. Other taints
      # (GPU or dedicated pools) are not tolerated: add them here if wanted.
      tolerations:
      - { key: node-role.kubernetes.io/control-plane, operator: Exists, effect: NoSchedule }
      initContainers:
      # Copies the supervisor out of its own release image into a volume the
      # collector image can execute it from. Required because neither upstream
      # image is a complete runtime on its own: this image has no collector in
      # it anywhere, and the collector image has no supervisor. The binary is
      # statically linked, so it runs unchanged in the (distroless) collector
      # image. Keep this tag and the collector tag below equal.
      - name: stage-supervisor
        image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-opampsupervisor:0.165.0
        command: ["cp", "/usr/local/bin/opampsupervisor", "/opt/linkmesh/opampsupervisor"]
        resources:
          requests: { cpu: 10m, memory: 32Mi }
          limits: { cpu: 100m, memory: 128Mi }
        volumeMounts:
        - { name: supervisor-bin, mountPath: /opt/linkmesh }
      # The node directory below is created by the kubelet as root, and the
      # collector runs as uid 10001, so without this it could not write its
      # read positions there and would refuse to start. Root for this one
      # command only, holding no capability but CHOWN: every capability a
      # container runtime grants by default is dropped by name except that
      # one. (Dropping ALL and adding CHOWN back would be the same, but
      # OpenShift refuses any added capability.)
      - name: own-node-state
        image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-opampsupervisor:0.165.0
        command: ["sh", "-c", "mkdir -p /state/supervisor /state/filelog-storage /state/sending-queue && chown 10001:10001 /state/supervisor /state/filelog-storage /state/sending-queue"]
        securityContext:
          runAsUser: 0
          runAsNonRoot: false
          capabilities:
            drop: ["AUDIT_WRITE", "DAC_OVERRIDE", "FOWNER", "FSETID", "KILL", "MKNOD", "NET_BIND_SERVICE", "NET_RAW", "SETFCAP", "SETGID", "SETPCAP", "SETUID", "SYS_CHROOT"]
          # See the supervisor container below.
          seLinuxOptions: { type: spc_t }
        resources:
          requests: { cpu: 10m, memory: 32Mi }
          limits: { cpu: 100m, memory: 128Mi }
        volumeMounts:
        - { name: node-state, mountPath: /state }
      containers:
      - name: supervisor
        # Upstream OTel collector release image, one pinned version (matches
        # what this server is tested against). PID 1 is the staged supervisor;
        # it starts and manages this image's own /otelcol-contrib.
        image: otel/opentelemetry-collector-contrib:0.165.0
        command: ["/opt/linkmesh/opampsupervisor"]
        args: ["--config", "/etc/otelcol-supervisor/supervisor.yaml"]
        # On nodes that enforce SELinux (OpenShift, RHEL) the host directories
        # mounted below carry labels a container with the default type may not
        # write, so the collector could not keep its read positions there.
        # spc_t is the type the container runtime gives a container that works
        # on host files. Nodes without SELinux ignore it.
        securityContext:
          seLinuxOptions: { type: spc_t }
        # The supervisor and the collector share this one container. Every
        # value is set on purpose: in a namespace with a LimitRange, any value
        # left out is taken from its default (often 250m CPU / 256Mi), and the
        # collector is then throttled and, tailing busy pod logs, OOM-killed.
        # That includes the CPU limit — leaving it out gets the LimitRange's
        # default, not "unlimited". The limits fit under a per-container
        # LimitRange max of 500m / 512Mi. Above its max, the namespace refuses
        # the pod and the DaemonSet shows only events, no pods. Under a
        # stricter max, lower these limits to it. With no max and a lot of
        # pod logs, raise memory to 1Gi after checking kubectl top pod.
        resources:
          requests: { cpu: 100m, memory: 256Mi }
          limits: { cpu: 500m, memory: 512Mi }
        env:
        # Which node this pod is on. Kubernetes Node Metrics targets this
        # node's kubelet with it, and the k8sattributes processor scopes its
        # pod cache to this node with it. It is NOT optional: once any
        # Kubernetes source is activated, a collector without it refuses to
        # start ("'node_from_env_var' is configured but envvar K8S_NODE_NAME
        # is not set") and takes every other source on it down too.
        - name: K8S_NODE_NAME
          valueFrom: { fieldRef: { fieldPath: spec.nodeName } }
        # This node's IP. Kubernetes Node Metrics dials the kubelet by it,
        # because a node NAME is not resolvable in every cluster's DNS
        # (OpenShift/CRC, bare metal). Without it the collector falls back to
        # the node name.
        - name: K8S_NODE_IP
          valueFrom: { fieldRef: { fieldPath: status.hostIP } }
        volumeMounts:
        - { name: supervisor-bin, mountPath: /opt/linkmesh, readOnly: true }
        - { name: cfg, mountPath: /etc/otelcol-supervisor }
        # The supervisor's own state, on the NODE: its persisted instance id,
        # which LinkMesh derives this collector's identity from, and the last
        # config it was given. A replaced pod (rollout, drain, image bump) is
        # therefore the same collector, not a new one. On a pod-scoped volume
        # every replacement enrolled as a brand-new collector, while the old
        # one lingered offline in the cluster's group holding a licence seat.
        - { name: node-state, mountPath: /var/lib/otelcol-supervisor, subPath: supervisor }
        # A File Tail or Kubernetes Pod Logs source's read position, and a
        # destination's durable queue. Also on the node, so a pod log line
        # written while the pod was being replaced is read, not skipped. Kept
        # in their own directories so state written before the
        # identity moved to the node is still found.
        - { name: node-state, mountPath: /var/lib/otelcol-supervisor/filelog-storage, subPath: filelog-storage }
        - { name: node-state, mountPath: /var/lib/otelcol-supervisor/sending-queue, subPath: sending-queue }
        # The collector image is DISTROLESS and its whole filesystem is three
        # files — /otelcol-contrib, /etc/otelcol-contrib/config.yaml and the CA
        # bundle. There is no /tmp in it, so without this mount the collector
        # has nowhere to write a temp file at all. A File destination left on
        # its catalogue default (/tmp/otel-output.json) then fails to start the
        # pipeline, and because the supervisor is PID 1 and absorbs the crash
        # the POD stays Running while the agent subprocess restarts forever.
        - { name: tmp, mountPath: /tmp }
        # Pod logs are files on the node. Without this mount a Kubernetes Pod
        # Logs source matches nothing inside the container and collects zero
        # records while looking perfectly healthy. Read-only on purpose.
        # containerd/CRI-O write the real files here; on a node where
        # /var/log/pods holds symlinks, mount their targets as well.
        - { name: podlogs, mountPath: /var/log/pods, readOnly: true }
      volumes:
      # Where the initContainer drops the supervisor binary. Pod-scoped on
      # purpose — it is re-staged from the image on every pod start, so it can
      # never drift from the image tag above.
      - { name: supervisor-bin, emptyDir: {} }
      - { name: cfg, configMap: { name: linkmesh-supervisor } }
      - { name: podlogs, hostPath: { path: /var/log/pods } }
      # Scratch space, pod-scoped and not persisted. A File destination writing
      # here is for first-setup inspection, which is what the catalogue entry
      # says it is for — point it at a hostPath or a PVC if the output has to
      # outlive the pod.
      - { name: tmp, emptyDir: {} }
      # The collector's identity, read positions and durable queues (mounted
      # above). One directory per node, reused by whichever collector pod runs
      # there next. Node-scoped is right for a DaemonSet only: one pod per
      # node, so one writer. After uninstalling, remove it by hand if the disk
      # matters; a later install on this node then enrols a new collector
      # instead of reviving the old one.
      - { name: node-state, hostPath: { path: /var/lib/linkmesh/otelcol, type: DirectoryOrCreate } }
EOF

The collector’s identity and read positions survive the pod. The supervisor’s own state (its persisted instance id, which LinkMesh derives the collector’s identity from), a File Tail or Kubernetes Pod Logs source’s read position, and a destination’s durable queue are kept in /var/lib/linkmesh/otelcol on the node. A pod that is rescheduled, drained or moved to a new image is therefore the same collector, not a new one holding a second licence seat, and it resumes where the previous one stopped instead of skipping what was written in between. The second init container gives those directories to the collector’s user (uid 10001); it runs as root for that one command and holds no capability but CHOWN.

The updateStrategy is part of that: a new pod does not start on a node until the old one is gone, because both would open the same state files and claim one identity. Leave maxSurge at 0.

The standalone-host version of this runtime, plus how the two binaries fit together, is in Onboard otelcol-contrib via OpAMP.

# Wait for a supervisor pod on every node
kubectl -n linkmesh rollout status ds/linkmesh-otelcol

# Watch the OpAMP handshake + config apply
kubectl -n linkmesh logs -l app=linkmesh-otelcol --tail=20

In your LinkMesh UI, open Collectors. The fleet’s collectors appear with the OpAMP mode and leave Awaiting connection within about 30s, once the OpAMP handshake completes. The topology canvas renders throughput once own_metrics start landing.

Host metrics: report the node, not the pod

Section titled “Host metrics: report the node, not the pod”

The Host Metrics source reads /proc, /sys, and the root filesystem to report CPU, memory, disk, filesystem, and network. Inside a container that’s the collector’s own filesystem — a few processes, a thin overlay disk — not the node it runs on. Activate Host Metrics on the fleet above with no further changes, and it reports the pod, not the node. Nothing errors; the numbers are just wrong, and they look plausible.

Fixing it takes two changes, and both are required — the mount without the field, or the field without the mount, each silently do nothing:

  1. Mount the node’s root filesystem, read-only, into the collector container: the supervisor container, which runs the collector image.

    Add a hostfs volume and mount it into the supervisor container (the otelcol-contrib it starts runs in the same container), then apply the manifest again:

    # containers[0].volumeMounts (supervisor), alongside the existing entries:
    - { name: hostfs, mountPath: /hostfs, readOnly: true }
    # volumes, alongside the existing entries:
    - { name: hostfs, hostPath: { path: / } }
  2. Set root_path on the source — your group’s Sources tab → your Host Metrics source → Root Path → /hostfs (or whatever mount path you chose above). Leave it empty for a collector running directly on a host; only a containerised or DaemonSet collector needs it.

The collector accepts the field once the mount exists; without a matching mount, the collector reads an empty or absent directory at that path instead — check the field is set and the volume above is present before concluding the source is broken.

Application telemetry: send OTLP to the collector on the same node

Section titled “Application telemetry: send OTLP to the collector on the same node”

An application that sends traces, metrics or logs over OTLP to a fleet collector gets the same Kubernetes metadata as the pod logs — namespace, pod, node, the owning Deployment, StatefulSet, DaemonSet, Job or CronJob, the container image and the recommended app.kubernetes.io/* labels. Nothing in the application has to change for it. The collector looks up the pod by the address the request came from.

Each collector knows only the pods on its own node: that keeps its memory and its load on the Kubernetes API flat as the cluster grows. So an application has to send to the collector on its own node. Telemetry that reaches the collector on another node is delivered but carries no Kubernetes metadata, and nothing reports an error.

  1. Open the listener on all interfaces. In the OTLP source, set gRPC Endpoint to 0.0.0.0:4317 (and/or HTTP Endpoint to 0.0.0.0:4318), and activate the source on the fleet’s group.

  2. Add a node-local Service in front of the fleet. With internalTrafficPolicy: Local, Kubernetes delivers each connection to the collector on the sender’s node and keeps the sender’s own address:

    apiVersion: v1
    kind: Service
    metadata: { name: linkmesh-otlp, namespace: linkmesh }
    spec:
      selector: { app: linkmesh-otelcol }
      internalTrafficPolicy: Local
      ports:
      - { name: otlp-grpc, port: 4317, targetPort: 4317 }
      - { name: otlp-http, port: 4318, targetPort: 4318 }
  3. Point the application at it, e.g. OTEL_EXPORTER_OTLP_ENDPOINT=http://linkmesh-otlp.linkmesh.svc:4317.

What does not carry Kubernetes metadata:

  • An ordinary Service (the default internalTrafficPolicy: Cluster) or a load balancer in front of the fleet. They send each connection to a collector on any node, so only the share that happens to land on the sender’s own node is labelled.
  • A hostPort on the fleet, with the application sending to its node’s IP. Most network plugins rewrite the source address of a pod reaching a hostPort on its own node, so the collector sees the node, not the pod. To use a hostPort anyway, have the application state its own IP. Set OTEL_RESOURCE_ATTRIBUTES=k8s.pod.ip=$(POD_IP), with POD_IP from the downward API (fieldRef: { fieldPath: status.podIP }). The collector looks that IP up before the connection’s.
  • The cluster collector. It is one pod for the cluster receivers, not a collector per node, so OTLP sent to it is not enriched.
  • A pod with hostNetwork: true. It shares its node’s address, so no pod can be found from it.

The manifests above are deliberately minimal. Before promoting to production:

  • Keep the versions pinned. The manifests pin the collector and supervisor images to one version. Change versions with the upgrade LinkMesh renders (see Upgrade a collector fleet on Kubernetes), not by editing one tag: the collector and supervisor images must stay a matched pair.

  • Add a NetworkPolicy on the linkmesh namespace that allows egress only to what the collectors talk to:

    • your LinkMesh server’s HTTPS / WSS port;
    • your destinations, which the collectors send their data to directly;
    • cluster DNS (UDP and TCP 53);
    • the Kubernetes API server, which is the kubernetes Service in the default namespace on port 443. Many clusters also need the API server’s own endpoint addresses, often on port 6443, because a NetworkPolicy is evaluated after the Service address is translated;
    • the kubelet on each node, TCP 10250, for node metrics;
    • the LinkMesh agent pods on TCP 14318, if you use Live Capture.

    Without the API server, the cluster collector never starts: the cluster metrics and events receivers wait for it while the collector starts. Node collectors also stop naming each record’s pod and workload. Without the kubelet, node metrics stay empty.

  • Move the token into sealed-secrets, SOPS, or Vault rather than templating it into values/manifests. A reusable enrollment token is a fleet credential — treat it accordingly, and revoke + re-mint to rotate.

  • Size the resource requests and limits to your telemetry volume. The supervisor container requests 100m CPU and 256Mi memory, with limits of 500m and 512Mi; with a lot of pod logs and no namespace maximum in the way, raise memory after checking kubectl top pod.

  • Review the cluster access. The RBAC above is read-only (get/list/watch, never write, never cluster-admin) — the least the Kubernetes receivers need.

  • Decide about tainted nodes. The fleet tolerates the control-plane taint (node-role.kubernetes.io/control-plane), so on a cluster that runs its own control plane (kubeadm, kind, RKE2, k3s) the control-plane nodes get a collector too. No other taint is tolerated: a node in a GPU or dedicated pool runs no collector, and its pod logs and metrics are not collected. Add its taint to tolerations in the DaemonSet if you want them.

The commands above work on OpenShift 4.x unchanged. OpenShift admits a pod only under a SecurityContextConstraints (SCC) its ServiceAccount may use, and the default one, restricted-v2, refuses a collector that mounts host directories or runs as a fixed user. So each manifest grants its own collector the SCC it needs:

Workload SCC Why
Node collectors (linkmesh-otelcol DaemonSet) hostmount-anyuid-v2 They read pod logs from the node and keep their read positions in node directories, which restricted-v2 refuses.
Cluster collector nonroot-v2 It mounts nothing from the node, but runs as the fixed user 10001, which is outside the namespace’s user range that restricted-v2 allows. nonroot-v2 admits any non-root user and otherwise keeps the rules of restricted-v2.

The table describes the Standard platform in the Add Collector wizard. Pick OpenShift there instead and the OpenTelemetry Collector DaemonSet runs under an SCC of its own, linkmesh-otelcol, that the manifest creates and that allows only what the collector’s pods ask for.

hostmount-anyuid-v2 is a built-in SCC and the narrowest one that admits the node collectors: it allows host mounts, any uid and a chosen SELinux type, and still refuses privileged containers, host networking, host PID/IPC and host ports. The grant is a namespaced Role that lets the collector’s ServiceAccount use that one SCC, bound in the linkmesh namespace. On other distributions the Role names an API group that does not exist and grants nothing.

The node collectors also run with the SELinux type spc_t. On an OpenShift node SELinux keeps a container with the default type from writing to the node directories, and the collector could not keep its read positions. Nodes without SELinux ignore the setting.

If you install with an account that may not create Roles, an administrator can grant the same SCC by hand:

# Node collectors
oc adm policy add-scc-to-user hostmount-anyuid-v2 -z linkmesh-otelcol -n linkmesh
# Cluster collector
oc adm policy add-scc-to-user nonroot-v2 -z linkmesh-otelcol-cluster -n linkmesh

To see which SCC admitted each pod:

oc -n linkmesh get pods -o custom-columns=NAME:.metadata.name,SCC:.metadata.annotations.openshift\\.io/scc

A DaemonSet that shows 0 pods and a FailedCreate event naming security context constraint means the grant is missing.

For a quick local evaluation:

# Create a kind cluster
kind create cluster --name linkmesh-eval

# Run a LinkMesh server reachable from the kind cluster
# (host.docker.internal works from kind pods on macOS/Windows)

# Then follow steps 1-3 with your server URL set to, e.g.:
#   https://host.docker.internal:8080
# (the manifest connects to wss://host.docker.internal:8080/v1/opamp)

kind nodes share a Docker network, so any service reachable from your host on host.docker.internal:<port> is reachable from the collector pods too.

kubectl delete namespace linkmesh

The collector’s identity, read positions and durable queues are kept on each node, outside the namespace, so deleting it leaves them behind in /var/lib/linkmesh/otelcol. Remove that directory on every node if the disk matters; a later install on that node then enrols a new collector instead of reviving the old one. The cluster-scoped objects the manifests create are not in the namespace either: the ClusterRoles and ClusterRoleBindings linkmesh-otelcol and linkmesh-otelcol-cluster, and with the OpenShift variant the SCC linkmesh-otelcol. Delete them as well if you are removing LinkMesh from the cluster.

Then revoke the fleet’s enrollment token under Settings → Enrollment Tokens if you’re decommissioning the cluster.

The steps above enrol a collector fleet you then wire by hand. To instead browse your namespaces and workloads in the UI and onboard their logs in one click, install the linkmesh-agent alongside the fleet — it reports the cluster inventory the onboarding view reads.

The Enroll Agent wizard (Agents → Enroll Agent → Kubernetes) first asks for the cluster name — lowercase letters, digits and dashes, for example homelab-k3s. The name becomes the name of the collector group the cluster lands in and the readable part of its fleet id, so every agent id says which cluster it belongs to. If a Kubernetes cluster of that name exists already, the wizard offers Add to cluster instead, and the new nodes join that cluster’s fleet and group.

It then gives you the whole cluster in one paste, with your server URL and a reusable fleet token already filled in:

  1. The agent (namespace linkmesh-system) — a DaemonSet, one pod per node, that reports namespaces, workloads and services. Read-only RBAC. It carries no telemetry.
  2. The collector fleet (namespace linkmesh) — the otelcol-contrib + OpAMP DaemonSet from step 2, with the pod-log mounts and read-only RBAC. This is what collects. Pick your platform (Standard, OpenShift, GKE Autopilot, EKS Fargate) above the manifest, as in the Add Collector wizard.

Both enrol with the same fleet token, so agents and collectors land in the same collector group. The wizard waits for both: it shows the cluster as connected only once agents and collectors have enrolled, tells you which half is still missing until then, and links to the cluster’s group.

Enroll agent, Kubernetes: the cluster name, the platform, and the one paste that installs the agent and the collector fleet.

Prefer the command line? The agent repository’s packaging/k8s kustomize base installs the same agent manifests:

kubectl -n linkmesh-system create secret generic linkmesh-agent-bootstrap \
  --from-literal=enrollment-token="$LINKMESH_TOKEN"
kubectl apply -k <path-to>/linkmesh-agent/packaging/k8s

Within ~60s the fleet enrols and your namespaces, workloads, and services appear on the group’s Kubernetes tab, under Workloads & services in the menu on the left. To collect a workload’s logs, open the group’s Sources tab, click Add from cluster, and click Onboard logs on the workload under Workload logs (the same action sits on each workload under Workloads & services). A Kubernetes Pod Logs source starts tailing it with no further cluster edits — the collector fleet already carries the pod-log mounts and read-only RBAC.

If the tab says the agents are connected but there is no cluster inventory yet, click Scan cluster now. An agent sends the inventory when it is asked, and the tab shows it as soon as it arrives. If no agent is connected, the tab says so and links to Agents, where you enroll it.

Workloads & services on the group's Kubernetes tab: the namespaces, workloads and services the agent reported, with a one-click Onboard logs action on each workload.

Node metrics are one click too. The Overview section of the node group’s Kubernetes tab shows the cluster layer by layer, with a Collect action on each source that is not collected yet. It enables Node metrics (kubeletstats), which runs on every node collector because it reads the node each collector runs on. The two cluster-wide sources, Cluster metrics and Cluster events, run on the cluster collector described next, and are started from its Sources tab:

Cluster coverage on the Overview section: each layer says what is collected, with a Collect action on Node metrics and pod logs, and Add cluster collector on the cluster-wide sources.

See The agent for what it does and does not do.

Cluster metrics and Cluster events read the whole cluster through the Kubernetes API, so they must be collected exactly once, not once per node. They run on a cluster collector: one extra collector per cluster, next to the node collectors.

  • One replica, Recreate. A single-replica Deployment. The old pod is gone before a new one starts, and every replacement pod enrols as the same collector, so a reschedule never leaves a second collector in the group. A second replica would collect everything twice; the server refuses it.
  • Read-only. Its ClusterRole grants get, list and watch only, on the objects cluster metrics and events describe. No Secrets, no ConfigMaps, no hostPath, no kubelet access.
  • Its own group. It lives in a cluster collector group paired with the node group, and each group’s Kubernetes tab links to the other.
Source Runs on
Node metrics (kubeletstats) the node group, on every node collector
Kubernetes Pod Logs the node group, on every node collector
Cluster metrics (k8s_cluster) the cluster collector only
Cluster events (k8s_events) the cluster collector only

The server enforces this split: a cluster-wide source is refused on a node group, and a node-level source is refused on the cluster collector.

  1. Open the node group’s Kubernetes tab, choose Cluster setup in the menu on the left, and click Add cluster collector on the Cluster collector card. LinkMesh creates the paired group and shows the install manifest with a reusable enrollment token, shown only once.
  2. Apply the manifest with kubectl pointed at that cluster. Nothing checks the context for you, and the manifest pairs with this cluster’s node collectors.
  3. Open the cluster collector group’s Sources tab, click Add from cluster, and click Start on Cluster metrics and Cluster events under Cluster-wide sources.

The manifest the wizard renders looks like this, with your server URL, token, collector identity and cluster name filled in:

# LinkMesh cluster collector for cluster "<CLUSTER_NAME>".
# Apply it with kubectl pointed at THAT cluster: it pairs with that cluster's
# node collectors in LinkMesh, and nothing checks the context for you.
#
# One replica, on purpose. It collects cluster-wide data (Cluster metrics,
# Cluster events) exactly once; a second replica would collect it twice and is
# refused by the server.
kubectl create namespace linkmesh --dry-run=client -o yaml | kubectl apply -f -

kubectl apply -n linkmesh -f - <<'EOF'
apiVersion: v1
kind: ServiceAccount
metadata: { name: linkmesh-otelcol-cluster, namespace: linkmesh }
---
# Read-only: get, list and watch, nothing else. No Secrets, no ConfigMaps.
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata: { name: linkmesh-otelcol-cluster }
rules:
# Cluster metrics (k8s_cluster) and the objects its metrics describe; events for Cluster events.
- apiGroups: [""]
  resources: ["events", "namespaces", "namespaces/status", "nodes", "nodes/spec", "persistentvolumes", "persistentvolumeclaims", "pods", "pods/status", "replicationcontrollers", "replicationcontrollers/status", "resourcequotas", "services"]
  verbs: ["get", "list", "watch"]
# Cluster events (k8sobjects watch), whichever events API the cluster serves.
- apiGroups: ["events.k8s.io"]
  resources: ["events"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["discovery.k8s.io"]
  resources: ["endpointslices"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["apps"]
  resources: ["daemonsets", "deployments", "replicasets", "statefulsets"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["batch"]
  resources: ["jobs", "cronjobs"]
  verbs: ["get", "list", "watch"]
- apiGroups: ["autoscaling"]
  resources: ["horizontalpodautoscalers"]
  verbs: ["get", "list", "watch"]
# On OpenShift: the Infrastructure object, to tell which platform the cluster runs on.
- apiGroups: ["config.openshift.io"]
  resources: ["infrastructures", "infrastructures/status"]
  verbs: ["get", "list", "watch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata: { name: linkmesh-otelcol-cluster }
roleRef: { apiGroup: rbac.authorization.k8s.io, kind: ClusterRole, name: linkmesh-otelcol-cluster }
subjects:
- { kind: ServiceAccount, name: linkmesh-otelcol-cluster, namespace: linkmesh }
---
# OpenShift only: the pod below runs as the fixed user 10001, which the default
# SCC (restricted-v2) refuses because it is outside the namespace's user range.
# This lets the collector's ServiceAccount use the built-in SCC nonroot-v2, the
# narrowest one that admits it: any non-root user, and otherwise the same rules
# as restricted-v2 (no privilege escalation, all capabilities dropped, no host
# access, no host directories). Elsewhere the API group does not exist and this
# grants nothing.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata: { name: linkmesh-otelcol-cluster-scc }
rules:
- apiGroups: ["security.openshift.io"]
  resources: ["securitycontextconstraints"]
  resourceNames: ["nonroot-v2"]
  verbs: ["use"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata: { name: linkmesh-otelcol-cluster-scc }
roleRef: { apiGroup: rbac.authorization.k8s.io, kind: Role, name: linkmesh-otelcol-cluster-scc }
subjects:
- { kind: ServiceAccount, name: linkmesh-otelcol-cluster, namespace: linkmesh }
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: linkmesh-supervisor-cluster
data:
  supervisor.yaml: |
    server:
      endpoint: "wss://linkmesh.example.com/v1/opamp"
      headers:
        Authorization: "Bearer <ENROLLMENT_TOKEN>"
    capabilities:
      accepts_remote_config: true
      reports_effective_config: true
      reports_health: true
      reports_own_metrics: true
      reports_available_components: true
    agent:
      executable: /otelcol-contrib
      # Fixed by LinkMesh for this cluster collector. Every pod that replaces
      # this one enrolls as the SAME collector, so a reschedule never leaves a
      # second, dead collector in the group.
      instance_id: "<INSTANCE_UID>"
      # LinkMesh reads which Kubernetes platform the collector runs on while
      # the collector starts. Off a cloud that takes several seconds, longer
      # than the supervisor's default wait of 5s for a new config, which would
      # then be reported as failed although it works. The attribute below
      # tells LinkMesh this supervisor waits long enough.
      config_apply_timeout: 30s
      description:
        non_identifying_attributes:
          linkmesh.config_apply_timeout: "30s"
          # The node this pod runs on. LinkMesh uses it to find the agent on
          # the same node for Live Capture (the enrichment check). The
          # supervisor resolves ${env:...} from the pod's environment.
          k8s.node.name: "${env:K8S_NODE_NAME}"
    storage:
      directory: /var/lib/otelcol-supervisor
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: linkmesh-otelcol-cluster
spec:
  replicas: 1
  # The old pod is gone before the new one starts. Two pods at once would be
  # two collectors with one identity.
  strategy: { type: Recreate }
  selector:
    matchLabels: { app: linkmesh-otelcol-cluster }
  template:
    metadata:
      labels: { app: linkmesh-otelcol-cluster }
      # The supervisor stops and restarts the collector it runs, by signal,
      # inside this one container. On Ubuntu nodes whose kernel stacks
      # AppArmor labels (7.0.0-42 and later) the runtime's default profile
      # refuses that signal and the pod crash-loops with "error when stopping
      # the collector: permission denied". Unconfined is set for the
      # supervisor container only. It is the one setting here that Pod
      # Security "baseline" and "restricted" refuse: if this namespace
      # enforces one of them and no node runs such a kernel, delete these
      # two lines.
      annotations:
        container.apparmor.security.beta.kubernetes.io/supervisor: unconfined
    spec:
      serviceAccountName: linkmesh-otelcol-cluster
      # Pod Security "restricted" admits the pod only with all of these, and
      # nothing here needs more: no host directory, no root. The user is a
      # number because the supervisor image's own user is a name, which the
      # kubelet refuses under runAsNonRoot. 10001 is the collector image's user.
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001
        runAsGroup: 10001
        seccompProfile: { type: RuntimeDefault }
      initContainers:
      # Copies the supervisor out of its release image into a volume the
      # collector image can execute it from: neither upstream image holds both.
      # Keep this tag and the collector tag below equal.
      - name: stage-supervisor
        image: ghcr.io/open-telemetry/opentelemetry-collector-releases/opentelemetry-collector-opampsupervisor:0.165.0
        command: ["cp", "/usr/local/bin/opampsupervisor", "/opt/linkmesh/opampsupervisor"]
        securityContext:
          allowPrivilegeEscalation: false
          capabilities: { drop: ["ALL"] }
        resources:
          requests: { cpu: 10m, memory: 32Mi }
          limits: { cpu: 100m, memory: 128Mi }
        volumeMounts:
        - { name: supervisor-bin, mountPath: /opt/linkmesh }
      containers:
      - name: supervisor
        image: otel/opentelemetry-collector-contrib:0.165.0
        command: ["/opt/linkmesh/opampsupervisor"]
        args: ["--config", "/etc/otelcol-supervisor/supervisor.yaml"]
        securityContext:
          allowPrivilegeEscalation: false
          capabilities: { drop: ["ALL"] }
        # Set explicitly so a namespace LimitRange does not choose them (its
        # default is often 250m CPU / 256Mi). Fits under a per-container max of
        # 500m / 512Mi. Memory grows with the number of objects in the
        # cluster: on a large cluster raise it, within your namespace's max.
        resources:
          requests: { cpu: 100m, memory: 256Mi }
          limits: { cpu: 500m, memory: 512Mi }
        env:
        # Not read by the cluster receivers. Set anyway: a collector whose
        # config names it and finds it unset refuses to start at all.
        - name: K8S_NODE_NAME
          valueFrom: { fieldRef: { fieldPath: spec.nodeName } }
        volumeMounts:
        - { name: supervisor-bin, mountPath: /opt/linkmesh, readOnly: true }
        - { name: cfg, mountPath: /etc/otelcol-supervisor }
        - { name: data, mountPath: /var/lib/otelcol-supervisor }
        # The collector image is distroless and has no /tmp.
        - { name: tmp, mountPath: /tmp }
      volumes:
      - { name: supervisor-bin, emptyDir: {} }
      - { name: cfg, configMap: { name: linkmesh-supervisor-cluster } }
      # The supervisor's state and a destination's durable queue. Pod-scoped:
      # a queue held here is lost with the pod. The identity is not, because it
      # comes from the ConfigMap above.
      - { name: data, emptyDir: {} }
      - { name: tmp, emptyDir: {} }
EOF

The container requests 100m CPU and 256Mi memory, with limits of 500m and 512Mi. Memory grows with the number of objects in the cluster: on a large cluster, raise the limit within your namespace’s maximum.

Cluster metrics enables, next to the receiver’s defaults:

  • node allocatable: cpu, memory, pods, ephemeral-storage;
  • node conditions Ready, MemoryPressure, DiskPressure, PIDPressure and NetworkUnavailable;
  • five metrics the receiver ships disabled: k8s.service.endpoint.count, k8s.service.load_balancer.ingress.count, k8s.container.status.reason, k8s.pod.status_reason and k8s.persistentvolumeclaim.status.phase.

k8s.service.endpoint.count is computed from EndpointSlices. A Service whose selector matches no pod at all emits no series, so an alert on == 0 alone misses it; alert on the series being absent as well.

Cluster events collects Warning events only (field selector type=Warning). Clear the field on the source to receive Normal events too. A repeated event arrives as one event whose count rises, so read count rather than counting records.

These defaults apply to sources created from now on. Existing sources keep the configuration they were created with.

The agent’s kustomize base (see Onboard from the cluster inventory) also applies linkmesh-agent-capture.yaml. It is what lets Live Capture and the Enrichment and ownership check on the Kubernetes tab read records from your collectors. It installs two objects in linkmesh-system and grants no Kubernetes permission:

  • A Service, linkmesh-agent-capture, on port 14318 with internalTrafficPolicy: Local. A collector sends its capture copy to this Service, and the cluster delivers it only to the agent pod on the same node, so captured records never leave the node they were collected on.
  • A NetworkPolicy, linkmesh-agent-capture, that admits traffic to the agent pods only on TCP 14318 and only from pods labelled app: linkmesh-otelcol or app: linkmesh-otelcol-cluster, in any namespace. A collector you deployed with other labels needs its own entry there.

The agent listens on that port only while a capture is open, and each capture carries its own token.

If you applied the agent’s manifests one by one instead of with -k, apply this one too:

kubectl apply -n linkmesh-system -f <path-to>/linkmesh-agent/packaging/k8s/linkmesh-agent-capture.yaml

Without it, Live Capture and the enrichment check report that they cannot check on this install. Nothing else changes.

Complete OpenTelemetry Collector configs for the same jobs, validated against the collector and with the mistake that usually breaks each one: