通过外网ULB访问Service

注意:ULB相关参数目前均不支持Update,如不确认如何填写,请咨询UCloud 技术支持。

外网模式下,ULB支持“报文转发(ULB4)”及“请求代理(ULB7)”两种转发模式,两种模式配置方式大致相同,默认推荐使用ULB4。

通过外网ULB4暴露服务

使用外网ULB4来暴露服务非常简单,如无特别要求,不需要填写任何 annotations。
apiVersion: v1
kind: Service
metadata:
  name: ucloud-nginx-out-tcp-new
  labels:
    app: ucloud-nginx-out-tcp-new
  annotations:
    ulb-field: none    
spec:
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  selector:
    app: ucloud-nginx-out-tcp-new
---
apiVersion: v1
kind: Pod
metadata:
  name: test-nginx-out-tcp
  labels:
    app: ucloud-nginx-out-tcp-new
spec:
  containers:
  - name: nginx
    image: uhub.service.ucloud.cn/ucloud/nginx:1.9.2
    ports:
    - containerPort: 80

通过外网ULB7暴露服务

需要指定vserver-listentype为requestproxy,其他参数视情况配置,不指定则为默认值。
apiVersion: v1
kind: Service
metadata:
  name: ucloud-nginx-out-tcp-new
  labels:
    app: ucloud-nginx-out-tcp-new
  annotations:
    "service.beta.kubernetes.io/ucloud-load-balancer-vserver-listentype": "RequestProxy" ## 监听器转发模式,支持RequestProxy和PacketsTransmit,默认为PacketsTransmit
    "service.beta.kubernetes.io/ucloud-load-balancer-vserver-protocol": "HTTP"       ## VServer协议类型,默认为HTTP,支持TCP、HTTP、HTTPS
    "service.beta.kubernetes.io/ucloud-load-balancer-vserver-method": "Roundrobin"  ##负载均衡模式,默认为Roundrobin,协议为HTTP时支持Roundrobin,Source    
    "service.beta.kubernetes.io/ucloud-load-balancer-vserver-session-persistence-type": "None" ##默认为None,支持None,ServerInsert,UserDefined
    "service.beta.kubernetes.io/ucloud-load-balancer-vserver-session-persistence-info": "string" ##用户自定义KEY,会话保持方式为UserDefined有效
    "service.beta.kubernetes.io/ucloud-load-balancer-vserver-client-timeout": "60" ##空闲连接回收时间,单位为秒,取值范围:时(0,86400],默认值为60
    "service.beta.kubernetes.io/ucloud-load-balancer-vserver-monitor-type": "Path" ##健康检查类型,支持Port和Path,默认为Port
    "service.beta.kubernetes.io/ucloud-load-balancer-vserver-monitor-domain": "www.ucloud.cn" ##http检查域名
    "service.beta.kubernetes.io/ucloud-load-balancer-vserver-monitor-path": "/html/index"  ##http检查路径    
    ## 以下为EIP的相关注释  
    "service.beta.kubernetes.io/ucloud-load-balancer-eip-paymode": "ShareBandwidth" ###支持Traffic、Bandwidth、ShareBandwidth,默认为Bandwidth
    "service.beta.kubernetes.io/ucloud-load-balancer-eip-sharebandwidthid": "bwshare-d8dklw" ##共享带宽id
    "service.beta.kubernetes.io/ucloud-load-balancer-eip-bandwidth": "0" ##共享带宽模式下无需指定,或者配置为0,bandwidth下默认为10 
    "service.beta.kubernetes.io/ucloud-load-balancer-eip-chargetype": "month" ##付费模式,支持month,year,dynamic
    "service.beta.kubernetes.io/ucloud-load-balancer-eip-quantity": "1" ##付费时长,默认为1,chargetype为dynimic时无效
spec:
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
  selector:
    app: ucloud-nginx-out-tcp-new
---
apiVersion: v1
kind: Pod
metadata:
  name: test-nginx-out-tcp
  labels:
    app: ucloud-nginx-out-tcp-new
spec:
  containers:
  - name: nginx
    image: uhub.service.ucloud.cn/ucloud/nginx:1.9.2
    ports:
    - containerPort: 80
如有疑问请联系 技术支持