#
# 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.
#

# https://help.aliyun.com/document_detail/94925.html?spm=5176.2020520152.0.0.44ca16ddon5iJF
apiVersion: v1
kind: Service
metadata:
  name: apisix-gw-lb
  # namespace: default
  annotations:
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-additional-resource-tags: ""
    #
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-AddressType: "intranet"
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-network-type: "vpc"
    service.beta.kubernetes.io/alibaba-cloud-loadbalancer-force-override-listeners: "true"
    service.beta.kubernetes.io/alibaba-cloud-loadbalancer-persistence-timeout: "1800"
    service.beta.kubernetes.io/alibaba-cloud-loadbalancer-id: "lb-xx"
    #
    # http
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cert-id: ''
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: 'https:443'
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-spec: "slb.s1.small"
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-forward-port
    # http sticky-session
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-sticky-session: "on"
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-sticky-session-type: "insert"
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-cookie-timeout: "1800"
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-protocol-port: "http:80"
    #
    # health-check
    service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-type: "tcp"
    service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-connect-timeout: "4"
    service.beta.kubernetes.io/alibaba-cloud-loadbalancer-healthy-threshold: "4"
    service.beta.kubernetes.io/alibaba-cloud-loadbalancer-unhealthy-threshold: "4"
    service.beta.kubernetes.io/alibaba-cloud-loadbalancer-health-check-interval: "6"
    #
    service.beta.kubernetes.io/alibaba-cloud-loadbalancer-scheduler: "wlc"
    # ACL
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-status: "on"
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-id: "acl-xx"
    # service.beta.kubernetes.io/alibaba-cloud-loadbalancer-acl-type: "white"
    #
    service.beta.kubernetes.io/alibaba-cloud-loadbalancer-remove-unscheduled-backend: "on"
  labels:
    app: apisix-gw
spec:
  selector:
    app: apisix-gw
  ports:
    - protocol: TCP
      port: 80
      name: http
      targetPort: 9080
    - protocol: TCP
      port: 443
      name: https
      targetPort: 9443
    # - protocol: TCP
    #   port: 9180
    #   name: admin-port
    #   targetPort: 9180
  type: LoadBalancer
  externalTrafficPolicy: Local
  # sessionAffinity: ClientIP
