# 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: otel-collector
  namespace: memorystore-cluster-autoscaler # kpt-set: ${namespace}
  labels:
    app: otel-collector
spec:
  replicas: 1
  selector:
    matchLabels:
      app: otel-collector
  template:
    metadata:
      labels:
        app: otel-collector
    spec:
      containers:
        - name: otel-collector
          image: otel/opentelemetry-collector-contrib:0.93.0
          resources:
            requests:
              memory: "128Mi"
              cpu: "250m"
            limits:
              memory: "256Mi"
          args:
            - --config
            - /etc/otel/config.yaml
          securityContext:
            allowPrivilegeEscalation: false
            readOnlyRootFilesystem: true
            runAsNonRoot: true
            capabilities:
              drop:
                - all
          volumeMounts:
            - mountPath: /etc/otel/
              name: otel-config
      volumes:
        - name: otel-config
          configMap:
            name: otel-config
      nodeSelector:
        iam.gke.io/gke-metadata-server-enabled: "true"
      serviceAccountName: otel-collector-sa
      automountServiceAccountToken: true
---
apiVersion: v1
kind: Service
metadata:
  name: otel-collector
  namespace: memorystore-cluster-autoscaler # kpt-set: ${namespace}
spec:
  type: ClusterIP
  selector:
    app: otel-collector
  ports:
    - protocol: TCP
      port: 4317
      targetPort: 4317
