apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: metrics
  labels:
    app.kubernetes.io/name: otel-collector
  name: otel-collector
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: otel-collector
  strategy:
    type: Recreate
  template:
    metadata:
      namespace: metrics
      labels:
        app.kubernetes.io/name: otel-collector
    spec:
      securityContext:
        runAsUser: 1000
        runAsGroup: 1000
        fsGroup: 1000
      containers:
        - args:
            - --config=/etc/otel-collector-config.yaml
          image: otel/opentelemetry-collector-contrib:0.104.0
          name: otel-collector
          ports:
            - containerPort: 4317
              protocol: TCP
            - containerPort: 4318
              protocol: TCP

          volumeMounts:
            - mountPath: /etc/otel-collector-config.yaml
              name: otel-collector-config
              subPath: otel-collector-config.yaml
      restartPolicy: Always
      volumes:
        - configMap:
            items:
              - key: config.yaml
                path: otel-collector-config.yaml
            name: otel-collector-config
          name: otel-collector-config