mxschmitt / ui-driver-hetzner

Rancher UI driver for the Hetzner Cloud docker driver.
https://mxschmitt.github.io/ui-driver-hetzner
Apache License 2.0
254 stars 50 forks source link

Support the creation of servers with only private networks #129

Open eedugon opened 2 years ago

eedugon commented 2 years ago

Recently Hetzner has added the support of servers belonging only to private networks, without any public interface, thank to the following options:

image

This is a great achievement for security and architectural purposes, and the driver https://github.com/JonasProgrammer/docker-machine-driver-hetzner has implemented the support for this in version 3.8.0 (see this issue for more information).

It would be great if we supported this from the UI driver too.

In order to implement this we should offer a new option called disable-public (includes both ipv4 & ipv6), only applicable when at least one private network is selected. This option would use the new flag implemented in the driver, called --hetzner-disable-public.

The usage of --hetzner-disable-public should also imply the usage of --hetzner-use-private-network and the association of at least one private network to the server.

Another option would be to include 2 extra checkboxes to disablePublic4 and disablePublic6 independently (associated with machine driver parameters --hetzner-disable-public-4 and --hetzner-disable-public-6.

eedugon commented 2 years ago

Due to https://github.com/mxschmitt/ui-driver-hetzner/issues/130 I haven't been able to do the change directly in the code (because the builds I create from the main branch don't work with Rancher 2.6).

Taking the official component.js I was able to make it working in the described way:

image

I added in component.js the disablePublic boolean in the hetznerConfig object:

    bootstrap: function bootstrap() {
      var config = get(this, 'globalStore').createRecord({
        type: 'hetznerConfig',
        additionalKey: [],
        serverType: 'cx21',
        serverLocation: 'nbg1',
        imageId: "168855",
        userData: '',
        networks: [],
        firewalls: [],
        usePrivateNetwork: false,
        disablePublic: false,
        serverLabel: [''],
        placementGroup: ''
      });
      set(this, 'model.hetznerConfig', config);
    },

And then I also changed the base64 layout to include a section for the new checkbox:

      <div class="col-md-2">
        <div class="checkbox">
          <label class="acc-label">{{input type="checkbox" checked=model.hetznerConfig.usePrivateNetwork}}
            EEDUGON: Use private network (first private network which is attached will be used for communication)
          </label>
        </div>
      </div>
      <div class="col-md-2">
        <div class="checkbox">
          <label class="acc-label">{{input type="checkbox" checked=model.hetznerConfig.disablePublic}}
            EEDUGON: Disable public IPv4 and IPv6 addresses (this implies "use private network" for communication).
          </label>
        </div>
      </div>

If anyone likes the change I have no issues raising a PR, but the current github code doesn't generate a valid component.js in my case (and it looks very different than the published one as mentioned here