mirror of
https://github.com/portainer/portainer.git
synced 2025-08-08 15:25:22 +02:00
feat(networks): add ipv6 support (#3717)
* feat(portainer-core): add ipv6 support * feat(networks): add few changes * refacto(networks): write regex once * fix(networks): fix indentation * refacto(networks): use foreach instead map and pluralize ipvxconfig * refacto(networks): pluralize ipvxconfig * feat(networks): support ipv6 with ports * feat(networks): add an explicit error message * fix(networks): hide ipv6 configuration when creating macvlan
This commit is contained in:
parent
b2f36a3bbe
commit
3de533042d
16 changed files with 262 additions and 72 deletions
|
@ -16,10 +16,18 @@ angular.module('portainer.docker').controller('CreateNetworkController', [
|
|||
function ($q, $scope, $state, PluginService, Notifications, NetworkService, LabelHelper, Authentication, ResourceControlService, FormValidator, HttpRequestHelper) {
|
||||
$scope.formValues = {
|
||||
DriverOptions: [],
|
||||
Subnet: '',
|
||||
Gateway: '',
|
||||
IPRange: '',
|
||||
AuxAddress: '',
|
||||
IPV4: {
|
||||
Subnet: '',
|
||||
Gateway: '',
|
||||
IPRange: '',
|
||||
AuxAddress: ''
|
||||
},
|
||||
IPV6: {
|
||||
Subnet: '',
|
||||
Gateway: '',
|
||||
IPRange: '',
|
||||
AuxAddress: ''
|
||||
},
|
||||
Labels: [],
|
||||
AccessControlData: new AccessControlFormData(),
|
||||
NodeName: null,
|
||||
|
@ -38,6 +46,7 @@ angular.module('portainer.docker').controller('CreateNetworkController', [
|
|||
CheckDuplicate: true,
|
||||
Internal: false,
|
||||
Attachable: false,
|
||||
EnableIPv6: false,
|
||||
// Force IPAM Driver to 'default', should not be required.
|
||||
// See: https://github.com/docker/docker/issues/25735
|
||||
IPAM: {
|
||||
|
@ -70,20 +79,35 @@ angular.module('portainer.docker').controller('CreateNetworkController', [
|
|||
};
|
||||
|
||||
function prepareIPAMConfiguration(config) {
|
||||
if ($scope.formValues.Subnet) {
|
||||
var ipamConfig = {};
|
||||
ipamConfig.Subnet = $scope.formValues.Subnet;
|
||||
if ($scope.formValues.Gateway) {
|
||||
ipamConfig.Gateway = $scope.formValues.Gateway;
|
||||
if ($scope.formValues.IPV4.Subnet) {
|
||||
let ipamConfig = {};
|
||||
ipamConfig.Subnet = $scope.formValues.IPV4.Subnet;
|
||||
if ($scope.formValues.IPV4.Gateway) {
|
||||
ipamConfig.Gateway = $scope.formValues.IPV4.Gateway;
|
||||
}
|
||||
if ($scope.formValues.IPRange) {
|
||||
ipamConfig.IPRange = $scope.formValues.IPRange;
|
||||
if ($scope.formValues.IPV4.IPRange) {
|
||||
ipamConfig.IPRange = $scope.formValues.IPV4.IPRange;
|
||||
}
|
||||
if ($scope.formValues.AuxAddress) {
|
||||
ipamConfig.AuxAddress = $scope.formValues.AuxAddress;
|
||||
if ($scope.formValues.IPV4.AuxAddress) {
|
||||
ipamConfig.AuxAddress = $scope.formValues.IPV4.AuxAddress;
|
||||
}
|
||||
config.IPAM.Config.push(ipamConfig);
|
||||
}
|
||||
if ($scope.formValues.IPV6.Subnet) {
|
||||
let ipamConfig = {};
|
||||
ipamConfig.Subnet = $scope.formValues.IPV6.Subnet;
|
||||
if ($scope.formValues.IPV6.Gateway) {
|
||||
ipamConfig.Gateway = $scope.formValues.IPV6.Gateway;
|
||||
}
|
||||
if ($scope.formValues.IPV6.IPRange) {
|
||||
ipamConfig.IPRange = $scope.formValues.IPV6.IPRange;
|
||||
}
|
||||
if ($scope.formValues.IPV6.AuxAddress) {
|
||||
ipamConfig.AuxAddress = $scope.formValues.IPV6.AuxAddress;
|
||||
}
|
||||
config.EnableIPv6 = true;
|
||||
config.IPAM.Config.push(ipamConfig);
|
||||
}
|
||||
}
|
||||
|
||||
function prepareDriverOptions(config) {
|
||||
|
|
|
@ -68,29 +68,58 @@
|
|||
<!-- !macvlan-management -->
|
||||
<div ng-hide="config.Driver === 'macvlan' && formValues.Macvlan.Scope === 'swarm'">
|
||||
<div class="col-sm-12 form-section-title">
|
||||
Network configuration
|
||||
IPV4 Network configuration
|
||||
</div>
|
||||
<!-- subnet-gateway-inputs -->
|
||||
<div class="form-group">
|
||||
<label for="network_subnet" class="col-sm-2 col-lg-1 control-label text-left">Subnet</label>
|
||||
<label for="ipv4_network_subnet" class="col-sm-2 col-lg-1 control-label text-left">Subnet</label>
|
||||
<div class="col-sm-4 col-lg-5">
|
||||
<input type="text" class="form-control" ng-model="formValues.Subnet" id="network_subnet" placeholder="e.g. 172.20.0.0/16" />
|
||||
<input type="text" class="form-control" ng-model="formValues.IPV4.Subnet" id="ipv4_network_subnet" placeholder="e.g. 172.20.0.0/16" />
|
||||
</div>
|
||||
<label for="network_gateway" class="col-sm-2 col-lg-1 control-label text-left">Gateway</label>
|
||||
<label for="ipv4_network_gateway" class="col-sm-2 col-lg-1 control-label text-left">Gateway</label>
|
||||
<div class="col-sm-4 col-lg-5">
|
||||
<input type="text" class="form-control" ng-model="formValues.Gateway" id="network_gateway" placeholder="e.g. 172.20.10.11" />
|
||||
<input type="text" class="form-control" ng-model="formValues.IPV4.Gateway" id="ipv4_network_gateway" placeholder="e.g. 172.20.10.11" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- !subnet-gateway-inputs -->
|
||||
<!-- iprange-auxaddr-inputs -->
|
||||
<div class="form-group">
|
||||
<label for="network_iprange" class="col-sm-2 col-lg-1 control-label text-left">IP range</label>
|
||||
<label for="ipv4_network_iprange" class="col-sm-2 col-lg-1 control-label text-left">IP range</label>
|
||||
<div class="col-sm-4 col-lg-5">
|
||||
<input type="text" class="form-control" ng-model="formValues.IPRange" id="network_iprange" placeholder="e.g. 172.20.10.128/25" />
|
||||
<input type="text" class="form-control" ng-model="formValues.IPV4.IPRange" id="ipv4_network_iprange" placeholder="e.g. 172.20.10.128/25" />
|
||||
</div>
|
||||
<label for="network_auxaddr" class="col-sm-2 col-lg-1 control-label text-left">Exclude IPs</label>
|
||||
<label for="ipv4_network_auxaddr" class="col-sm-2 col-lg-1 control-label text-left">Exclude IPs</label>
|
||||
<div class="col-sm-4 col-lg-5">
|
||||
<input type="text" class="form-control" ng-model="formValues.AuxAddress" id="network_auxaddr" placeholder="e.g. my-router=172.20.10.129" />
|
||||
<input type="text" class="form-control" ng-model="formValues.IPV4.AuxAddress" id="ipv4_network_auxaddr" placeholder="e.g. my-router=172.20.10.129" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- !iprange-auxaddr-inputs -->
|
||||
</div>
|
||||
<div ng-show="config.Driver === 'bridge' || (config.Driver === 'macvlan' && formValues.Macvlan.Scope !== 'swarm')">
|
||||
<div class="col-sm-12 form-section-title">
|
||||
IPV6 Network configuration
|
||||
</div>
|
||||
<!-- subnet-gateway-inputs -->
|
||||
<div class="form-group">
|
||||
<label for="ipv6_network_subnet" class="col-sm-2 col-lg-1 control-label text-left">Subnet</label>
|
||||
<div class="col-sm-4 col-lg-5">
|
||||
<input type="text" class="form-control" ng-model="formValues.IPV6.Subnet" id="ipv6_network_subnet" placeholder="e.g. 2001:db8::/48" />
|
||||
</div>
|
||||
<label for="ipv6_network_gateway" class="col-sm-2 col-lg-1 control-label text-left">Gateway</label>
|
||||
<div class="col-sm-4 col-lg-5">
|
||||
<input type="text" class="form-control" ng-model="formValues.IPV6.Gateway" id="ipv6_network_gateway" placeholder="e.g. 2001:db8::1" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- !subnet-gateway-inputs -->
|
||||
<!-- iprange-auxaddr-inputs -->
|
||||
<div class="form-group">
|
||||
<label for="ipv6_network_iprange" class="col-sm-2 col-lg-1 control-label text-left">IP range</label>
|
||||
<div class="col-sm-4 col-lg-5">
|
||||
<input type="text" class="form-control" ng-model="formValues.IPV6.IPRange" id="ipv6_network_iprange" placeholder="e.g. 2001:db8::/64" />
|
||||
</div>
|
||||
<label for="ipv6_network_auxaddr" class="col-sm-2 col-lg-1 control-label text-left">Exclude IPs</label>
|
||||
<div class="col-sm-4 col-lg-5">
|
||||
<input type="text" class="form-control" ng-model="formValues.IPV6.AuxAddress" id="ipv6_network_auxaddr" placeholder="e.g. my-router=2001:db8::1" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- !iprange-auxaddr-inputs -->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue