So i have a Statefulset with 2 replicas and OpenTelemetryCollector configmap
So i try to get index and logs in my opensearch use with this opentelemetry operator sidecar with 2 replicas and there are get logs from this two replicas/pods.
So the problem is there are not set Volume mount in my opentelemetry sidecar pod and i dont know how to set the volumes and volume mount path set in this below code.
This is the code :
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: my-app
annotations:
sidecar.opentelemetry.io/inject: "true"
spec:
replicas: 2
selector:
matchLabels:
app: my-app
serviceName: "my-app"
template:
metadata:
labels:
app: my-app
annotations:
sidecar.opentelemetry.io/inject: "true"
sidecar.opentelemetry.io/config: "otel-sidecar-config"
sidecar.opentelemetry.io/volumes: '[
{"name": "nginx-logs", "mountPath": "/var/log/nginx", "readOnly": true}
]'
spec:
nodeSelector:
kubernetes.io/hostname: minikube
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
volumeMounts:
- name: nginx-logs
mountPath: /var/log/nginx # ✅ Mount logs for Nginx
volumes:
- name: opentelemetry-config
configMap:
name: otel-sidecar-config
volumeClaimTemplates:
- metadata:
name: nginx-logs
spec:
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 1Gi
---
apiVersion: opentelemetry.io/v1beta1
kind: OpenTelemetryCollector
metadata:
name: otel-sidecar-config
spec:
mode: sidecar
config:
receivers:
filelog:
include:
- /var/log/nginx/access.log # ✅ Standard Nginx access log
- /var/log/nginx/error.log # ✅ Standard Nginx error log
start_at: beginning
include_file_path: true
include_file_name: true
operators:
- type: json_parser
timestamp:
parse_from: attributes.@t
layout: '%Y-%m-%dT%H:%M:%S.%LZ'
severity:
parse_from: attributes.@l
processors:
batch:
timeout: 10s
resource:
attributes:
- key: my-metadata-key
value: my-metadata-value
action: insert
exporters:
opensearch/log:
http:
endpoint: https://opensearch-cluster-master.open.svc.cluster.local:9200
auth:
authenticator: basicauth/client
tls:
insecure: false
insecure_skip_verify: true
timeout: 2m
logs_index: newcust
retry_on_failure:
enabled: true
service:
extensions:
- basicauth/client
pipelines:
logs:
receivers: [filelog]
processors: []
exporters: [opensearch/log]
extensions:
basicauth/client:
client_auth:
username: admin
password: admin
in this above code the set Volume try but this is not working the try is :
sidecar.opentelemetry.io/volumes: '[
{"name": "nginx-logs", "mountPath": "/var/log/nginx", "readOnly": true}
]'
this is my minikube dashboard screen shots :
Kubernetes version:
Client Version: v1.31.0
Kustomize Version: v5.4.2
Server Version: v1.31.0
You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.