Configure Kubernetes with docker container on Ubuntu VM I am using the YAML file to deploy the container on Kubernetes with some replication factor on a hosted machine.
YAML File
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

Steps:

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


deployment.apps/mojo-deployment created
service/mojo-services created
ingress.networking.k8s.io/mojo-ingress created


kubectl get service returns


kubectl get pod returns


kubectl get deployment returns



Questions?

Do I need to build the container before deploying YAML file? I tried it but still kubernetes not running.

Why all pods are showing Pending status.

Deployment is also showing pending status.

Though I am trying to access the Ingress with :80 and cannot access it.
You have to push your image in a registry in order to get the deployment working. Kubernetes does not deal with images (i.e. building, pushing...).

Try kubectl describe deployment mojo-deployment, you'll get more informations about why it's pending (surely because it does not know how to get your Docker image).