Navratan Lal Gupta:
You can not curl into cluster pods from outside the cluster whose service type is ClusterIP. You need to have service with node type as NodePort and curl into it with nodeIP and port.
Deepak Mourya:
@Navratan Lal Gupta Hi, I am using this from inside the cluster and with the same node.
Navratan Lal Gupta:
Can you send yaml deployed
Navratan Lal Gupta:
k get svc nginx -o yaml
Deepak Mourya:
copy whole yaml is not possible, may be describe svc and pod details are fine ?
Deepak Mourya:
spec:
clusterIP: 10.102.94.17
clusterIPs:
- 10.102.94.17
ports: - port: 8080
protocol: TCP
targetPort: 8080
selector:
run: nginx
sessionAffinity: None
type: ClusterIP
status:
loadBalancer: {}
Navratan Lal Gupta:
svc looks good. Are you sure if nginx is running fine in pod
Deepak Mourya:
yes it is running
root@controlplane:~# k get pods --show-labels
NAME READY STATUS RESTARTS AGE LABELS
nginx 1/1 Running 0 36m run=nginx
damoder reddy:
can you try curl -Il controlplane:8080 where i is Caps lock I and lower case l
Deepak Mourya:
@damoder reddy Yes, i can curl the same ^^
Deepak Mourya:
https://beta.kodekloud.com/topic/practice-test-imperative-commands-3/ i am using this lab
Vinay:
Hi , Deepak can you check the container port where nginix is running on
Deepak Mourya:
hi @Vinay IPs:
IP: 10.244.0.4
Containers:
nginx:
Container ID: docker://e00b52ae9d97772202d96a3ef5845938504829a7a0d7071536b2045918daad76
Image: nginx
Image ID: docker-pullable://nginx@sha256:6d75c99af15565a301e48297fa2d121e15d80ad526f8369c526324f0f7ccb750
Port: <none>
Host Port: <none>
State: Running
Started: Tue, 22 Jun 2021 14:03:16 +0000
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-9qbwn (ro)
Vinay:
can you edit the Pod port to 8080 and try
Port: 8080
Deepak Mourya:
hmm ok
Deepak Mourya:
How to set port in the pod ?
Deepak Mourya:
It seems lab session out now
Hinodeya:
Its’normally because this ip adress 10.244.0.4:8080 is the ip of the pod
Hinodeya:
You have to create another type of rule --type=NodePort in this case
Hinodeya:
kubectl expose po “name of pod” --type=NodePort --port 8080 target-port 8080 --name svcpodexpose --dry-run -o yaml >svcpo.yaml