<p>I'm using minikube on WSL2.
I deployed a simple flask app image and write a LoadBalancer to expose the service.</p>
<p>My question is, how do I modify service manifest to get the same result as expose?</p>
<p>Below are more details.</p>
<p>flask app deployment yaml.</p>
<p>rss.yaml</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: esg
spec:
  selector:
    matchLabels:
      app: rss
  replicas: 3
  template:
    metadata:
      labels:
        app: rss
    spec: 
      containers:
      - name: rss
        image: &quot;idioluck/00esg_rss:v01&quot;
        ports:
        - containerPort: 5000
</code></pre>
<p>service yaml (I tried nodeport and loadbalanacer either.)</p>
<p>rss_lb.yaml</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: esg-lb
spec:
  type: NodePort # LoadBalancer
  selector:
    app: rss  
  ports:
  - protocol: TCP
    port: 8080 
    targetPort: 5000
</code></pre>
<p>kubectl command is</p>
<pre><code>sjw@DESKTOP-MFPNHRC:~/esg_kube/kubesvc/rss$ kubectl apply -f rss.yaml
deployment.apps/esg created
sjw@DESKTOP-MFPNHRC:~/esg_kube/kubesvc/rss$ kubectl apply -f rss_lb.yaml
service/esg-lb created
sjw@DESKTOP-MFPNHRC:~/esg_kube/kubesvc/rss$ kubectl get pods
NAME                  READY   STATUS    RESTARTS   AGE
esg-757f659b4-4vndc   1/1     Running   0          13s
esg-757f659b4-4wd2w   1/1     Running   0          13s
esg-757f659b4-sf5q6   1/1     Running   0          13s
sjw@DESKTOP-MFPNHRC:~/esg_kube/kubesvc/rss$ kubectl get all
NAME                      READY   STATUS    RESTARTS   AGE
pod/esg-757f659b4-4vndc   1/1     Running   0          16s
pod/esg-757f659b4-4wd2w   1/1     Running   0          16s
pod/esg-757f659b4-sf5q6   1/1     Running   0          16s

NAME                 TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
service/esg-lb       LoadBalancer   10.101.221.26   &lt;pending&gt;     8080:31308/TCP   8s
service/kubernetes   ClusterIP      10.96.0.1       &lt;none&gt;        443/TCP          23h

NAME                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/esg   3/3     3            3           16s

NAME                            DESIRED   CURRENT   READY   AGE
replicaset.apps/esg-757f659b4   3         3         3       16s
</code></pre>
<p>Exteranl ip is pending.
so i delete loabdbalancer and use expose</p>
<pre><code>sjw@DESKTOP-MFPNHRC:~/esg_kube/kubesvc/rss$ kubectl expose deployment esg --type=LoadBalancer --port=8080
service/esg exposed
sjw@DESKTOP-MFPNHRC:~/esg_kube/kubesvc/rss$ kubectl get svc
NAME         TYPE           CLUSTER-IP     EXTERNAL-IP   PORT(S)          AGE
esg          LoadBalancer   10.99.208.98   127.0.0.1     8080:30929/TCP   46s
kubernetes   ClusterIP      10.96.0.1      &lt;none&gt;        443/TCP          23h
</code></pre>
<p>The service has been successfully exposed. And the service is a load balancer.</p>

<p>Your <code>LoadBalancer</code> type service is showing <code>Pending</code> as status because it is waiting for you to provision an external Load Balancer like AWS's Elastic Load Balancer or GCP's Load Balancer. LoadBalancer type services are usually used together with managed Kubernetes service e.g EKS, GKE etc.</p>
<p>On the other hand, you're able to expose your service because it already has <code>clusterIP</code> assigned to it.</p>
<p>If you want to use LB in Minikube, this official <a href="https://minikube.sigs.k8s.io/docs/handbook/accessing/#loadbalancer-access" rel="nofollow noreferrer">doc</a> may help you. Otherwise, you can use <code>NodePort</code> type service directly to expose your flask app.</p>
