<p>I have hosted Docker Images in a VM of Azure and I'm trying to access the Service outside VM. This is not working because of External IP is not generated for the Service.</p>

<p>After building the Docker image, I've applied yml file for creating Deployment and Service. My yml file looks as below:</p>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: planservice-deployment
  labels: 
    app: planservice-deploy
spec:
  selector:
    matchLabels:
      run: planservice-deploy
  replicas: 2
  template:
    metadata:
      labels:
        run: planservice-deploy
    spec:
      containers:
      - name: planservice-deploy
        image: planserviceimage
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 8086
---
apiVersion: v1
kind: Service
metadata:
  name: planservice-service
  labels: 
    app: planservice-deploy
spec:
  type: NodePort
  ports:
  - port: 80
    protocol: TCP
    targetPort: 8086
  selector:
    run: planservice-deploy
---
</code></pre>

<p>After I ran the following command to look running services:</p>

<pre><code>kubectl get pods --output=wide
</code></pre>

<p>This command returned all the running services and it's external IP information. But, when I saw the list, all the services are generated with blank external IPs. </p>

<p>How to set external IP for all the services, so that I can access my web services outside VM?</p>

55SK55
<p>you need to change <code>type</code> to <code>LoadBalancer</code>:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: planservice-service
  labels: 
    app: planservice-deploy
spec:
  type: LoadBalancer
  ports:
  - port: 80
    protocol: TCP
    targetPort: 8086
  selector:
    run: planservice-deploy
</code></pre>

<p><a href="https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer</a></p>
