本文主要是介绍华为云CCE集群创建loadBalancer,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
目录
一、目的
二、创建应用
三、创建服务 loadBalancer
四、域名解析
五、验证
一、目的
1、为CCE容器应用创建loadBalancer服务,并且绑定https协议的域名
2、公网访问域名: https://test.******.com
3、CCE创建用于公网域名访问的loadBalancer,不需要额外创建ingress路由
二、创建应用
1、创建无状态应用: nginx
2、创建无状态应用nginx的清单内容
# 命令行创建无状态 nginx 应用代码:kubectl create deploy nginx --image=nginx:alpine-perl -n default
三、创建服务 loadBalancer
1、创建应用nginx的服务
2、注意: 上面设置关于设置域名的内容是需要提前在ELB导入域名证书
3、nginx服务清单文件
第1步创建loadBalancer服务的代码结果是:
# 创建 loadblance 的代码结果 nginx-svc.yaml 是:metadata:name: nginx-svcnamespace: defaultuid: 9255776c-5505-4f6c-9bf3-06ff4bcba11cresourceVersion: '22021'creationTimestamp: '2024-09-01T15:38:28Z'labels:app: nginxversion: v1annotations: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: 1dafe21b9ec74b32a96e942fc439ae8ckubernetes.io/elb.class: performancekubernetes.io/elb.client-ca-cert-id: ''kubernetes.io/elb.eip-id: 68e2dd0c-b625-44da-94d3-91597484bb8akubernetes.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-0a2eea979f31kubernetes.io/elb.lb-algorithm: ROUND_ROBINkubernetes.io/elb.mark: '0'kubernetes.io/elb.protocol-port: https:443kubernetes.io/elb.security-policy-id: ''kubernetes.io/elb.security-pool-protocol: 'off'kubernetes.io/elb.tls-certificate-ids: 1dafe21b9ec74b32a96e942fc439ae8ckubernetes.io/elb.tls-ciphers-policy: tls-1-2finalizers:- service.kubernetes.io/load-balancer-cleanupmanagedFields:- manager: cfe-apiserveroperation: UpdateapiVersion: v1time: '2024-09-01T15:38:28Z'fieldsType: FieldsV1fieldsV1: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-manageroperation: UpdateapiVersion: v1time: '2024-09-01T15:38:37Z'fieldsType: FieldsV1fieldsV1:f:metadata:f:finalizers:.: {}v:"service.kubernetes.io/load-balancer-cleanup": {}f:status:f:loadBalancer:f:ingress: {}subresource: status- manager: huawei-cloud-controller-manageroperation: UpdateapiVersion: v1time: '2024-09-01T15:39:43Z'fieldsType: FieldsV1fieldsV1: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-0protocol: TCPport: 443targetPort: 80nodePort: 30208listenerProtocol: HTTPSselector:app: nginxversion: v1clusterIP: 10.247.103.12clusterIPs:- 10.247.103.12type: LoadBalancersessionAffinity: NoneloadBalancerIP: 121.37.16.149externalTrafficPolicy: ClusteripFamilies:- IPv4ipFamilyPolicy: SingleStackallocateLoadBalancerNodePorts: trueinternalTrafficPolicy: Cluster
status:loadBalancer:ingress:- ip: 121.37.16.149- ip: 172.16.0.179
apiVersion: v1
kind: Service
4、负载均衡器ELB
loadblance服务创建成功后,自动成名为 nginx-elb 的负载均衡(默认是受保护,不建议手工直接修改改的)
四、域名解析
五、验证
通过公网访问域名验证
这篇关于华为云CCE集群创建loadBalancer的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!