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

Add static hosts to TSL SANs #7379

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions pkg/rancher-desktop/backend/wsl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,8 @@ export default class WSLBackend extends events.EventEmitter implements VMBackend
* contents from the data distribution.
*/
protected async writeHostsFile(config: BackendSettings) {
const rdNetworking = config.experimental.virtualMachine.networkingTunnel;
const virtualNetworkHostAddr = '192.168.127.254';
const hostIPAddr = rdNetworking ? virtualNetworkHostAddr : wslHostIPv4Address();
const virtualNetworkStaticAddr = '192.168.127.254';
const virtualNetworkGatewayAddr = '192.168.127.1';

await this.progressTracker.action('Updating /etc/hosts', 50, async() => {
const contents = await fs.promises.readFile(`\\\\wsl$\\${ DATA_INSTANCE_NAME }\\etc\\hosts`, 'utf-8');
Expand All @@ -492,7 +491,8 @@ export default class WSLBackend extends events.EventEmitter implements VMBackend
const hosts = ['host.rancher-desktop.internal', 'host.docker.internal'];
const extra = [
'# BEGIN Rancher Desktop configuration.',
`${ hostIPAddr } ${ hosts.join(' ') }`,
`${ virtualNetworkStaticAddr } ${ hosts.join(' ') }`,
`${ virtualNetworkGatewayAddr } gateway.rancher-desktop.internal`,
'# END Rancher Desktop configuration.',
].map(l => `${ l }\n`).join('');

Expand Down Expand Up @@ -1448,6 +1448,11 @@ export default class WSLBackend extends events.EventEmitter implements VMBackend
// Make sure the apiserver can be accessed from WSL through the internal gateway
k3sConf.ADDITIONAL_ARGS += ' --tls-san gateway.rancher-desktop.internal';
Copy link
Contributor

Choose a reason for hiding this comment

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

That's not actually reachable right?

Copy link
Member

Choose a reason for hiding this comment

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

That's not actually reachable right?

This was not answered. If the address is not reachable, why would we add it to the cert?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was added here: #6167, so it looks like it is needed because of this: #6156.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we using gateway.rancher-desktop.internal for WSL kubeconfig then? We're using a symlink again now, so it should be back to 127.0.0.1?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, it is back to localhost now.

Copy link
Member

Choose a reason for hiding this comment

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

I'm still confused: Is gateway.rancher-desktop.internal used for anything? Should it still be on the cert?

Because the comment sounds wrong now:

// Make sure the apiserver can be accessed from WSL through the internal gateway


// Generate certificates for the statically defined host entries.
// This is useful for users connecting to the host via HTTPS.
k3sConf.ADDITIONAL_ARGS += ' --tls-san host.rancher-desktop.internal';
k3sConf.ADDITIONAL_ARGS += ' --tls-san host.docker.internal';

// Add the `veth-rd1` IP address from inside the namespace
k3sConf.ADDITIONAL_ARGS += ' --tls-san 192.168.1.2';

Expand Down
Loading