k8c.io/api/v3@v3.0.0-20230904060738-b0a93889c0b6/pkg/apis/kubermatic/v1/ipam_pool.go (about) 1 /* 2 Copyright 2023 The Kubermatic Kubernetes Platform contributors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 // +kubebuilder:validation:Enum=prefix;range 24 25 // IPAMPoolAllocationType defines the type of allocation to be used. 26 type IPAMPoolAllocationType string 27 28 const ( 29 // IPAMPoolAllocationTypePrefix corresponds to prefix allocation type. 30 IPAMPoolAllocationTypePrefix IPAMPoolAllocationType = "prefix" 31 // IPAMPoolAllocationTypeRange corresponds to range allocation type. 32 IPAMPoolAllocationTypeRange IPAMPoolAllocationType = "range" 33 ) 34 35 // +genclient 36 // +kubebuilder:resource:scope=Cluster 37 // +kubebuilder:object:generate=true 38 // +kubebuilder:object:root=true 39 // +kubebuilder:printcolumn:JSONPath=".metadata.creationTimestamp",name="Age",type="date" 40 41 // IPAMPool is the object representing Multi-Cluster IP Address Management (IPAM) 42 // configuration for KKP user clusters. 43 type IPAMPool struct { 44 metav1.TypeMeta `json:",inline"` 45 metav1.ObjectMeta `json:"metadata,omitempty"` 46 47 Spec IPAMPoolSpec `json:"spec,omitempty"` 48 } 49 50 // IPAMPoolSpec specifies the Multi-Cluster IP Address Management (IPAM) 51 // configuration for KKP user clusters. 52 type IPAMPoolSpec struct { 53 // Datacenters contains a map of datacenters (DCs) for the allocation. 54 Datacenters map[string]IPAMPoolDatacenterSettings `json:"datacenters"` 55 } 56 57 // IPAMPoolDatacenterSettings contains IPAM Pool configuration for a datacenter. 58 type IPAMPoolDatacenterSettings struct { 59 // Type is the allocation type to be used. 60 Type IPAMPoolAllocationType `json:"type"` 61 62 // PoolCIDR is the pool CIDR to be used for the allocation. 63 PoolCIDR SubnetCIDR `json:"poolCidr"` 64 65 // +kubebuilder:validation:Minimum:=1 66 // +kubebuilder:validation:Maximum:=128 67 // AllocationPrefix is the prefix for the allocation. 68 // Used when "type=prefix". 69 AllocationPrefix int `json:"allocationPrefix,omitempty"` 70 71 // Optional: ExcludePrefixes is used to exclude particular subnets for the allocation. 72 // NOTE: must be the same length as allocationPrefix. 73 // Can be used when "type=prefix". 74 ExcludePrefixes []SubnetCIDR `json:"excludePrefixes,omitempty"` 75 76 // +kubebuilder:validation:Minimum:=1 77 // AllocationRange is the range for the allocation. 78 // Used when "type=range". 79 AllocationRange int `json:"allocationRange,omitempty"` 80 81 // Optional: ExcludeRanges is used to exclude particular IPs or IP ranges for the allocation. 82 // Examples: "192.168.1.100-192.168.1.110", "192.168.1.255". 83 // Can be used when "type=range". 84 ExcludeRanges []string `json:"excludeRanges,omitempty"` 85 } 86 87 // +kubebuilder:object:generate=true 88 // +kubebuilder:object:root=true 89 90 type IPAMPoolList struct { 91 metav1.TypeMeta `json:",inline"` 92 metav1.ListMeta `json:"metadata,omitempty"` 93 94 Items []IPAMPool `json:"items"` 95 }