# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: cloud-trace-demo-a
  labels:
    app: cloud-trace-demo-app-a
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cloud-trace-demo-app-a
  template:
    metadata:
      name: cloud-trace-demo-a
      labels:
        app: cloud-trace-demo-app-a
    spec:
      containers:
      - name: cloud-trace-demo-container
        image: gcr.io/google_samples/cloud-trace-demo-opentelemetry:latest
        imagePullPolicy: "Always"
        command:
        - python
        args:
        - app.py
        ports:
        - containerPort: 8080
        env:
        - name: PORT
          value: "8080"
        - name: KEYWORD
          value: "Hello, I am service A"
        - name: ENDPOINT
          value: "http://cloud-trace-demo-b:8090"
---
apiVersion: v1
kind: Service
metadata:
  name: cloud-trace-demo-a
spec:
  selector:
    app: cloud-trace-demo-app-a
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080
  type: LoadBalancer

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cloud-trace-demo-b
  labels:
    app: cloud-trace-demo-app-b
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cloud-trace-demo-app-b
  template:
    metadata:
      name: cloud-trace-demo-b
      labels:
        app: cloud-trace-demo-app-b
    spec:
      containers:
      - name: cloud-trace-demo-container
        image: gcr.io/google_samples/cloud-trace-demo-opentelemetry:latest
        imagePullPolicy: "Always"
        command:
        - python
        args:
        - app.py
        ports:
        - containerPort: 8090
        env:
        - name: PORT
          value: "8090"
        - name: KEYWORD
          value: "And I am service B"
        - name: ENDPOINT
          value: "http://cloud-trace-demo-c:8090"

---
apiVersion: v1
kind: Service
metadata:
  name: cloud-trace-demo-b
spec:
  selector:
    app: cloud-trace-demo-app-b
  ports:
  - protocol: TCP
    port: 8090
    targetPort: 8090
  type: ClusterIP

---
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: cloud-trace-demo-c
  labels:
    app: cloud-trace-demo-app-c
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cloud-trace-demo-app-c
  template:
    metadata:
      name: cloud-trace-demo-c
      labels:
        app: cloud-trace-demo-app-c
    spec:
      containers:
      - name: cloud-trace-demo-container
        image: gcr.io/google_samples/cloud-trace-demo-opentelemetry:latest
        imagePullPolicy: "Always"
        command:
        - python
        args:
        - app.py
        ports:
        - containerPort: 8090
        env:
        - name: PORT
          value: "8090"
        - name: KEYWORD
          value: "Hello, I am service C"

---
apiVersion: v1
kind: Service
metadata:
  name: cloud-trace-demo-c
spec:
  selector:
    app: cloud-trace-demo-app-c
  ports:
  - protocol: TCP
    port: 8090
    targetPort: 8090
  type: ClusterIP
