Skip to content

Commit 544da39

Browse files
committed
DNM: PoC ippool + network data generator
Signed-off-by: Enrique Llorente <[email protected]>
1 parent 65467dd commit 544da39

File tree

5,985 files changed

+1864248
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,985 files changed

+1864248
-103
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
# Build the manager binary
1818
# Run this with docker build --build-arg builder_image=<golang:x.y.z>
19-
ARG builder_image=docker.io/golang:1.23
19+
ARG builder_image=docker.io/golang:1.24
2020
FROM ${builder_image} as builder
2121
WORKDIR /workspace
2222

api/v1alpha1/kubevirtmachine_types.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const (
2828
// MachineFinalizer allows ReconcileKubevirtMachine to clean up resources associated with machine before
2929
// removing it from the apiserver.
3030
MachineFinalizer = "kubevirtmachine.infrastructure.cluster.x-k8s.io"
31+
32+
// AllocatedIPsAnnotationPrefix is the prefix for annotations storing allocated IPs per network
33+
// The full annotation key will be: AllocatedIPsAnnotationPrefix + networkName
34+
AllocatedIPsAnnotationPrefix = "infrastructure.cluster.x-k8s.io/allocated-ips-"
3135
)
3236

3337
// VirtualMachineTemplateSpec defines the desired state of the kubevirt VM.
@@ -55,6 +59,8 @@ type KubevirtMachineSpec struct {
5559
// When nil, this defaults to the value present in the KubevirtCluster object's spec associated with this machine.
5660
// +optional
5761
InfraClusterSecretRef *corev1.ObjectReference `json:"infraClusterSecretRef,omitempty"`
62+
63+
NetworkConfig *NetworkConfig `json:"networkConfig,omitempty"`
5864
}
5965

6066
// VirtualMachineBootstrapCheckSpec defines how the controller will remotely check CAPI Sentinel file content.
@@ -68,6 +74,27 @@ type VirtualMachineBootstrapCheckSpec struct {
6874
CheckStrategy string `json:"checkStrategy,omitempty"`
6975
}
7076

77+
type IPPoolEntry struct {
78+
// +required
79+
InterfaceName string `json:"interfaceName"`
80+
// Subnets specify IP ranges from which addresses will be allocated for this interface.
81+
// Supports CIDR notation, hyphenated ranges, and single IPs.
82+
// +required
83+
Subnets []string `json:"subnets"`
84+
}
85+
86+
type NetworkConfig struct {
87+
// CloudInitNetworkData contains user-provided cloud-init network data in YAML format.
88+
// The system will find the interface specified in IPPool entries and inject
89+
// allocated IP addresses into this network configuration.
90+
// +optional
91+
CloudInitNetworkData string `json:"cloudInitNetworkData,omitempty"`
92+
// IPPool is a map where the key is the network name and the value contains
93+
// the interface name and subnets for that network.
94+
// +required
95+
IPPool map[string]IPPoolEntry `json:"ipPool"`
96+
}
97+
7198
// KubevirtMachineStatus defines the observed state of KubevirtMachine.
7299
type KubevirtMachineStatus struct {
73100
// Ready denotes that the machine is ready

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_kubevirtclusters.yaml

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -195,32 +195,27 @@ spec:
195195
properties:
196196
lastTransitionTime:
197197
description: |-
198-
lastTransitionTime is the last time the condition transitioned from one status to another.
198+
Last time the condition transitioned from one status to another.
199199
This should be when the underlying condition changed. If that is not known, then using the time when
200200
the API field changed is acceptable.
201201
format: date-time
202202
type: string
203203
message:
204204
description: |-
205-
message is a human readable message indicating details about the transition.
205+
A human readable message indicating details about the transition.
206206
This field may be empty.
207-
maxLength: 10240
208-
minLength: 1
209207
type: string
210208
reason:
211209
description: |-
212-
reason is the reason for the condition's last transition in CamelCase.
210+
The reason for the condition's last transition in CamelCase.
213211
The specific API may choose whether or not this field is considered a guaranteed API.
214212
This field may be empty.
215-
maxLength: 256
216-
minLength: 1
217213
type: string
218214
severity:
219215
description: |-
220216
severity provides an explicit classification of Reason code, so the users or machines can immediately
221217
understand the current situation and act accordingly.
222218
The Severity field MUST be set only when Status=False.
223-
maxLength: 32
224219
type: string
225220
status:
226221
description: status of the condition, one of True, False, Unknown.
@@ -230,8 +225,6 @@ spec:
230225
type of condition in CamelCase or in foo.example.com/CamelCase.
231226
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
232227
can be useful (see .node.status.conditions), the ability to deconflict is important.
233-
maxLength: 256
234-
minLength: 1
235228
type: string
236229
required:
237230
- lastTransitionTime

config/crd/bases/infrastructure.cluster.x-k8s.io_kubevirtclustertemplates.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ spec:
8686
additionalProperties:
8787
type: string
8888
description: |-
89-
labels is a map of string keys and values that can be used to organize and categorize
89+
Map of string keys and values that can be used to organize and categorize
9090
(scope and select) objects. May match selectors of replication controllers
9191
and services.
9292
More info: http://kubernetes.io/docs/user-guide/labels

config/crd/bases/infrastructure.cluster.x-k8s.io_kubevirtmachines.yaml

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,37 @@ spec:
9494
type: string
9595
type: object
9696
x-kubernetes-map-type: atomic
97+
networkConfig:
98+
properties:
99+
cloudInitNetworkData:
100+
description: |-
101+
CloudInitNetworkData contains user-provided cloud-init network data in YAML format.
102+
The system will find the interface specified in IPPool entries and inject
103+
allocated IP addresses into this network configuration.
104+
type: string
105+
ipPool:
106+
additionalProperties:
107+
properties:
108+
interfaceName:
109+
type: string
110+
subnets:
111+
description: |-
112+
Subnets specify IP ranges from which addresses will be allocated for this interface.
113+
Supports CIDR notation, hyphenated ranges, and single IPs.
114+
items:
115+
type: string
116+
type: array
117+
required:
118+
- interfaceName
119+
- subnets
120+
type: object
121+
description: |-
122+
IPPool is a map where the key is the network name and the value contains
123+
the interface name and subnets for that network.
124+
type: object
125+
required:
126+
- ipPool
127+
type: object
97128
providerID:
98129
description: ProviderID TBD what to use for Kubevirt
99130
type: string
@@ -4348,19 +4379,11 @@ spec:
43484379
address.
43494380
properties:
43504381
address:
4351-
description: address is the machine address.
4352-
maxLength: 256
4353-
minLength: 1
4382+
description: The machine address.
43544383
type: string
43554384
type:
4356-
description: type is the machine address type, one of Hostname,
4357-
ExternalIP, InternalIP, ExternalDNS or InternalDNS.
4358-
enum:
4359-
- Hostname
4360-
- ExternalIP
4361-
- InternalIP
4362-
- ExternalDNS
4363-
- InternalDNS
4385+
description: Machine address type, one of Hostname, ExternalIP,
4386+
InternalIP, ExternalDNS or InternalDNS.
43644387
type: string
43654388
required:
43664389
- address
@@ -4375,32 +4398,27 @@ spec:
43754398
properties:
43764399
lastTransitionTime:
43774400
description: |-
4378-
lastTransitionTime is the last time the condition transitioned from one status to another.
4401+
Last time the condition transitioned from one status to another.
43794402
This should be when the underlying condition changed. If that is not known, then using the time when
43804403
the API field changed is acceptable.
43814404
format: date-time
43824405
type: string
43834406
message:
43844407
description: |-
4385-
message is a human readable message indicating details about the transition.
4408+
A human readable message indicating details about the transition.
43864409
This field may be empty.
4387-
maxLength: 10240
4388-
minLength: 1
43894410
type: string
43904411
reason:
43914412
description: |-
4392-
reason is the reason for the condition's last transition in CamelCase.
4413+
The reason for the condition's last transition in CamelCase.
43934414
The specific API may choose whether or not this field is considered a guaranteed API.
43944415
This field may be empty.
4395-
maxLength: 256
4396-
minLength: 1
43974416
type: string
43984417
severity:
43994418
description: |-
44004419
severity provides an explicit classification of Reason code, so the users or machines can immediately
44014420
understand the current situation and act accordingly.
44024421
The Severity field MUST be set only when Status=False.
4403-
maxLength: 32
44044422
type: string
44054423
status:
44064424
description: status of the condition, one of True, False, Unknown.
@@ -4410,8 +4428,6 @@ spec:
44104428
type of condition in CamelCase or in foo.example.com/CamelCase.
44114429
Many .condition.type values are consistent across resources like Available, but because arbitrary conditions
44124430
can be useful (see .node.status.conditions), the ability to deconflict is important.
4413-
maxLength: 256
4414-
minLength: 1
44154431
type: string
44164432
required:
44174433
- lastTransitionTime

config/crd/bases/infrastructure.cluster.x-k8s.io_kubevirtmachinetemplates.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,37 @@ spec:
9696
type: string
9797
type: object
9898
x-kubernetes-map-type: atomic
99+
networkConfig:
100+
properties:
101+
cloudInitNetworkData:
102+
description: |-
103+
CloudInitNetworkData contains user-provided cloud-init network data in YAML format.
104+
The system will find the interface specified in IPPool entries and inject
105+
allocated IP addresses into this network configuration.
106+
type: string
107+
ipPool:
108+
additionalProperties:
109+
properties:
110+
interfaceName:
111+
type: string
112+
subnets:
113+
description: |-
114+
Subnets specify IP ranges from which addresses will be allocated for this interface.
115+
Supports CIDR notation, hyphenated ranges, and single IPs.
116+
items:
117+
type: string
118+
type: array
119+
required:
120+
- interfaceName
121+
- subnets
122+
type: object
123+
description: |-
124+
IPPool is a map where the key is the network name and the value contains
125+
the interface name and subnets for that network.
126+
type: object
127+
required:
128+
- ipPool
129+
type: object
99130
providerID:
100131
description: ProviderID TBD what to use for Kubevirt
101132
type: string

config/default/manager_image_patch.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ spec:
88
spec:
99
containers:
1010
# Change the value of image field below to your controller image URL
11-
- image: controller
11+
- image: 127.0.0.1:32771/capk-manager-amd64:dev
1212
name: manager

0 commit comments

Comments
 (0)