apiVersion: v1 kind: ServiceAccount metadata: name: corridora-kubernetes-state namespace: observability --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: name: corridora-kubernetes-state rules: - apiGroups: [""] resources: [events, namespaces, namespaces/status, nodes, nodes/spec, persistentvolumes, persistentvolumeclaims, pods, pods/status, replicationcontrollers, replicationcontrollers/status, resourcequotas, services] 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] --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: name: corridora-kubernetes-state roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole name: corridora-kubernetes-state subjects: - kind: ServiceAccount name: corridora-kubernetes-state namespace: observability --- apiVersion: v1 kind: ConfigMap metadata: name: corridora-kubernetes-state namespace: observability data: config.yaml: | receivers: k8s_cluster: auth_type: serviceAccount collection_interval: 30s node_conditions_to_report: [Ready, MemoryPressure, DiskPressure] allocatable_types_to_report: [cpu, memory] metrics: k8s.container.status.reason: enabled: true k8s.container.status.state: enabled: true k8s.pod.status_reason: enabled: true resource_attributes: k8s.container.status.last_terminated_reason: enabled: true k8s_events: auth_type: serviceAccount dedup_interval: 1m processors: memory_limiter: check_interval: 1s limit_mib: 400 spike_limit_mib: 80 resource/state: attributes: - key: service.name value: kubernetes-state action: upsert - key: k8s.cluster.name value: ${env:CORRIDORA_CLUSTER_NAME} action: upsert - key: service.namespace value: ${env:CORRIDORA_SERVICE_NAMESPACE} action: insert - key: deployment.environment.name value: ${env:CORRIDORA_DEPLOYMENT_ENVIRONMENT} action: insert transform/event_identity: error_mode: ignore flatten_data: true log_statements: - set(log.attributes["event.name"], "k8s.event") - set(resource.attributes["k8s.namespace.name"], log.attributes["k8s.namespace.name"]) where resource.attributes["k8s.object.kind"] != "Node" and log.attributes["k8s.namespace.name"] != nil - set(resource.attributes["k8s.pod.uid"], resource.attributes["k8s.object.uid"]) where resource.attributes["k8s.object.kind"] == "Pod" - set(resource.attributes["k8s.pod.name"], resource.attributes["k8s.object.name"]) where resource.attributes["k8s.object.kind"] == "Pod" - set(resource.attributes["k8s.node.uid"], resource.attributes["k8s.object.uid"]) where resource.attributes["k8s.object.kind"] == "Node" - set(resource.attributes["k8s.node.name"], resource.attributes["k8s.object.name"]) where resource.attributes["k8s.object.kind"] == "Node" - set(resource.attributes["k8s.deployment.uid"], resource.attributes["k8s.object.uid"]) where resource.attributes["k8s.object.kind"] == "Deployment" - set(resource.attributes["k8s.deployment.name"], resource.attributes["k8s.object.name"]) where resource.attributes["k8s.object.kind"] == "Deployment" - set(resource.attributes["k8s.statefulset.uid"], resource.attributes["k8s.object.uid"]) where resource.attributes["k8s.object.kind"] == "StatefulSet" - set(resource.attributes["k8s.statefulset.name"], resource.attributes["k8s.object.name"]) where resource.attributes["k8s.object.kind"] == "StatefulSet" - set(resource.attributes["k8s.daemonset.uid"], resource.attributes["k8s.object.uid"]) where resource.attributes["k8s.object.kind"] == "DaemonSet" - set(resource.attributes["k8s.daemonset.name"], resource.attributes["k8s.object.name"]) where resource.attributes["k8s.object.kind"] == "DaemonSet" - set(resource.attributes["k8s.replicaset.uid"], resource.attributes["k8s.object.uid"]) where resource.attributes["k8s.object.kind"] == "ReplicaSet" - set(resource.attributes["k8s.replicaset.name"], resource.attributes["k8s.object.name"]) where resource.attributes["k8s.object.kind"] == "ReplicaSet" batch: timeout: 5s send_batch_size: 1024 exporters: otlp_http/corridora: endpoint: ${env:CORRIDORA_OTLP_ENDPOINT} headers: X-CORRIDORA-KEY: ${env:CORRIDORA_INGEST_KEY} timeout: 30s sending_queue: queue_size: 128 retry_on_failure: max_elapsed_time: 300s service: pipelines: metrics: receivers: [k8s_cluster] processors: [memory_limiter, resource/state, batch] exporters: [otlp_http/corridora] logs: receivers: [k8s_events] processors: [memory_limiter, transform/event_identity, resource/state, batch] exporters: [otlp_http/corridora] --- apiVersion: apps/v1 kind: Deployment metadata: name: corridora-kubernetes-state namespace: observability spec: replicas: 1 strategy: type: Recreate selector: matchLabels: app: corridora-kubernetes-state template: metadata: labels: app: corridora-kubernetes-state spec: serviceAccountName: corridora-kubernetes-state containers: - name: collector image: otel/opentelemetry-collector-contrib:0.160.0 args: ["--config=/etc/corridora/config.yaml", "--feature-gates=transform.flatten.logs"] env: - name: CORRIDORA_CLUSTER_NAME value: replace-with-your-cluster-name - name: CORRIDORA_SERVICE_NAMESPACE value: replace-with-your-service-namespace - name: CORRIDORA_DEPLOYMENT_ENVIRONMENT value: staging - name: CORRIDORA_OTLP_ENDPOINT valueFrom: secretKeyRef: name: corridora-otel key: endpoint - name: CORRIDORA_INGEST_KEY valueFrom: secretKeyRef: name: corridora-otel key: ingest-key - name: GOMEMLIMIT value: 360MiB resources: requests: cpu: 100m memory: 256Mi limits: memory: 512Mi securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true runAsNonRoot: true capabilities: drop: [ALL] volumeMounts: - name: config mountPath: /etc/corridora readOnly: true volumes: - name: config configMap: name: corridora-kubernetes-state