1package v1 2 3import ( 4 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 5) 6 7// +genclient 8// +genclient:nonNamespaced 9// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 10 11// Network describes the cluster's desired network configuration. It is 12// consumed by the cluster-network-operator. 13// +k8s:openapi-gen=true 14type Network struct { 15 metav1.TypeMeta `json:",inline"` 16 metav1.ObjectMeta `json:"metadata,omitempty"` 17 18 Spec NetworkSpec `json:"spec,omitempty"` 19 Status NetworkStatus `json:"status,omitempty"` 20} 21 22// NetworkStatus is currently unused. Instead, status 23// is reported in the Network.config.openshift.io object. 24type NetworkStatus struct { 25} 26 27// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 28 29// NetworkList contains a list of Network configurations 30type NetworkList struct { 31 metav1.TypeMeta `json:",inline"` 32 metav1.ListMeta `json:"metadata,omitempty"` 33 Items []Network `json:"items"` 34} 35 36// NetworkSpec is the top-level network configuration object. 37type NetworkSpec struct { 38 // clusterNetwork is the IP address pool to use for pod IPs. 39 // Some network providers, e.g. OpenShift SDN, support multiple ClusterNetworks. 40 // Others only support one. This is equivalent to the cluster-cidr. 41 ClusterNetwork []ClusterNetworkEntry `json:"clusterNetwork"` 42 43 // serviceNetwork is the ip address pool to use for Service IPs 44 // Currently, all existing network providers only support a single value 45 // here, but this is an array to allow for growth. 46 ServiceNetwork []string `json:"serviceNetwork"` 47 48 // defaultNetwork is the "default" network that all pods will receive 49 DefaultNetwork DefaultNetworkDefinition `json:"defaultNetwork"` 50 51 // additionalNetworks is a list of extra networks to make available to pods 52 // when multiple networks are enabled. 53 AdditionalNetworks []AdditionalNetworkDefinition `json:"additionalNetworks,omitempty"` 54 55 // disableMultiNetwork specifies whether or not multiple pod network 56 // support should be disabled. If unset, this property defaults to 57 // 'false' and multiple network support is enabled. 58 DisableMultiNetwork *bool `json:"disableMultiNetwork,omitempty"` 59 60 // deployKubeProxy specifies whether or not a standalone kube-proxy should 61 // be deployed by the operator. Some network providers include kube-proxy 62 // or similar functionality. If unset, the plugin will attempt to select 63 // the correct value, which is false when OpenShift SDN and ovn-kubernetes are 64 // used and true otherwise. 65 // +optional 66 DeployKubeProxy *bool `json:"deployKubeProxy,omitempty"` 67 68 // kubeProxyConfig lets us configure desired proxy configuration. 69 // If not specified, sensible defaults will be chosen by OpenShift directly. 70 // Not consumed by all network providers - currently only openshift-sdn. 71 KubeProxyConfig *ProxyConfig `json:"kubeProxyConfig,omitempty"` 72} 73 74// ClusterNetworkEntry is a subnet from which to allocate PodIPs. A network of size 75// HostPrefix (in CIDR notation) will be allocated when nodes join the cluster. 76// Not all network providers support multiple ClusterNetworks 77type ClusterNetworkEntry struct { 78 CIDR string `json:"cidr"` 79 // +kubebuilder:validation:Minimum=0 80 HostPrefix uint32 `json:"hostPrefix"` 81} 82 83// DefaultNetworkDefinition represents a single network plugin's configuration. 84// type must be specified, along with exactly one "Config" that matches the type. 85type DefaultNetworkDefinition struct { 86 // type is the type of network 87 // All NetworkTypes are supported except for NetworkTypeRaw 88 Type NetworkType `json:"type"` 89 90 // openShiftSDNConfig configures the openshift-sdn plugin 91 // +optional 92 OpenShiftSDNConfig *OpenShiftSDNConfig `json:"openshiftSDNConfig,omitempty"` 93 94 // oVNKubernetesConfig configures the ovn-kubernetes plugin. This is currently 95 // not implemented. 96 // +optional 97 OVNKubernetesConfig *OVNKubernetesConfig `json:"ovnKubernetesConfig,omitempty"` 98 99 // KuryrConfig configures the kuryr plugin 100 // +optional 101 KuryrConfig *KuryrConfig `json:"kuryrConfig,omitempty"` 102} 103 104// SimpleMacvlanConfig contains configurations for macvlan interface. 105type SimpleMacvlanConfig struct { 106 // master is the host interface to create the macvlan interface from. 107 // If not specified, it will be default route interface 108 // +optional 109 Master string `json:"master,omitempty"` 110 111 // IPAMConfig configures IPAM module will be used for IP Address Management (IPAM). 112 // +optional 113 IPAMConfig *IPAMConfig `json:"ipamConfig,omitempty"` 114 115 // mode is the macvlan mode: bridge, private, vepa, passthru. The default is bridge 116 // +optional 117 Mode MacvlanMode `json:"mode,omitempty"` 118 119 // mtu is the mtu to use for the macvlan interface. if unset, host's 120 // kernel will select the value. 121 // +kubebuilder:validation:Minimum=0 122 // +optional 123 MTU uint32 `json:"mtu,omitempty"` 124} 125 126// StaticIPAMAddresses provides IP address and Gateway for static IPAM addresses 127type StaticIPAMAddresses struct { 128 // Address is the IP address in CIDR format 129 // +optional 130 Address string `json:"address"` 131 // Gateway is IP inside of subnet to designate as the gateway 132 // +optional 133 Gateway string `json:"gateway,omitempty"` 134} 135 136// StaticIPAMRoutes provides Destination/Gateway pairs for static IPAM routes 137type StaticIPAMRoutes struct { 138 // Destination points the IP route destination 139 Destination string `json:"destination"` 140 // Gateway is the route's next-hop IP address 141 // If unset, a default gateway is assumed (as determined by the CNI plugin). 142 // +optional 143 Gateway string `json:"gateway,omitempty"` 144} 145 146// StaticIPAMDNS provides DNS related information for static IPAM 147type StaticIPAMDNS struct { 148 // Nameservers points DNS servers for IP lookup 149 // +optional 150 Nameservers []string `json:"nameservers,omitempty"` 151 // Domain configures the domainname the local domain used for short hostname lookups 152 // +optional 153 Domain string `json:"domain,omitempty"` 154 // Search configures priority ordered search domains for short hostname lookups 155 // +optional 156 Search []string `json:"search,omitempty"` 157} 158 159// StaticIPAMConfig contains configurations for static IPAM (IP Address Management) 160type StaticIPAMConfig struct { 161 // Addresses configures IP address for the interface 162 // +optional 163 Addresses []StaticIPAMAddresses `json:"addresses,omitempty"` 164 // Routes configures IP routes for the interface 165 // +optional 166 Routes []StaticIPAMRoutes `json:"routes,omitempty"` 167 // DNS configures DNS for the interface 168 // +optional 169 DNS *StaticIPAMDNS `json:"dns,omitempty"` 170} 171 172// IPAMConfig contains configurations for IPAM (IP Address Management) 173type IPAMConfig struct { 174 // Type is the type of IPAM module will be used for IP Address Management(IPAM). 175 // The supported values are IPAMTypeDHCP, IPAMTypeStatic 176 Type IPAMType `json:"type"` 177 178 // StaticIPAMConfig configures the static IP address in case of type:IPAMTypeStatic 179 // +optional 180 StaticIPAMConfig *StaticIPAMConfig `json:"staticIPAMConfig,omitempty"` 181} 182 183// AdditionalNetworkDefinition configures an extra network that is available but not 184// created by default. Instead, pods must request them by name. 185// type must be specified, along with exactly one "Config" that matches the type. 186type AdditionalNetworkDefinition struct { 187 // type is the type of network 188 // The supported values are NetworkTypeRaw, NetworkTypeSimpleMacvlan 189 Type NetworkType `json:"type"` 190 191 // name is the name of the network. This will be populated in the resulting CRD 192 // This must be unique. 193 Name string `json:"name"` 194 195 // namespace is the namespace of the network. This will be populated in the resulting CRD 196 // If not given the network will be created in the default namespace. 197 Namespace string `json:"namespace,omitempty"` 198 199 // rawCNIConfig is the raw CNI configuration json to create in the 200 // NetworkAttachmentDefinition CRD 201 RawCNIConfig string `json:"rawCNIConfig,omitempty"` 202 203 // SimpleMacvlanConfig configures the macvlan interface in case of type:NetworkTypeSimpleMacvlan 204 // +optional 205 SimpleMacvlanConfig *SimpleMacvlanConfig `json:"simpleMacvlanConfig,omitempty"` 206} 207 208// OpenShiftSDNConfig configures the three openshift-sdn plugins 209type OpenShiftSDNConfig struct { 210 // mode is one of "Multitenant", "Subnet", or "NetworkPolicy" 211 Mode SDNMode `json:"mode"` 212 213 // vxlanPort is the port to use for all vxlan packets. The default is 4789. 214 // +kubebuilder:validation:Minimum=0 215 // +optional 216 VXLANPort *uint32 `json:"vxlanPort,omitempty"` 217 218 // mtu is the mtu to use for the tunnel interface. Defaults to 1450 if unset. 219 // This must be 50 bytes smaller than the machine's uplink. 220 // +kubebuilder:validation:Minimum=0 221 // +optional 222 MTU *uint32 `json:"mtu,omitempty"` 223 224 // useExternalOpenvswitch tells the operator not to install openvswitch, because 225 // it will be provided separately. If set, you must provide it yourself. 226 // +optional 227 UseExternalOpenvswitch *bool `json:"useExternalOpenvswitch,omitempty"` 228 229 // enableUnidling controls whether or not the service proxy will support idling 230 // and unidling of services. By default, unidling is enabled. 231 EnableUnidling *bool `json:"enableUnidling,omitempty"` 232} 233 234// KuryrConfig configures the Kuryr-Kubernetes SDN 235type KuryrConfig struct { 236 // The port kuryr-daemon will listen for readiness and liveness requests. 237 // +kubebuilder:validation:Minimum=0 238 // +optional 239 DaemonProbesPort *uint32 `json:"daemonProbesPort,omitempty"` 240 241 // The port kuryr-controller will listen for readiness and liveness requests. 242 // +kubebuilder:validation:Minimum=0 243 // +optional 244 ControllerProbesPort *uint32 `json:"controllerProbesPort,omitempty"` 245 246 // openStackServiceNetwork contains the CIDR of network from which to allocate IPs for 247 // OpenStack Octavia's Amphora VMs. Please note that with Amphora driver Octavia uses 248 // two IPs from that network for each loadbalancer - one given by OpenShift and second 249 // for VRRP connections. As the first one is managed by OpenShift's and second by Neutron's 250 // IPAMs, those need to come from different pools. Therefore `openStackServiceNetwork` 251 // needs to be at least twice the size of `serviceNetwork`, and whole `serviceNetwork` 252 // must be overlapping with `openStackServiceNetwork`. cluster-network-operator will then 253 // make sure VRRP IPs are taken from the ranges inside `openStackServiceNetwork` that 254 // are not overlapping with `serviceNetwork`, effectivly preventing conflicts. If not set 255 // cluster-network-operator will use `serviceNetwork` expanded by decrementing the prefix 256 // size by 1. 257 // +optional 258 OpenStackServiceNetwork string `json:"openStackServiceNetwork,omitempty"` 259} 260 261// ovnKubernetesConfig contains the configuration parameters for networks 262// using the ovn-kubernetes network project 263type OVNKubernetesConfig struct { 264 // mtu is the MTU to use for the tunnel interface. This must be 100 265 // bytes smaller than the uplink mtu. 266 // Default is 1400 267 // +kubebuilder:validation:Minimum=0 268 // +optional 269 MTU *uint32 `json:"mtu,omitempty"` 270 // geneve port is the UDP port to be used by geneve encapulation. 271 // Default is 6081 272 // +kubebuilder:validation:Minimum=1 273 // +optional 274 GenevePort *uint32 `json:"genevePort,omitempty"` 275} 276 277// NetworkType describes the network plugin type to configure 278type NetworkType string 279 280// ProxyArgumentList is a list of arguments to pass to the kubeproxy process 281type ProxyArgumentList []string 282 283// ProxyConfig defines the configuration knobs for kubeproxy 284// All of these are optional and have sensible defaults 285type ProxyConfig struct { 286 // The period that iptables rules are refreshed. 287 // Default: 30s 288 IptablesSyncPeriod string `json:"iptablesSyncPeriod,omitempty"` 289 290 // The address to "bind" on 291 // Defaults to 0.0.0.0 292 BindAddress string `json:"bindAddress,omitempty"` 293 294 // Any additional arguments to pass to the kubeproxy process 295 ProxyArguments map[string]ProxyArgumentList `json:"proxyArguments,omitempty"` 296} 297 298const ( 299 // NetworkTypeOpenShiftSDN means the openshift-sdn plugin will be configured 300 NetworkTypeOpenShiftSDN NetworkType = "OpenShiftSDN" 301 302 // NetworkTypeOVNKubernetes means the ovn-kubernetes project will be configured. 303 // This is currently not implemented. 304 NetworkTypeOVNKubernetes NetworkType = "OVNKubernetes" 305 306 // NetworkTypeKuryr means the kuryr-kubernetes project will be configured. 307 NetworkTypeKuryr NetworkType = "Kuryr" 308 309 // NetworkTypeRaw 310 NetworkTypeRaw NetworkType = "Raw" 311 312 // NetworkTypeSimpleMacvlan 313 NetworkTypeSimpleMacvlan NetworkType = "SimpleMacvlan" 314) 315 316// SDNMode is the Mode the openshift-sdn plugin is in 317type SDNMode string 318 319const ( 320 // SDNModeSubnet is a simple mode that offers no isolation between pods 321 SDNModeSubnet SDNMode = "Subnet" 322 323 // SDNModeMultitenant is a special "multitenant" mode that offers limited 324 // isolation configuration between namespaces 325 SDNModeMultitenant SDNMode = "Multitenant" 326 327 // SDNModeNetworkPolicy is a full NetworkPolicy implementation that allows 328 // for sophisticated network isolation and segmenting. This is the default. 329 SDNModeNetworkPolicy SDNMode = "NetworkPolicy" 330) 331 332// MacvlanMode is the Mode of macvlan. The value are lowercase to match the CNI plugin 333// config values. See "man ip-link" for its detail. 334type MacvlanMode string 335 336const ( 337 // MacvlanModeBridge is the macvlan with thin bridge function. 338 MacvlanModeBridge MacvlanMode = "Bridge" 339 // MacvlanModePrivate 340 MacvlanModePrivate MacvlanMode = "Private" 341 // MacvlanModeVEPA is used with Virtual Ethernet Port Aggregator 342 // (802.1qbg) swtich 343 MacvlanModeVEPA MacvlanMode = "VEPA" 344 // MacvlanModePassthru 345 MacvlanModePassthru MacvlanMode = "Passthru" 346) 347 348// IPAMType describes the IP address management type to configure 349type IPAMType string 350 351const ( 352 // IPAMTypeDHCP uses DHCP for IP management 353 IPAMTypeDHCP IPAMType = "DHCP" 354 // IPAMTypeStatic uses static IP 355 IPAMTypeStatic IPAMType = "Static" 356) 357