It's been some days since I have started to learn Kubernetes. I am a noob in this and don't have any troubleshooting skills or any experience this is my first lab and however I am stuck in my first lab. Now the problem is this I have a VMware workstation where I have hosted my centos box in that box I have installed docker minikube kubectl KVM and then started the lab.
There are two object files which will be shown below ...
vi client-pod.yml
apiVersion: v1
kind: Pod
metadata:
name: client-pod
labels:
components: web
spec:
containers:
- name: client
image: stephengrider/multi-client
ports:
- containerPort: 3000
vi client-pod.service
apiVersion: v1
kind: Service
metadata:
name: client-node-port
spec:
type: NodePort
ports:
- port: 3050
targetPort: 3000
nodePort: 31515
selector:
component: web
after this I use the
minikube start --driver=kvm
Then after loading it starts
Then I use these commands
kubectl apply -f client-pod.yml
kubectl apply -f client-pod.service
So after this I use the
minikube ip
I get a IP:192.168.39.107
Then in browser of host when I use http://192.168.39.107:31515 It shows request not completed or something like that
Can anyone tell me whats going on
Your Pod
labels and Service
selector aren't same.
Either use components: web
or component: web
in both pod and service.
apiVersion: v1
kind: Pod
metadata:
name: client-pod
labels:
component: web # updated labels key
...
apiVersion: v1
kind: Service
metadata:
name: client-node-port
spec:
type: NodePort
ports:
- port: 3050
targetPort: 3000
nodePort: 31515
selector:
component: web # it should be same as pod labels
This should solve your issue.