<p>I am using the <code>YAML</code> file to deploy the container on <code>Kubernetes</code> with some replication factor on a hosted machine. </p>

<h1>YAML File</h1>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mojo-deployment
  labels:
    app: mojo
spec:
  selector:
    matchLabels:
      app: mojo
  replicas: 3
  template:
    metadata:
      labels:
        app: mojo
    spec:
      containers:
        - name: mojo
          image: mojo:1.0.1
          ports:
            - containerPort: 9000

---
#Services Info
apiVersion: v1
kind: Service
metadata:
  name: mojo-services
spec:
  selector:
    app: mojo
  ports:
    - protocol: TCP
      port: 80
      targetPort: 9376

---

#Ingress Configuration
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: mojo-ingress
  annotations:
    kubernetes.io/ingress.class: mojo
spec:
  backend:
    serviceName: mojo-services
    servicePort: 80
</code></pre>

<p>Steps:</p>

<ol>
<li>Build <code>Docker</code> image using `docker build -t mojo:1.0 .</li>
<li><code>docker image ls</code> show me an image id.</li>
<li>Skipping <code>docker build</code> command to deploy image on container. Do I need to do it? or <code>kubectl</code> service will take care of it. </li>
<li>Run <code>kubectl apply -f Prod.yaml</code>. It shows </li>
</ol>

<blockquote>
  <p>deployment.apps/mojo-deployment created</p>
  
  <p>service/mojo-services created</p>
  
  <p>ingress.networking.k8s.io/mojo-ingress created</p>
</blockquote>

<ol start="5">
<li><p><code>kubectl get service</code> returns</p>

<p><a href="https://i.stack.imgur.com/2mjol.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2mjol.png" alt=""></a></p></li>
<li><code>kubectl get pod</code> returns
<a href="https://i.stack.imgur.com/mQZY2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mQZY2.png" alt=""></a></li>
<li><code>kubectl get deployment</code> returns
<a href="https://i.stack.imgur.com/CulrZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CulrZ.png" alt="enter image description here"></a></li>
</ol>

<p>Questions?</p>

<ol>
<li><p>Do I need to build the container before deploying <code>YAML</code> file? I tried it but still <code>kubernetes</code> not running.</p></li>
<li><p>Why all pods are showing <code>Pending</code> status.</p></li>
<li><p>Deployment is also showing <code>pending</code> status.</p></li>
<li><p>Though I am trying to access the <code>Ingress</code> with :80 and cannot access it.  </p></li>
</ol>

<h1>Edit</h1>

<p>pod description </p>

<pre><code>Name:           mojo-deployment-6665bdc557-s57m7
Namespace:      default
Priority:       0
Node:           &lt;none&gt;
Labels:         app=mojo
            pod-template-hash=6665bdc557
Annotations:    &lt;none&gt;
Status:         Pending
IP:            
IPs:            &lt;none&gt;
Controlled By:  ReplicaSet/mojo-deployment-6665bdc557
Containers:
mojo:
 Image:        mojo:1.0
 Port:         9000/TCP
 Host Port:    0/TCP
 Environment:  &lt;none&gt;
 Mounts:
 /var/run/secrets/kubernetes.io/serviceaccount from default-token-tjx6p 
(ro)
Conditions:
Type           Status
PodScheduled   False
Volumes:
default-token-tjx6p:
 Type:        Secret (a volume populated by a Secret)
 SecretName:  default-token-tjx6p
 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:
  Type     Reason            Age                 From               
</code></pre>

<p>Message
    ----     ------            ----                ----               -------
    Warning  FailedScheduling  70s (x45 over 67m)  default-scheduler  0/1 
    nodes are available: 1 node(s) were unschedulable.</p>

<h1>Edit 2</h1>

<p>After removing the taint from the master node. 
 1. <code>kubectl get node</code> returns </p>

<p><a href="https://i.stack.imgur.com/CLLPJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CLLPJ.png" alt=""></a></p>

<ol start="2">
<li><code>kubectl get pod</code> returns </li>
</ol>

<p><a href="https://i.stack.imgur.com/3xf9l.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3xf9l.png" alt=""></a></p>

<ol start="3">
<li><code>kubectl describe node</code> : <a href="https://gist.github.com/amixpal/333bffd6ab91def749267f30d4ffb079" rel="nofollow noreferrer">https://gist.github.com/amixpal/333bffd6ab91def749267f30d4ffb079</a></li>
</ol>

Amit Pal
<p>If you have only one node (master) , then usually a Taint will be added to it which will make master node unschedulable. Remove taint from the master (and all other nodes, if there is more than one) using below.</p>

<p><code>kubectl taint nodes --all node-role.kubernetes.io/master-</code></p>

<p>Edit: Based on the node describe output, the CNI not ready.
Please make sure all CNI related Pods are running and healthy</p>
