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

Use kr8s in networking functions #764

Closed
wants to merge 3 commits into from

Conversation

Matt711
Copy link
Member

@Matt711 Matt711 commented Jul 11, 2023

Seperate operator networking functions and use kr8s api in them.

async def port_forward_service(service, remote_port, local_port=None):
async with PortForward(service, remote_port, local_port) as port:
print(f"Forwarding to port {port}")
return port
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be port.local_port

Comment on lines 93 to 95
async with PortForward(service, remote_port, local_port) as port:
print(f"Forwarding to port {port}")
return port
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you do async with the port forward will close when the function returns.

Suggested change
async with PortForward(service, remote_port, local_port) as port:
print(f"Forwarding to port {port}")
return port
pf = service.portforward(remote_port, local_port)
port = await pf.start()
print(f"Forwarding to port {port}")
return port

We might also want to return pf and hold a reference to it somewhere but I'm not sure.

@jacobtomlinson
Copy link
Member

This was superseded

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

Successfully merging this pull request may close these issues.

2 participants