---
apiVersion: v1
kind: Namespace
metadata:
  name: container-mom-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: metrics-service
  namespace: container-mom-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: metrics-service
  template:
    metadata:
      labels:
        app: metrics-service
    spec:
      containers:
      - name: metrics-service
        image: container-mom/metrics-service:latest
        ports:
        - containerPort: 8080
          name: http
        env:
        - name: OTEL_EXPORTER_OTLP_ENDPOINT
          value: "http://otel-collector:4317"
        livenessProbe:
          httpGet:
            path: /health
            port: http
          initialDelaySeconds: 10
        readinessProbe:
          httpGet:
            path: /health
            port: http
          initialDelaySeconds: 5
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: dns-service
  namespace: container-mom-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: dns-service
  template:
    metadata:
      labels:
        app: dns-service
    spec:
      containers:
      - name: dns-service
        image: container-mom/dns-service:latest
        ports:
        - containerPort: 8081
          name: http
        env:
        - name: K8S_NAMESPACE
          valueFrom:
            fieldRef:
              fieldPath: metadata.namespace
        livenessProbe:
          httpGet:
            path: /health
            port: http
          initialDelaySeconds: 10
        readinessProbe:
          httpGet:
            path: /health
            port: http
          initialDelaySeconds: 5
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: billing-service
  namespace: container-mom-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: billing-service
  template:
    metadata:
      labels:
        app: billing-service
    spec:
      containers:
      - name: billing-service
        image: container-mom/billing-service:latest
        ports:
        - containerPort: 8082
          name: http
        env:
        - name: STRIPE_API_KEY
          valueFrom:
            secretKeyRef:
              name: billing-secrets
              key: stripe-api-key
        livenessProbe:
          httpGet:
            path: /health
            port: http
          initialDelaySeconds: 10
        readinessProbe:
          httpGet:
            path: /health
            port: http
          initialDelaySeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: metrics-service
  namespace: container-mom-system
spec:
  selector:
    app: metrics-service
  ports:
  - port: 8080
    targetPort: http
    name: http
---
apiVersion: v1
kind: Service
metadata:
  name: dns-service
  namespace: container-mom-system
spec:
  selector:
    app: dns-service
  ports:
  - port: 8081
    targetPort: http
    name: http
---
apiVersion: v1
kind: Service
metadata:
  name: billing-service
  namespace: container-mom-system
spec:
  selector:
    app: billing-service
  ports:
  - port: 8082
    targetPort: http
    name: http
