Skip to content

feat: add uc context create - #327

Open
miekg wants to merge 9 commits into
psviderski:mainfrom
miekg:miek/26/apr22wo/14
Open

feat: add uc context create#327
miekg wants to merge 9 commits into
psviderski:mainfrom
miekg:miek/26/apr22wo/14

Conversation

@miekg

@miekg miekg commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

This gets the context from the remote machine and add it to the correct place in your uncloud config.

@miekg
miekg marked this pull request as draft April 22, 2026 14:24
@miekg

miekg commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author
% ./uc machine context test@uncloud1.vm.science.ru.nl -c bla   
uncloud:
  connections:
    - ssh: test@131.174.88.77
      machine_id: c22073beee04bf9b1861e53c21023d2d
    - ssh: test@131.174.88.78
      machine_id: 212fd73438b53ebfb7dd531da4c6ed41

the context is uncloud because the machine(s) ID already are in that section in my uncloud config

@miekg
miekg marked this pull request as ready for review April 22, 2026 16:03
@miekg

miekg commented Apr 22, 2026

Copy link
Copy Markdown
Contributor Author

where should this be tested? test/e2e/machine_test.go ?

@miekg miekg closed this May 6, 2026
@miekg
miekg deleted the miek/26/apr22wo/14 branch May 6, 2026 09:09
@miekg
miekg restored the miek/26/apr22wo/14 branch May 7, 2026 14:06
@miekg miekg reopened this May 7, 2026
@miekg

miekg commented May 7, 2026

Copy link
Copy Markdown
Contributor Author

weird

@miekg

miekg commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

a user just came in asking fo such a feature. If you have specifics on why this doesn't work in some usecases let me know so I can brush up the PR

@psviderski

Copy link
Copy Markdown
Owner

From the Discord discussion, I think something like the following feels like a more generic approach:

uc context create mycluster --connect user@host1 [--connect user@host2]

this generates and adds the following to ~/.config/uncloud/config.yaml:

contexts:
  mycluster:
    connections:
      - ssh: user@host1
        machine_id: .... # inspected for each user@hostX

and optionally sets the current_context.

PublicIP doesn't work in the cases when machines don't have public IPs, which is a common use cases for office/home clusters behind NAT or hybrid clusters when only a subset of machines are public. Public IP in those cases is the IP of the egress router which won't work as the connection to the machine.

That's why I'm suggesting to require a user to explicitly specify what connections to use and their hosts/IPs.

We don't need to list all the machines in the connections. So I'd say listing only 1 machine with the correct user@host is more preferable than all machines with potentially incorrect addresses.

@miekg

miekg commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

We don't need to list all the machines in the connections.

technically correct, but this is also something that serves as documentation, which machines do we actually have in our cluster. (Yes uc machine ls also does this - but having a complete listing in the config would help).

Point taken on the public ips, those machines prolly need to be filtered out? (I.e. a different route then your suggestion)

miekg added 8 commits July 28, 2026 13:47
This gets the context from the remote machine and add it to the correct
place in your uncloud config.

Signed-off-by: Miek Gieben <miek@miek.nl>
Signed-off-by: Miek Gieben <miek@miek.nl>
Signed-off-by: Miek Gieben <miek@miek.nl>
Signed-off-by: Miek Gieben <miek@miek.nl>
Signed-off-by: Miek Gieben <miek@miek.nl>
Add context as alias and make main cmd ctx

Signed-off-by: Miek Gieben <miek@miek.nl>
Signed-off-by: Miek Gieben <miek@miek.nl>
Signed-off-by: Miek Gieben <miek@miek.nl>
@miekg
miekg force-pushed the miek/26/apr22wo/14 branch from 2094851 to 5451bc0 Compare July 28, 2026 12:28
Signed-off-by: Miek Gieben <miek@miek.nl>
@miekg miekg changed the title feat: add uc machine context feat: add uc context create Jul 28, 2026
@miekg

miekg commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

this now is: us context create and only add machines that have a public IP address

PTAL

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