# This should work on Kubernetes deployments that have LoadBalancer support
apiVersion: v1
kind: Service
metadata:
  name: redis-server
  labels:
    app: redis-server
    tier: cache
spec:
  type: ClusterIP
  ports:
  - name: tcp-6379
    port: 6379
    protocol: TCP
    targetPort: 6379
  selector:
    app: redis-server
    tier: cache
---
apiVersion: v1
kind: Service
metadata:
  name: yelb-db
  labels:
    app: yelb-db
    tier: backenddb
spec:
  type: ClusterIP
  ports:
  - name: tcp-5432
    port: 5432
    protocol: TCP
    targetPort: 5432
  selector:
    app: yelb-db
    tier: backenddb
---
apiVersion: v1
kind: Service
metadata:
  name: yelb-appserver
  labels:
    app: yelb-appserver
    tier: middletier
spec:
  type: ClusterIP
  ports:
  - name: http-4567
    port: 4567
    protocol: TCP
    targetPort: 4567
  selector:
    app: yelb-appserver
    tier: middletier
---
apiVersion: v1
kind: Service
metadata:
  name: yelb-ui
  labels:
    app: yelb-ui
    tier: frontend
spec:
  type: LoadBalancer
  ports:
  - name: http-80
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: yelb-ui
    tier: frontend
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: yelb-ui
spec:
  replicas: 1
  selector:
    matchLabels: 
      app: yelb-ui
      tier: frontend    
  template:
    metadata:
      labels:
        app: yelb-ui
        tier: frontend
        version: v1
    spec:
      containers:
      - name: yelb-ui
        image:  public.ecr.aws/v2k0k1b1/yelb/yelb-ui:latest
        imagePullPolicy: Always
        ports:
        - name: http-80
          containerPort: 80
          protocol: TCP
        resources:
          limits:
            cpu: 512m
            memory: 1024Mi  
          requests:
            cpu: 256m
            memory: 256Mi  
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: redis-server
spec:
  replicas: 1
  selector:
    matchLabels: 
      app: redis-server
      tier: cache
  template:
    metadata:
      labels:
        app: redis-server
        tier: cache
        version: v1        
    spec:
      containers:
      - name: redis-server
        image: redis:4.0.2
        ports:
        - name: tcp-6379
          containerPort: 6379
          protocol: TCP        
        resources:
          limits:
            cpu: 512m
            memory: 1024Mi 
          requests:
            cpu: 256m
            memory: 256Mi  
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: yelb-db 
spec:
  replicas: 1
  selector:
    matchLabels: 
      app: yelb-db
      tier: backenddb
  template:
    metadata:
      labels:
        app: yelb-db
        tier: backenddb
        version: v1        
    spec:
      containers:
      - name: yelb-db
        image:  mreferre/yelb-db:0.5
        ports:
        - name: tcp-5432
          containerPort: 5432
          protocol: TCP
        resources:
          limits:
            cpu: 1024m
            memory: 2048Mi
          requests:
            cpu: 256m
            memory: 256Mi    
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: yelb-appserver-v1
  labels:
    app: yelb-appserver
    tier: middletier  
    version: v1
spec:
  replicas: 1
  selector:
    matchLabels: 
      app: yelb-appserver
      tier: middletier
      version: v1
  template:
    metadata:
      labels:
        app: yelb-appserver
        tier: middletier
        version: v1        
    spec:
      containers:
      - name: yelb-appserver
        image:  public.ecr.aws/v2k0k1b1/yelb/yelb-appserver:latest
        imagePullPolicy: Always
        ports:
        - name: http-4567
          containerPort: 4567
          protocol: TCP
        resources:
          limits:
            cpu: 1024m
            memory: 1024Mi
          requests:
            cpu: 256m
            memory: 256Mi 
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: yelb-appserver-v2
  labels:
    app: yelb-appserver
    tier: middletier  
    version: v2
spec:
  replicas: 1
  selector:
    matchLabels: 
      app: yelb-appserver
      tier: middletier
      version: v2
  template:
    metadata:
      labels:
        app: yelb-appserver
        tier: middletier
        version: v2        
    spec:
      containers:
      - name: yelb-appserver
        image:  public.ecr.aws/v2k0k1b1/yelb/yelb-appserver:O3
        imagePullPolicy: Always
        ports:
        - name: http-4567
          containerPort: 4567
          protocol: TCP
        resources:
          limits:
            cpu: 1024m
            memory: 1024Mi
          requests:
            cpu: 256m
            memory: 256Mi  
