# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: opentelemetry-collector
  namespace: opentelemetry
  labels:
    app: opentelemetry-collector
spec:
  replicas: 2
  selector:
    matchLabels:
      app: opentelemetry-collector
  template:
    metadata:
      labels:
        app: opentelemetry-collector
    spec:
      serviceAccountName: opentelemetry-collector
      securityContext:
        {}
      containers:
      - name: opentelemetry-collector
        imagePullPolicy: Always
        image: otel/opentelemetry-collector-contrib:0.118.0
        args:
          - "--config=/conf/collector.yaml"
          - "--feature-gates=exporter.googlemanagedprometheus.intToDouble"
        ports:
          - name: otlp-grpc
            containerPort: 4317
            protocol: TCP
          - name: otlp-http
            containerPort: 4318
            protocol: TCP
        env:
          - name: MY_POD_IP
            valueFrom:
              fieldRef:
                apiVersion: v1
                fieldPath: status.podIP
        resources:
          requests:
            memory: "400Mi"
            cpu: "200m"
          limits:
            memory: "800Mi"
        volumeMounts:
          - name: collector-config
            mountPath: /conf
        readinessProbe:
          httpGet:
            path: /
            port: 13133
      volumes:
          - name: collector-config
            configMap:
              name: collector-config
              items:
              - key: collector.yaml
                path: collector.yaml
