如何在Digitalocean上的集群中添加负载均衡器>>

问题描述 投票:0回答:1

我使用Kubeadm和3个液滴在Digitalocean上创建了一个集群。由于这不是Digital ocean的托管Kubernetes集群,因此如何手动设置LoadBalancer?

我已经尝试通过将以下行添加到部署配置文件来添加外部负载均衡器

...
replicaCount: 1

image:
  repository: turfff/node-replicas
  tag: latest
  pullPolicy: IfNotPresent
...
service:
  type: LoadBalancer
  port: 80
  targetPort: 8080
...

但是,当我运行配置并检查创建的svc时

kubectl get svc

NAME                              TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
kubernetes                        ClusterIP      10.96.0.1       <none>        443/TCP        13d
mongo-mongodb-replicaset          ClusterIP      None            <none>        27017/TCP      3h15m
mongo-mongodb-replicaset-client   ClusterIP      None            <none>        27017/TCP      3h15m
nodejs-nodeapp                    LoadBalancer   10.109.213.98   <pending>     80:31769/TCP   61m

kubectl describe svc nodejs-nodeapp

Name:                     nodejs-nodeapp
Namespace:                default
Labels:                   app.kubernetes.io/instance=nodejs
                          app.kubernetes.io/managed-by=Tiller
                          app.kubernetes.io/name=nodeapp
                          app.kubernetes.io/version=1.0
                          helm.sh/chart=nodeapp-0.1.0
Annotations:              <none>
Selector:                 app.kubernetes.io/instance=nodejs,app.kubernetes.io/name=nodeapp
Type:                     LoadBalancer
IP:                       10.109.213.98
Port:                     http  80/TCP
TargetPort:               http/TCP
NodePort:                 http  31769/TCP
Endpoints:                10.244.2.19:8080
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>

kubectl get pods

NAME                              READY   STATUS    RESTARTS   AGE
mongo-mongodb-replicaset-0        1/1     Running   0          3h18m
mongo-mongodb-replicaset-1        1/1     Running   0          3h17m
mongo-mongodb-replicaset-2        1/1     Running   0          3h16m
nodejs-nodeapp-7b89db8888-sjcbq   1/1     Running   0          65m

kubectl describe pod nodejs-nodeapp

Name:               nodejs-nodeapp-7b89db8888-sjcbq
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               worker-02/206.81.3.65
Start Time:         Sun, 14 Jun 2020 11:21:07 +0100
Labels:             app.kubernetes.io/instance=nodejs
                    app.kubernetes.io/name=nodeapp
                    pod-template-hash=7b89db8888
Annotations:        <none>
Status:             Running
IP:                 10.244.2.19
Controlled By:      ReplicaSet/nodejs-nodeapp-7b89db8888
Containers:
  nodeapp:
    Container ID:   docker://f0d4d01f....
    Image:          turfff/node-replicas:latest
    Image ID:       docker-pullable://turfff/node-replicas@sha256:34d...
    Port:           8080/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Sun, 14 Jun 2020 11:21:08 +0100
    Ready:          True
    Restart Count:  0
    Liveness:       http-get http://:http/sharks delay=0s timeout=1s period=10s #success=1 #failure=3
    Readiness:      http-get http://:http/sharks delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:
      MONGO_USERNAME:    <set to the key 'MONGO_USERNAME' in secret 'nodejs-auth'>          Optional: false
      MONGO_PASSWORD:    <set to the key 'MONGO_PASSWORD' in secret 'nodejs-auth'>          Optional: false
      MONGO_HOSTNAME:    <set to the key 'MONGO_HOSTNAME' of config map 'nodejs-config'>    Optional: false
      MONGO_PORT:        <set to the key 'MONGO_PORT' of config map 'nodejs-config'>        Optional: false
      MONGO_DB:          <set to the key 'MONGO_DB' of config map 'nodejs-config'>          Optional: false
      MONGO_REPLICASET:  <set to the key 'MONGO_REPLICASET' of config map 'nodejs-config'>  Optional: false
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from nodejs-nodeapp-token-4wxvd (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  nodejs-nodeapp-token-4wxvd:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  nodejs-nodeapp-token-4wxvd
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>

它无法创建负载均衡器。如何手动设置LoadBalancer?

我使用Kubeadm和3个液滴在Digitalocean上创建了一个集群。由于这不是Digital ocean的托管Kubernetes集群,因此如何手动设置LoadBalancer?我尝试添加一个...

kubernetes digital-ocean kubernetes-helm
1个回答
0
投票

您需要安装Digital Ocean cloud controller manager,它是DigitalOcean的Kubernetes云控制器管理器实现。了解有关云控制器管理器here的更多信息。

© www.soinside.com 2019 - 2024. All rights reserved.