华为云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 的负载均衡(默认是受保护,不建议手工直接修改改的)

四、域名解析

五、验证

通过公网访问域名验证

相关推荐
一只IT攻城狮9 小时前
华为云语音交互SIS的使用案例(文字转语音-详细教程)
java·后端·华为云·音频·语音识别
終不似少年遊*9 小时前
华为云计算HCIE笔记04
网络·华为云·云计算·学习笔记·hcie·认证·数据中心
終不似少年遊*17 小时前
华为云计算HCIE笔记05
网络·华为云·云计算·学习笔记·hcie·认证·hcs
枫叶丹420 小时前
【HarmonyOS之旅】HarmonyOS开发基础知识(三)
华为od·华为·华为云·harmonyos
nangonghen2 天前
在华为云通过operator部署Doris v2.1集群
kubernetes·华为云·doris·operator
Gauss松鼠会2 天前
GaussDB 企业版轻量化部署探索(二)
数据库·人工智能·docker·华为云·gaussdb
play_big_knife3 天前
鸿蒙项目云捐助第二十讲云捐助项目物联网IOT的使用
物联网·华为·华为云·harmonyos·鸿蒙·鸿蒙开发·iot开发
play_big_knife4 天前
鸿蒙项目云捐助第十五讲云数据库的初步使用
数据库·华为云·harmonyos·鸿蒙·云开发·云数据库·鸿蒙开发
枫叶丹44 天前
【HarmonyOS之旅】HarmonyOS开发基础知识(二)
华为od·华为·华为云·harmonyos
終不似少年遊*4 天前
华为云计算HCIE笔记01
运维·网络·笔记·华为云·云计算·hcie