Welcome to the Linux Foundation Forum!

Exercise 8.2 - Not able to do a curl using NodePort

ganeshahv
ganeshahv Posts: 15
edited August 2020 in LFS258 Class Forum

Hi,

[email protected]:~$ kubectl -n accounting describe services
Name:                     service-lab
Namespace:                accounting
Labels:                   system=secondary
Annotations:              <none>
Selector:                 system=secondary
Type:                     NodePort
IP:                       10.104.115.79
Port:                     <unset>  8080/TCP
TargetPort:               8080/TCP
NodePort:                 <unset>  31742/TCP
Endpoints:                192.168.89.54:8080,192.168.89.55:8080
Session Affinity:         None
External Traffic Policy:  Cluster
Events:                   <none>
[email protected]:~$ kubectl cluster-info
Kubernetes master is running at https://k8smaster:6443
KubeDNS is running at https://k8smaster:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
[email protected]:~$ curl https://k8smaster:31742
curl: (7) Failed to connect to k8smaster port 31742: Connection refused
[email protected]:~$ curl http://k8smaster:31742
curl: (7) Failed to connect to k8smaster port 31742: Connection refused

Also, I see in the description that "In a previous exercise we deployed a Load Balancerwhich deployed a ClusterIP and NodePort automatically."
IIRC, In Exercise 8.1 we do not deploy a LB Service. Please correct me if I am wrong.

Comments

  • serewicz
    serewicz Posts: 942

    Hello,

    It would look like the service is as expected, so next I would want to make sure the pod is properly running. Just to double-check you have no firewalls in place, and the nodes have 2cpu/7.5G? This is what I would try next:

    Check the spelling of the labels, it is case sensitive. Are both the service and the pod using "system=secondary"? The service must match what you set Ex8.1, step 1.

    kubectl get pods -o wide --all-namespaces
    kubectl -n accounting get svc
    kubectl describe node | grep -i taint

    As far as the LB setup, the description says "a previous lab", which may be prior to 8.1. For example Ex3.5, step 5.

    Regards,

  • chrispokorni
    chrispokorni Posts: 1,131

    Hi @ganeshahv,

    As long as the Service's TargetPort is set to 8080, it will not be able to forward traffic to the port 80 of the nginx container.

    I suggest reconfiguring the service and/or the yaml manifest of the nginx-one Deployment - which should be performed in step 13 of exercise 8.1.

    Regards,
    -Chris

  • Hi @chrispokorni , thanks for your suggestion. I reconfigured the services and it works fine now.

    `Name: service-lab
    Namespace: accounting
    Labels: system=secondary
    Annotations:
    Selector: system=secondary
    Type: NodePort
    IP: 10.99.38.30
    Port: 80/TCP
    TargetPort: 80/TCP
    NodePort: 32204/TCP
    Endpoints: 192.168.89.62:80,192.168.89.63:80
    Session Affinity: None
    External Traffic Policy: Cluster
    Events:
    [email protected]:~$ curl http://k8smaster:32204
    <!DOCTYPE html>


    Welcome to nginx!

    body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; }


    Welcome to nginx!

    If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

    For online documentation and support please refer to nginx.org.
    Commercial support is available at nginx.com.

    Thank you for using nginx.



    [email protected]:~$`

Categories

Upcoming Training