---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: orders
  labels:
    name: orders
  namespace: sock-shop
spec:
  replicas: 1
  selector:
    matchLabels:
      name: orders
  template:
    metadata:
      labels:
        name: orders
    spec:
      containers:
      - name: orders
        image: weaveworksdemos/orders:0.4.7
        env:
          - name: OTEL_RESOURCE_ATTRIBUTES
            value: service.name = orders
          - name: JAVA_OPTS
            value: -Xms64m -Xmx128m -XX:PermSize=32m -XX:MaxPermSize=64m -XX:+UseG1GC -Djava.security.egd=file:/dev/urandom -Dspring.sleuth.enabled=false -javaagent:/tmp/opentelemetry-javaagent-all.jar
          - name: OTEL_EXPORTER_OTLP_ENDPOINT
            value: http://otel-collector.monitoring.svc.cluster.local:4317
        resources:
          requests:
            cpu: 100m
          limits:
            cpu: 200m
            memory: 500Mi
        ports:
        - containerPort: 80
        securityContext:
          runAsNonRoot: true
          runAsUser: 10001
          capabilities:
            drop:
              - all
            add:
              - NET_BIND_SERVICE
          readOnlyRootFilesystem: true
        volumeMounts:
        - mountPath: /tmp
          name: tmp-volume
        livenessProbe:
          httpGet:
            path: /health
            port: 80
          initialDelaySeconds: 300
          periodSeconds: 3
        readinessProbe:
          httpGet:
            path: /health
            port: 80
          initialDelaySeconds: 180
          periodSeconds: 3
      initContainers:
      - command:
        - wget
        - "-O"
        - /tmp/opentelemetry-javaagent-all.jar
        - https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v1.5.3/opentelemetry-javaagent-all.jar
        name: otel-javaagent
        image: busybox
        volumeMounts:
        - mountPath: /tmp
          name: tmp-volume
      volumes:
        - name: tmp-volume
          emptyDir:
            medium: Memory
      nodeSelector:
        beta.kubernetes.io/os: linux
