<p>I created a cluster on digitalocean using Kubeadm and 3 droplets. Since this is not a managed Kubernetes cluster from Digital ocean, how do I manually setup a LoadBalancer ?</p>

<p>I've tried adding an external load balancer by adding the following lines to a deployment config file</p>

<pre><code>...
replicaCount: 1

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

<p>however, when I run the configuration and check for created svc</p>

<pre><code>kubectl get svc

NAME                              TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
kubernetes                        ClusterIP      10.96.0.1       &lt;none&gt;        443/TCP        13d
mongo-mongodb-replicaset          ClusterIP      None            &lt;none&gt;        27017/TCP      3h15m
mongo-mongodb-replicaset-client   ClusterIP      None            &lt;none&gt;        27017/TCP      3h15m
nodejs-nodeapp                    LoadBalancer   10.109.213.98   &lt;pending&gt;     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:              &lt;none&gt;
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:                   &lt;none&gt;

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:  &lt;none&gt;
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:        &lt;none&gt;
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:    &lt;set to the key 'MONGO_USERNAME' in secret 'nodejs-auth'&gt;          Optional: false
      MONGO_PASSWORD:    &lt;set to the key 'MONGO_PASSWORD' in secret 'nodejs-auth'&gt;          Optional: false
      MONGO_HOSTNAME:    &lt;set to the key 'MONGO_HOSTNAME' of config map 'nodejs-config'&gt;    Optional: false
      MONGO_PORT:        &lt;set to the key 'MONGO_PORT' of config map 'nodejs-config'&gt;        Optional: false
      MONGO_DB:          &lt;set to the key 'MONGO_DB' of config map 'nodejs-config'&gt;          Optional: false
      MONGO_REPLICASET:  &lt;set to the key 'MONGO_REPLICASET' of config map 'nodejs-config'&gt;  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:  &lt;none&gt;
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          &lt;none&gt;
</code></pre>

<p>It fails to create a loadbalancer. How do I manually setup the LoadBalancer ?</p>

Ismail
<p>I would not recommend configuring loadbalancers manually. You can automate this if you install <a href="https://github.com/digitalocean/digitalocean-cloud-controller-manager" rel="nofollow noreferrer">digital ocean cloud controller manager</a> which is the Kubernetes cloud controller manager implementation for DigitalOcean. Read more about cloud controller managers <a href="https://kubernetes.io/docs/tasks/administer-cluster/running-cloud-controller/" rel="nofollow noreferrer">here</a>.</p>

<p>DigitalOcean cloud controller manager runs service controller, which is responsible for watching services of type <code>LoadBalancer</code> and creating DO loadbalancers to satisfy its requirements. <a href="https://github.com/digitalocean/digitalocean-cloud-controller-manager/tree/master/docs/controllers/services/examples" rel="nofollow noreferrer">Here</a> are example of how it's used.</p>

<p><a href="https://github.com/digitalocean/digitalocean-cloud-controller-manager/blob/master/docs/example-manifests/cloud-controller-manager.yml" rel="nofollow noreferrer">Here</a> is a yaml file that you can use to deploy this on your Kubernetes cluster. This needs a digital ocean api token to be placed in <code>access-token:</code> section of the manifest.</p>
