Skip to content

Commit

Permalink
Add v1beta1 API for IPPool CRD (#6036)
Browse files Browse the repository at this point in the history
As part of this change, we try to unify IPPool subnet and ExternalIPPool
definitions:
We make IPPoolSpec of IPPool use the same way to define IP ranges
and subnet as ExternalIPPool. With this change, one IPPool can have
multiple IP ranges, but it can only have one SubnetInfo, so this change
also adjusts the related tests, especially the ones for antrea IPAM validation.
We also remove the IPVersion field in IPPool definition, and change
the IPPool VLAN field from uint16 to int32.

We add a conversion webhook for the IPPool CRD. If a v1alpha1 IPPool
cannot be converted to an equivalent v1beta1 IPPool, the conversion
webhook will return an error, in which case the user would need to change
their IPPool resources manually.

Fixes #5961

Signed-off-by: Mengdie Song <[email protected]>
  • Loading branch information
mengdie-song authored Apr 25, 2024
1 parent 6b0f4f4 commit 9a9db6f
Show file tree
Hide file tree
Showing 48 changed files with 2,789 additions and 525 deletions.
128 changes: 127 additions & 1 deletion build/charts/antrea/crds/ippool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ metadata:
name: ippools.crd.antrea.io
labels:
app: antrea
served-by: antrea-controller
spec:
group: crd.antrea.io
versions:
- name: v1alpha2
served: true
storage: true
storage: false
deprecated: true
deprecationWarning: "crd.antrea.io/v1alpha2 IPPool is deprecated; use crd.antrea.io/v1beta1 IPPool"
schema:
openAPIV3Schema:
type: object
Expand Down Expand Up @@ -122,6 +125,129 @@ spec:
type: date
subresources:
status: {}
- name: v1beta1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
required:
- spec
properties:
spec:
required:
- ipRanges
- subnetInfo
type: object
properties:
ipRanges:
items:
oneOf:
- required:
- cidr
- required:
- start
- end
properties:
cidr:
format: cidr
type: string
start:
oneOf:
- format: ipv4
- format: ipv6
type: string
end:
oneOf:
- format: ipv4
- format: ipv6
type: string
type: object
type: array
subnetInfo:
type: object
required:
- gateway
- prefixLength
properties:
gateway:
type: string
oneOf:
- format: ipv4
- format: ipv6
prefixLength:
type: integer
minimum: 1
maximum: 127
vlan:
type: integer
minimum: 0
maximum: 4094
status:
properties:
ipAddresses:
items:
properties:
ipAddress:
type: string
owner:
properties:
pod:
properties:
name:
type: string
namespace:
type: string
containerID:
type: string
ifName:
type: string
type: object
statefulSet:
properties:
name:
type: string
namespace:
type: string
index:
type: integer
type: object
type: object
phase:
type: string
type: object
type: array
usage:
properties:
used:
type: integer
total:
type: integer
type: object
type: object
additionalPrinterColumns:
- description: The number of total IPs
jsonPath: .status.usage.total
name: Total
type: integer
- description: The number of allocated IPs
jsonPath: .status.usage.used
name: Used
type: integer
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
subresources:
status: {}
conversion:
strategy: Webhook
webhook:
conversionReviewVersions: ["v1", "v1beta1"]
clientConfig:
service:
name: "antrea"
namespace: "kube-system"
path: "/convert/ippool"
scope: Cluster
names:
plural: ippools
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ webhooks:
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["crd.antrea.io"]
apiVersions: ["v1alpha2"]
apiVersions: ["v1beta1"]
resources: ["ippools"]
scope: "Cluster"
admissionReviewVersions: ["v1", "v1beta1"]
Expand Down
130 changes: 128 additions & 2 deletions build/yamls/antrea-aks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1771,12 +1771,15 @@ metadata:
name: ippools.crd.antrea.io
labels:
app: antrea
served-by: antrea-controller
spec:
group: crd.antrea.io
versions:
- name: v1alpha2
served: true
storage: true
storage: false
deprecated: true
deprecationWarning: "crd.antrea.io/v1alpha2 IPPool is deprecated; use crd.antrea.io/v1beta1 IPPool"
schema:
openAPIV3Schema:
type: object
Expand Down Expand Up @@ -1889,6 +1892,129 @@ spec:
type: date
subresources:
status: {}
- name: v1beta1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
required:
- spec
properties:
spec:
required:
- ipRanges
- subnetInfo
type: object
properties:
ipRanges:
items:
oneOf:
- required:
- cidr
- required:
- start
- end
properties:
cidr:
format: cidr
type: string
start:
oneOf:
- format: ipv4
- format: ipv6
type: string
end:
oneOf:
- format: ipv4
- format: ipv6
type: string
type: object
type: array
subnetInfo:
type: object
required:
- gateway
- prefixLength
properties:
gateway:
type: string
oneOf:
- format: ipv4
- format: ipv6
prefixLength:
type: integer
minimum: 1
maximum: 127
vlan:
type: integer
minimum: 0
maximum: 4094
status:
properties:
ipAddresses:
items:
properties:
ipAddress:
type: string
owner:
properties:
pod:
properties:
name:
type: string
namespace:
type: string
containerID:
type: string
ifName:
type: string
type: object
statefulSet:
properties:
name:
type: string
namespace:
type: string
index:
type: integer
type: object
type: object
phase:
type: string
type: object
type: array
usage:
properties:
used:
type: integer
total:
type: integer
type: object
type: object
additionalPrinterColumns:
- description: The number of total IPs
jsonPath: .status.usage.total
name: Total
type: integer
- description: The number of allocated IPs
jsonPath: .status.usage.used
name: Used
type: integer
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
subresources:
status: {}
conversion:
strategy: Webhook
webhook:
conversionReviewVersions: ["v1", "v1beta1"]
clientConfig:
service:
name: "antrea"
namespace: "kube-system"
path: "/convert/ippool"
scope: Cluster
names:
plural: ippools
Expand Down Expand Up @@ -5378,7 +5504,7 @@ webhooks:
rules:
- operations: ["CREATE", "UPDATE", "DELETE"]
apiGroups: ["crd.antrea.io"]
apiVersions: ["v1alpha2"]
apiVersions: ["v1beta1"]
resources: ["ippools"]
scope: "Cluster"
admissionReviewVersions: ["v1", "v1beta1"]
Expand Down
Loading

0 comments on commit 9a9db6f

Please sign in to comment.