Skip to content

Commit 8725537

Browse files
authored
feat: add user-defined annotations support for nat gw sts template creation (#6256)
Signed-off-by: zbb88888 <jmdxjsjgcxy@gmail.com>
1 parent f97672e commit 8725537

File tree

11 files changed

+270
-90
lines changed

11 files changed

+270
-90
lines changed

charts/kube-ovn-v2/crds/kube-ovn-crd.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,11 @@ spec:
605605
nextHopIP:
606606
type: string
607607
description: Next hop IP address
608+
annotations:
609+
type: object
610+
additionalProperties:
611+
type: string
612+
description: User-defined annotations for the StatefulSet NAT gateway Pod template. Only effective at creation time.
608613
tolerations:
609614
type: array
610615
items:

charts/kube-ovn/templates/kube-ovn-crd.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,11 @@ spec:
605605
nextHopIP:
606606
type: string
607607
description: Next hop IP address
608+
annotations:
609+
type: object
610+
additionalProperties:
611+
type: string
612+
description: User-defined annotations for the StatefulSet NAT gateway Pod template. Only effective at creation time.
608613
tolerations:
609614
type: array
610615
items:

dist/images/install.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,11 @@ spec:
855855
nextHopIP:
856856
type: string
857857
description: Next hop IP address
858+
annotations:
859+
type: object
860+
additionalProperties:
861+
type: string
862+
description: User-defined annotations for the StatefulSet NAT gateway Pod template. Only effective at creation time.
858863
tolerations:
859864
type: array
860865
items:

pkg/apis/kubeovn/v1/vpc-nat-gateway.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ type VpcNatGatewayList struct {
2121
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
2222
// +genclient:nonNamespaced
2323
// +resourceName=vpc-nat-gateways
24+
//
25+
// VpcNatGateway represents a NAT gateway for a VPC, implemented as a StatefulSet Pod.
26+
//
27+
// Architecture note:
28+
// The NAT gateway Pod does NOT support hot updates. Any changes to Spec fields (ExternalSubnets,
29+
// Selector, Tolerations, Affinity, etc.) will trigger a StatefulSet template update,
30+
// which causes the Pod to be recreated via RollingUpdate strategy. This is by design because:
31+
// 1. Network configuration (routes, iptables rules) is initialized at Pod startup
32+
// 2. Runtime state (vpc_cidrs, init status) is managed by separate handlers and will be
33+
// automatically restored after Pod recreation through the normal reconciliation flow
34+
//
35+
// The only exception is QoSPolicy, which can be updated without Pod restart.
2436
type VpcNatGateway struct {
2537
metav1.TypeMeta `json:",inline"`
2638
metav1.ObjectMeta `json:"metadata"`
@@ -41,6 +53,9 @@ type VpcNatGatewaySpec struct {
4153
BgpSpeaker VpcBgpSpeaker `json:"bgpSpeaker"`
4254
Routes []Route `json:"routes"`
4355
NoDefaultEIP bool `json:"noDefaultEIP"`
56+
// User-defined annotations for the StatefulSet NAT gateway Pod template.
57+
// Only effective at creation time; updates to this field are not detected.
58+
Annotations map[string]string `json:"annotations,omitempty"`
4459
}
4560

4661
type VpcBgpSpeaker struct {
@@ -55,6 +70,7 @@ type VpcBgpSpeaker struct {
5570
ExtraArgs []string `json:"extraArgs"`
5671
}
5772

73+
// TODO: Consider removing redundant Status fields since statefulset template changes always trigger Pod recreation.
5874
type VpcNatGatewayStatus struct {
5975
QoSPolicy string `json:"qosPolicy" patchStrategy:"merge"`
6076
ExternalSubnets []string `json:"externalSubnets" patchStrategy:"merge"`

pkg/apis/kubeovn/v1/zz_generated.deepcopy.go

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

0 commit comments

Comments
 (0)