云容器引擎 CCE-Ingress:创建Ingress

时间:2023-12-26 21:29:51

创建Ingress

下面例子中,使用http协议,关联的后端Service为“nginx:8080”,使用ELB作为Ingress控制器(metadata.annotations字段都是指定使用哪个ELB实例),当访问“http://192.168.10.155:8080/”时,流量转发“nginx:8080”对应的Service,从而将流量转发到对应Pod。

示例如下(适用于v1.23及以上版本的集群):
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: test-ingress
  annotations:
    kubernetes.io/elb.class: union
    kubernetes.io/elb.port: '8080'
    kubernetes.io/elb.id: aa7cf5ec-7218-4c43-98d4-c36c0744667a
spec:
  rules:
    - host: ''
      http:
        paths:
          - path: /
            backend:
              service:
                name: nginx
                port:
                  number: 8080
            property:
              ingress.beta.kubernetes.io/url-match-mode: STARTS_WITH
            pathType: ImplementationSpecific
  ingressClassName: cce
support.huaweicloud.com/basics-cce/kubernetes_0025.html