Issue while deploying vote service in kubernetes hands on lab

I am trying to execute hands on lab for deploying voting app and I tried to create vote-service and vote-deployment using these two yaml files and when I hit on check it still shows vote-service needs to be created.

Could you please help??

controlplane ~ ➜ cat vote-service.yaml
apiVersion: v1
kind: Service
metadata:
name: vote-service
labels:
name: vote-service
app: demo-voting-app
spec:
ports:
- port: 5000
targetPort: 80
nodePort: 31000
type: NodePort
selector:
name: vote-service
app: demo-voting-app

controlplane ~ ➜ cat vote-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: vote-deployment
labels:
name: vote-deployment
app: demo-voting-app
spec:
replicas: 1
selector:
matchLabels:
name: vote-app-pod
app: demo-voting-app
template:
metadata:
name: vote-app-pod
labels:
name: vote-app-pod
app: demo-voting-app
spec:
containers:
- name: vote-app
image: kodekloud/examplevotingapp_vote:before
ports:
- containerPort: 80

issue:
image

First of all, to check your YAML, we need to make sure that it’s correct; it’s very hard to do that if you don’t use the </> button to create a

code block so 
    we can see where
    you indented your code.

The other thing, since the grader gave you no points – how did you apply your code? You needed to do something like

kubectl apply -f vote-deployment.yaml
kubectl apply -f vote-service.yaml

Thanks for responding rob, below is the formatted yaml file and screenshot of the same,
I have used kubectl create -f vote-service.yaml for creating service and I’m still facing the issue

apiVersion: v1
kind: Service
metadata:
  name: vote-service
  labels:
    name: vote-service
    app: demo-voting-app
spec:
  ports:
  - port: 5000
    targetPort: 80
    nodePort: 31000
  type: NodePort
  selector:
    name: vote-service
    app: demo-voting-app```
![image|613x500](upload://iCBw98eAILtuAMa1NTjxWFM2ffp.png)

Did you run kubectl apply -f or kubectl create -f on the files?

Rob, I’m using kubectl create -f

The deployment creates pods with the labels above. Your service is selecting for pods with the labels:

   name: vote-service
   app: demo-voting-app

This does not match, so this will not work.

Also: I assume this is a lab. A link to that lab would be very helpful, so I can see what’s being requested. Not knowing what you’re supposed to do for the lab, I therefore don’t know if you’re doing it right :slight_smile:

Rob, i have corrected the labels issue, unable to figure it out. below is the link for the lab and I’m working on the last lab deploying voting app and struck at the voting service issue

Link for course: kubernetes crash course

That’s a weird URL that redirects from youtube.com to Lir Knows Where. Can you give me a less tricksy URL? Or give me a statement of the actual problem. Again: I don’t know what you’re asked to do, so I don’t know what if you’re doing it right.

can you try this url and go to labs and navigate to the last lab

OK, the diagram makes this clear: everything is in the “vote” namespace. Your objects are in the “default” namespace, where the grader is not looking for objects.

Thanks rob, I did not notice that and issue resolved.