<p>I am trying to run my app using Kubernetes 
I have created a deployment from file called <code>deployment.yaml</code>
a service from the file called <code>service.yaml</code></p>

<p>Here is the content of <code>deployment.yaml</code>:</p>

<pre><code>apiVersion: v1
kind: Pod

    metadata:
      name: kubectl-test
    spec:
      containers:
        - name: kubectl-test
          image: gcr.io/[my-name]/node-app:0.0.1
          imagePullPolicy: Always
          ports:
            - containerPort: 8080
              hostPort: 8080
</code></pre>

<p>This is my <code>services.yaml</code></p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  #Service name
  name: kubectl-test-node-app
spec:
  selector:
    app: kubectl-test-189010
  ports:
    - protocol: TCP
      port: 8000
      targetPort: 8000
  type: LoadBalancer
</code></pre>

<p>When I run the command <code>kubectl get deployments</code>, I can see:</p>

<pre><code>NAME                  DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
kubernetes-bootcamp   1         1         1            1           16m
</code></pre>

<p>I can see my services by using <code>kubectl get services</code> and I can see:</p>

<pre><code>NAME                    TYPE           CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
kubectl-test-node-app   LoadBalancer   10.59.242.211   35.195.2.76   8000:31592/TCP   8m
kubernetes              ClusterIP      10.59.240.1     &lt;none&gt;        443/TCP          1d
</code></pre>

<p>When I try to visit the <code>EXTERNAL-IP:8000</code> I cant see my app there, I don't get any error, but I don't what is going wrong!</p>

<p><strong>EDIT</strong></p>

<p>I had to create deployment using:</p>

<pre><code>`kubectl run kubernetes-bootcamp --image=[image-name] --port=8080`
</code></pre>

<p>but not with this command </p>

<pre><code>`kubectl create -f deployment.yaml`
</code></pre>

<p>Is this related to the port: <code>8000:31592/TCP</code> ?</p>

<pre><code>kubectl get pods
kubectl-test                           1/1       Running   0          4h
kubernetes-bootcamp-1654181842-czwqg   1/1       Running   0          3h
</code></pre>

<p><strong>EDIT</strong></p>

<p>Running the command <code>kubectl describe services kubectl-test-node-app</code> returns:</p>

<pre><code>Name:                     kubectl-test-node-app
Namespace:                default
Labels:                   &lt;none&gt;
Annotations:              &lt;none&gt;
Selector:                 app=kubectl-test-189010
Type:                     LoadBalancer
IP:                       10.59.242.211
LoadBalancer Ingress:     35.195.2.76
Port:                     &lt;unset&gt;  8000/TCP
TargetPort:               8000/TCP
NodePort:                 &lt;unset&gt;  31592/TCP
Endpoints:                &lt;none&gt;
Session Affinity:         None
External Traffic Policy:  Cluster
Events:
  Type    Reason                Age   From                Message
  ----    ------                ----  ----                -------
  Normal  CreatingLoadBalancer  58m   service-controller  Creating load balancer
  Normal  CreatedLoadBalancer   57m   service-controller  Created load balancer
</code></pre>

<p>There are no endpoints defined. I guess this is the problem? How can I build the end points?</p>

<p>Your service specification target all pods with label "app=kubectl-test-189010" which your pod's specification doesn't have. </p>

<p>You need to update pod's metadata so it will match selector from service spec:</p>

<pre><code>    metadata:
       name: kubectl-test
       app: kubectl-test-189010
</code></pre>

<p>Also your service accept connections on port 8000 and then forward it to port 8000 (targetPort) on pod. But pod listen on port 8080 (containerPort). So one of them should be changed to match another - targetPort or containerPort.</p>

<p>You can read more about configuring services in Kubernetes here: <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/service/</a></p>
