华为云CCE集群创建loadBalancer

目录

一、目的

二、创建应用

[三、创建服务 loadBalancer](#三、创建服务 loadBalancer)

四、域名解析

五、验证


一、目的

1、为CCE容器应用创建loadBalancer服务,并且绑定https协议的域名

2、公网访问域名: https://test.******.com

3、CCE创建用于公网域名访问的 loadBalancer**,不需要额外创建ingress路由**

二、创建应用

1、创建无状态应用: nginx

2、创建无状态应用nginx的清单内容

bash 复制代码
# 命令行创建无状态 nginx 应用代码:

kubectl create deploy nginx --image=nginx:alpine-perl -n default

三、创建服务 loadBalancer

1、创建应用nginx的服务

2、注意: 上面设置关于设置域名的内容是需要提前在ELB导入域名证书

3、nginx服务清单文件

第1步创建loadBalancer服务的代码结果是:

bash 复制代码
# 创建 loadblance 的代码结果 nginx-svc.yaml 是:


metadata:
  name: nginx-svc
  namespace: default
  uid: 9255776c-5505-4f6c-9bf3-06ff4bcba11c
  resourceVersion: '22021'
  creationTimestamp: '2024-09-01T15:38:28Z'
  labels:
    app: nginx
    version: v1
  annotations:
    kubernetes.io/elb.acl-id: ''
    kubernetes.io/elb.autocreate: '{"name":"nginx-elb","type":"public","bandwidth_name":"cce-bandwidth-1725204558134","bandwidth_chargemode":"traffic","bandwidth_size":5,"bandwidth_sharetype":"PER","eip_type":"5_bgp","available_zone":["cn-south-2b","cn-south-1c","cn-south-1e"],"elb_virsubnet_ids":["2d1628a0-bf60-434f-938b-ae329ab43834"],"l7_flavor_name":"L7_flavor.elb.pro.max","l4_flavor_name":"","vip_subnet_cidr_id":"6d225e5c-6ee6-4bf3-b5aa-dd74e366239f"}'
    kubernetes.io/elb.cert-id: 1dafe21b9ec74b32a96e942fc439ae8c
    kubernetes.io/elb.class: performance
    kubernetes.io/elb.client-ca-cert-id: ''
    kubernetes.io/elb.eip-id: 68e2dd0c-b625-44da-94d3-91597484bb8a
    kubernetes.io/elb.health-check-flag: 'on'
    kubernetes.io/elb.health-check-option: '{"protocol":"TCP","delay":"5","timeout":"10","max_retries":"3"}'
    kubernetes.io/elb.id: 76d56aaa-7f20-40c9-9414-0a2eea979f31
    kubernetes.io/elb.lb-algorithm: ROUND_ROBIN
    kubernetes.io/elb.mark: '0'
    kubernetes.io/elb.protocol-port: https:443
    kubernetes.io/elb.security-policy-id: ''
    kubernetes.io/elb.security-pool-protocol: 'off'
    kubernetes.io/elb.tls-certificate-ids: 1dafe21b9ec74b32a96e942fc439ae8c
    kubernetes.io/elb.tls-ciphers-policy: tls-1-2
  finalizers:
    - service.kubernetes.io/load-balancer-cleanup
  managedFields:
    - manager: cfe-apiserver
      operation: Update
      apiVersion: v1
      time: '2024-09-01T15:38:28Z'
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            .: {}
            f:kubernetes.io/elb.acl-id: {}
            f:kubernetes.io/elb.autocreate: {}
            f:kubernetes.io/elb.cert-id: {}
            f:kubernetes.io/elb.class: {}
            f:kubernetes.io/elb.client-ca-cert-id: {}
            f:kubernetes.io/elb.health-check-flag: {}
            f:kubernetes.io/elb.health-check-option: {}
            f:kubernetes.io/elb.lb-algorithm: {}
            f:kubernetes.io/elb.protocol-port: {}
            f:kubernetes.io/elb.security-policy-id: {}
            f:kubernetes.io/elb.security-pool-protocol: {}
            f:kubernetes.io/elb.tls-certificate-ids: {}
            f:kubernetes.io/elb.tls-ciphers-policy: {}
          f:labels:
            .: {}
            f:app: {}
            f:version: {}
        f:spec:
          f:allocateLoadBalancerNodePorts: {}
          f:externalTrafficPolicy: {}
          f:internalTrafficPolicy: {}
          f:ports:
            .: {}
            k:{"port":443,"protocol":"TCP"}:
              .: {}
              f:name: {}
              f:port: {}
              f:protocol: {}
              f:targetPort: {}
          f:selector: {}
          f:sessionAffinity: {}
          f:type: {}
    - manager: huawei-cloud-controller-manager
      operation: Update
      apiVersion: v1
      time: '2024-09-01T15:38:37Z'
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:finalizers:
            .: {}
            v:"service.kubernetes.io/load-balancer-cleanup": {}
        f:status:
          f:loadBalancer:
            f:ingress: {}
      subresource: status
    - manager: huawei-cloud-controller-manager
      operation: Update
      apiVersion: v1
      time: '2024-09-01T15:39:43Z'
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            f:kubernetes.io/elb.eip-id: {}
            f:kubernetes.io/elb.id: {}
            f:kubernetes.io/elb.mark: {}
        f:spec:
          f:loadBalancerIP: {}
spec:
  ports:
    - name: cce-service-0
      protocol: TCP
      port: 443
      targetPort: 80
      nodePort: 30208
      listenerProtocol: HTTPS
  selector:
    app: nginx
    version: v1
  clusterIP: 10.247.103.12
  clusterIPs:
    - 10.247.103.12
  type: LoadBalancer
  sessionAffinity: None
  loadBalancerIP: 121.37.16.149
  externalTrafficPolicy: Cluster
  ipFamilies:
    - IPv4
  ipFamilyPolicy: SingleStack
  allocateLoadBalancerNodePorts: true
  internalTrafficPolicy: Cluster
status:
  loadBalancer:
    ingress:
      - ip: 121.37.16.149
      - ip: 172.16.0.179
apiVersion: v1
kind: Service

4、负载均衡器ELB

loadblance服务创建成功后,自动成名为 nginx-elb 的负载均衡(默认是受保护,不建议手工直接修改改的)

四、域名解析

五、验证

通过公网访问域名验证

相关推荐
学习向前冲10 小时前
CCE-基础
华为云
郝晨妤2 天前
鸿蒙原生应用开发元服务 元服务是什么?和App的关系?(保姆级步骤)
android·ios·华为od·华为·华为云·harmonyos·鸿蒙
咚璟2 天前
小熊派Nano接入华为云
华为云·liteos·小熊派
学习向前冲7 天前
华为云前台用户可挂载数据盘和系统盘是怎么做到的?
华为云
华为云PaaS服务小智7 天前
华为云分布式缓存服务(DCS)专家深度解析Valkey,助力openEuler峰会
华为云·分布式缓存
学习向前冲7 天前
华为云租户网络-用的是隧道技术
华为云
学习向前冲8 天前
华为云前台展示公网访问需要购买EIP,EIP流量走向
华为云
xiao_xx9 天前
华为云计算HCIE-Cloud Computing V3.0试验考试北京考场经验分享
经验分享·华为云
d4uu12 天前
华为云镜像仓库基本操作
docker·华为云
华为云PaaS服务小智15 天前
华为大咖说 | 浅谈智能运维技术
运维·华为·华为云