# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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
#
#     http://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: service-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: service
  template:
    metadata:
      labels:
        app: service
    spec:
      containers:
        - name: service
          image: ${IMAGE_NAME}
          env:
            - name: OAP_BACKEND_ADDR
              value: "skywalking-oap.istio-system:11800"

---

apiVersion: v1
kind: Service
metadata:
  name: service
spec:
  selector:
    app: service
  ports:
    - name: service-http-entry
      protocol: TCP
      port: 80
      targetPort: 80

---

apiVersion: v1
kind: ConfigMap
metadata:
  name: nginx-config
data:
  nginx.conf: |
    user nginx;
    worker_processes  auto;
    events {
      worker_connections  102400;
    }
    http {
      server {
        listen       80;
        server_name proxy;
        location /provider {
          proxy_pass http://service:80/provider;
          proxy_http_version 1.1;
        }
      }
    }

---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.25
          volumeMounts:
            - name: config-volume
              mountPath: /etc/nginx/nginx.conf
              subPath: nginx.conf
      volumes:
        - name: config-volume
          configMap:
            name: nginx-config
            items:
              - key: nginx.conf
                path: nginx.conf

---

apiVersion: v1
kind: Service
metadata:
  name: proxy
spec:
  selector:
    app: nginx
  ports:
    - name: proxy-entry
      protocol: TCP
      port: 80
      targetPort: 80