Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 7: Services, port definitions do not match #47

Open
martingregoire opened this issue Jun 25, 2024 · 0 comments
Open

Chapter 7: Services, port definitions do not match #47

martingregoire opened this issue Jun 25, 2024 · 0 comments

Comments

@martingregoire
Copy link

Hi @nigelpoulton, while enjoying your K8s book, I noticed that a port definition in one of the examples does not match another file.

In the Service definition it says the target port is 9090:

targetPort: 9090

The Pods that this Service refers to are defined like this, with port 8080:

- containerPort: 8080

And sure enough, following this chapter and applying both files to K8s will show this error message (please note that I'm using the "KinD" setup, and because of my local Docker setup have to explicitly create a port forwarding):

$ kubectl port-forward service/svc-test 30001:8080
Forwarding from 127.0.0.1:30001 -> 9090
Forwarding from [::1]:30001 -> 9090
Handling connection for 30001
E0625 13:52:21.097232   41027 portforward.go:409] an error occurred forwarding 30001 -> 9090: error forwarding port 9090 to pod ..., uid : failed to execute portforward in network namespace "/var/run/netns/cni-...": failed to connect to localhost:9090 inside namespace "...", IPv4: dial tcp4 127.0.0.1:9090: connect: connection refused IPv6 dial tcp6 [::1]:9090: connect: connection refused

After updating the services/svc.yml file and changing the targetPortfrom 9090 to 8080, it works as expected.

For reference, in the printed book (2023 edition) the services/svc.yml file is shown, and there it also says targetPort: 8080.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant