apiVersion: apps/v1
kind: Deployment
metadata:
  name: objectstory-rpc
  namespace: juwan
  labels:
    app: objectstory-rpc
spec:
  replicas: 1
  selector:
    matchLabels:
      app: objectstory-rpc
  template:
    metadata:
      labels:
        app: objectstory-rpc
    spec:
      imagePullSecrets:
        - name: registry-creds
      containers:
      - name: objectstory-rpc
        image: registry.juwan.xhttp.zip/juwan/objectstory-rpc:latest
        ports:
        - name: grpc
          containerPort: 8080
        - name: metrics
          containerPort: 4001
        env:
          - name: S3_ENDPOINT
            valueFrom:
              secretKeyRef:
                name: objectstory-s3
                key: endpoint
          - name: S3_ACCESS_KEY
            valueFrom:
              secretKeyRef:
                name: objectstory-s3
                key: access-key
          - name: S3_SECRET_KEY
            valueFrom:
              secretKeyRef:
                name: objectstory-s3
                key: secret-key
          - name: S3_BUCKET_NAME
            valueFrom:
              secretKeyRef:
                name: objectstory-s3
                key: bucket
          - name: S3_REGION
            valueFrom:
              secretKeyRef:
                name: objectstory-s3
                key: region
        resources:
          requests:
            cpu: 10m
            memory: 32Mi
          limits:
            memory: 512Mi

---
apiVersion: v1
kind: Service
metadata:
  name: objectstory-rpc-svc
  namespace: juwan
spec:
  ports:
    - name: grpc
      port: 8080
      targetPort: 8080
    - name: metrics
      port: 4001
      targetPort: 4001
  selector:
    app: objectstory-rpc

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: objectstory-api
  namespace: juwan
  labels:
    app: objectstory-api
spec:
  replicas: 1
  selector:
    matchLabels:
      app: objectstory-api
  template:
    metadata:
      labels:
        app: objectstory-api
    spec:
      imagePullSecrets:
        - name: registry-creds
      containers:
      - name: objectstory-api
        image: registry.juwan.xhttp.zip/juwan/objectstory-api:latest
        ports:
        - name: http
          containerPort: 8888
        - name: metrics
          containerPort: 4001
        env:
          - name: OBJECTSTORY_RPC_TARGET
            value: "objectstory-rpc-svc.juwan:8080"
        resources:
          requests:
            cpu: 10m
            memory: 32Mi
          limits:
            memory: 512Mi

---
apiVersion: v1
kind: Service
metadata:
  name: objectstory-api-svc
  namespace: juwan
spec:
  ports:
    - name: http
      port: 8888
      targetPort: 8888
    - name: metrics
      port: 4001
      targetPort: 4001
  selector:
    app: objectstory-api
