1 /* 2 Copyright 2022 The Kubernetes Authors. 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 v1alpha1 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 // +genclient 24 // +genclient:nonNamespaced 25 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 26 // +k8s:prerelease-lifecycle-gen:introduced=1.27 27 28 // IPAddress represents a single IP of a single IP Family. The object is designed to be used by APIs 29 // that operate on IP addresses. The object is used by the Service core API for allocation of IP addresses. 30 // An IP address can be represented in different formats, to guarantee the uniqueness of the IP, 31 // the name of the object is the IP address in canonical format, four decimal digits separated 32 // by dots suppressing leading zeros for IPv4 and the representation defined by RFC 5952 for IPv6. 33 // Valid: 192.168.1.5 or 2001:db8::1 or 2001:db8:aaaa:bbbb:cccc:dddd:eeee:1 34 // Invalid: 10.01.2.3 or 2001:db8:0:0:0::1 35 type IPAddress struct { 36 metav1.TypeMeta `json:",inline"` 37 // Standard object's metadata. 38 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 39 // +optional 40 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 41 // spec is the desired state of the IPAddress. 42 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status 43 // +optional 44 Spec IPAddressSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 45 } 46 47 // IPAddressSpec describe the attributes in an IP Address. 48 type IPAddressSpec struct { 49 // ParentRef references the resource that an IPAddress is attached to. 50 // An IPAddress must reference a parent object. 51 // +required 52 ParentRef *ParentReference `json:"parentRef,omitempty" protobuf:"bytes,1,opt,name=parentRef"` 53 } 54 55 // ParentReference describes a reference to a parent object. 56 type ParentReference struct { 57 // Group is the group of the object being referenced. 58 // +optional 59 Group string `json:"group,omitempty" protobuf:"bytes,1,opt,name=group"` 60 // Resource is the resource of the object being referenced. 61 // +required 62 Resource string `json:"resource,omitempty" protobuf:"bytes,2,opt,name=resource"` 63 // Namespace is the namespace of the object being referenced. 64 // +optional 65 Namespace string `json:"namespace,omitempty" protobuf:"bytes,3,opt,name=namespace"` 66 // Name is the name of the object being referenced. 67 // +required 68 Name string `json:"name,omitempty" protobuf:"bytes,4,opt,name=name"` 69 } 70 71 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 72 // +k8s:prerelease-lifecycle-gen:introduced=1.27 73 74 // IPAddressList contains a list of IPAddress. 75 type IPAddressList struct { 76 metav1.TypeMeta `json:",inline"` 77 // Standard object's metadata. 78 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 79 // +optional 80 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 81 // items is the list of IPAddresses. 82 Items []IPAddress `json:"items" protobuf:"bytes,2,rep,name=items"` 83 } 84 85 // +genclient 86 // +genclient:nonNamespaced 87 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 88 // +k8s:prerelease-lifecycle-gen:introduced=1.27 89 90 // ServiceCIDR defines a range of IP addresses using CIDR format (e.g. 192.168.0.0/24 or 2001:db2::/64). 91 // This range is used to allocate ClusterIPs to Service objects. 92 type ServiceCIDR struct { 93 metav1.TypeMeta `json:",inline"` 94 // Standard object's metadata. 95 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 96 // +optional 97 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 98 // spec is the desired state of the ServiceCIDR. 99 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status 100 // +optional 101 Spec ServiceCIDRSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` 102 // status represents the current state of the ServiceCIDR. 103 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status 104 // +optional 105 Status ServiceCIDRStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` 106 } 107 108 // ServiceCIDRSpec define the CIDRs the user wants to use for allocating ClusterIPs for Services. 109 type ServiceCIDRSpec struct { 110 // CIDRs defines the IP blocks in CIDR notation (e.g. "192.168.0.0/24" or "2001:db8::/64") 111 // from which to assign service cluster IPs. Max of two CIDRs is allowed, one of each IP family. 112 // This field is immutable. 113 // +optional 114 // +listType=atomic 115 CIDRs []string `json:"cidrs,omitempty" protobuf:"bytes,1,opt,name=cidrs"` 116 } 117 118 const ( 119 // ServiceCIDRConditionReady represents status of a ServiceCIDR that is ready to be used by the 120 // apiserver to allocate ClusterIPs for Services. 121 ServiceCIDRConditionReady = "Ready" 122 // ServiceCIDRReasonTerminating represents a reason where a ServiceCIDR is not ready because it is 123 // being deleted. 124 ServiceCIDRReasonTerminating = "Terminating" 125 ) 126 127 // ServiceCIDRStatus describes the current state of the ServiceCIDR. 128 type ServiceCIDRStatus struct { 129 // conditions holds an array of metav1.Condition that describe the state of the ServiceCIDR. 130 // Current service state 131 // +optional 132 // +patchMergeKey=type 133 // +patchStrategy=merge 134 // +listType=map 135 // +listMapKey=type 136 Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"` 137 } 138 139 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 140 // +k8s:prerelease-lifecycle-gen:introduced=1.27 141 142 // ServiceCIDRList contains a list of ServiceCIDR objects. 143 type ServiceCIDRList struct { 144 metav1.TypeMeta `json:",inline"` 145 // Standard object's metadata. 146 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 147 // +optional 148 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 149 // items is the list of ServiceCIDRs. 150 Items []ServiceCIDR `json:"items" protobuf:"bytes,2,rep,name=items"` 151 } 152