华为云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民工金鱼哥2 天前
【华为云-云驻共创】UCS跨云多活容灾:让业务高可用不再是难题
华为云
知孤云出岫4 天前
华为云计算知识总结——及案例分享
华为·华为云·云计算
嘟嘟Listing4 天前
华为云安装docker
docker·容器·华为云
博客园团队4 天前
又给会员送福利,100台一年华为云2核2G3M云服务器
华为云
三掌柜6665 天前
鸿蒙原生应用开发及部署:首选华为云,开启HarmonyOS NEXT App新纪元
华为·华为云·harmonyos·鸿蒙·1024程序员节
shiming88795 天前
GaussDB Ustore存储引擎解读
华为云·gaussdb ustore
wangye114226 天前
共创一带一路经济体,土耳其海外媒体软文发稿 - 媒体宣发报道
大数据·人工智能·华为云·游戏引擎·产品运营
华为云开源7 天前
华为云开源项目Sermant正式成为CNCF官方项目
微服务·云原生·开源·华为云
DS小龙哥7 天前
基于STM32+华为云IOT设计的大棚育苗管理系统
stm32·物联网·华为云