# openshift
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  labels:
    app: grpc-server
    version: v1
  name: grpc-server-v1
  namespace: ${NAMESPACE}
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    app: grpc-server
    deploymentconfig: grpc-server-v1
    version: v1
  strategy:
    activeDeadlineSeconds: 21600
    resources: {}
    rollingParams:
      intervalSeconds: 1
      maxSurge: 25%
      maxUnavailable: 25%
      timeoutSeconds: 600
      updatePeriodSeconds: 1
    type: Rolling
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "true"
      labels:
        app: grpc-server
        deploymentconfig: grpc-server-v1
        version: v1
    spec:
      containers:
      - image: quay.io/dsanchor/quarkus-grpc-server:istio
        imagePullPolicy: IfNotPresent
        name: grpc-server-v1
        ports:
        - containerPort: 50050
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
---
apiVersion: apps.openshift.io/v1
kind: DeploymentConfig
metadata:
  labels:
    app: grpc-client
    version: v1
  name: grpc-client-v1
  namespace: ${NAMESPACE}
spec:
  replicas: 1
  revisionHistoryLimit: 10
  selector:
    app: grpc-client
    deploymentconfig: grpc-client-v1
    version: v1
  strategy:
    activeDeadlineSeconds: 21600
    resources: {}
    rollingParams:
      intervalSeconds: 1
      maxSurge: 25%
      maxUnavailable: 25%
      timeoutSeconds: 600
      updatePeriodSeconds: 1
    type: Rolling
  template:
    metadata:
      annotations:
        sidecar.istio.io/inject: "true"
      labels:
        app: grpc-client
        deploymentconfig: grpc-client-v1
        version: v1
    spec:
      containers:
      - image: quay.io/dsanchor/quarkus-grpc-client:istio
        imagePullPolicy: IfNotPresent
        name: grpc-client-v1
        ports:
        - containerPort: 8080
          protocol: TCP
        - containerPort: 8778
          protocol: TCP
        - containerPort: 9779
          protocol: TCP
        resources: {}
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: grpc-client
  name: grpc-client
  namespace: ${NAMESPACE}
spec:
  ports:
  - name: http-8080
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: grpc-client
  sessionAffinity: None
  type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: grpc-server
  name: grpc-server
  namespace: ${NAMESPACE}
spec:
  ports:
  - name: grpc-50050
    port: 50050
    protocol: TCP
    targetPort: 50050
  selector:
    app: grpc-server
  sessionAffinity: None
  type: ClusterIP
---
# istio
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  name: grpc-istio
  namespace: istio-system
spec:
  host: ${HOST}
  port:
    targetPort: http2
  to:
    kind: Service
    name: istio-ingressgateway
    weight: 100
  wildcardPolicy: None
---
apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
  name: grpc-quarkus
  namespace: ${NAMESPACE}
spec:
  selector:
    istio: ingressgateway # use Istio default gateway implementation
  servers:
  - port:
      number: 80
      name: http
      protocol: HTTP2
    hosts:
    - ${HOST}
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: grpc-client
  namespace: ${NAMESPACE}
spec:
  hosts:
  - ${HOST}
  gateways:
  - grpc-quarkus
  http:
  - route:
    - destination:
        host: grpc-client
        subset: version-v1
      weight: 100
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: grpc-client
  namespace: ${NAMESPACE}
spec:
  host: grpc-client
  trafficPolicy:
    tls:
      mode: ISTIO_MUTUAL
  subsets:
  - labels:
      version: v1
    name: version-v1
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: grpc-server
  namespace: ${NAMESPACE}
spec:
  hosts:
  - grpc-server	
  http:
  - route:
    - destination:
        host: grpc-server
        subset: version-v1
      weight: 100
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: grpc-server
  namespace: ${NAMESPACE}
spec:
  host: grpc-server
  trafficPolicy:
    tls:
      mode: ISTIO_MUTUAL
  subsets:
  - labels:
      version: v1
    name: version-v1