Skip to content

Commit 4005801

Browse files
authored
Merge pull request #18 from datum-cloud/feature/instance-lifecycle-control
Add network and network context controllers to manage status conditions and teardown logic.
2 parents 78d7c1b + 86b390e commit 4005801

18 files changed

Lines changed: 490 additions & 93 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ go.work.sum
2525
.env
2626

2727
bin/
28+
config/**/charts

api/v1alpha/networkbinding_types.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,17 @@ const (
6363
// +kubebuilder:subresource:status
6464

6565
// NetworkBinding is the Schema for the networkbindings API
66+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
67+
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
68+
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`
6669
type NetworkBinding struct {
6770
metav1.TypeMeta `json:",inline"`
6871
metav1.ObjectMeta `json:"metadata,omitempty"`
6972

7073
// +kubebuilder:validation:Required
71-
Spec NetworkBindingSpec `json:"spec,omitempty"`
74+
Spec NetworkBindingSpec `json:"spec,omitempty"`
75+
76+
// +kubebuilder:default={conditions:{{type:"Ready",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
7277
Status NetworkBindingStatus `json:"status,omitempty"`
7378
}
7479

api/v1alpha/networkcontext_types.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,41 @@ type NetworkContextStatus struct {
2626
}
2727

2828
const (
29-
// NetworkContextReady indicates that the network context is ready for use.
29+
// NetworkContextReady indicates whether or not the network context is ready for use.
3030
NetworkContextReady = "Ready"
31+
32+
// NetworkContextProgrammed indicates whether or not the network context has been programmed.
33+
NetworkContextProgrammed = "Programmed"
34+
)
35+
36+
const (
37+
// NetworkContextProgrammedReasonNotProgrammed indicates that the network context is not ready because it has not been programmed.
38+
NetworkContextProgrammedReasonNotProgrammed = "NotProgrammed"
39+
40+
// NetworkContextProgrammedReasonProgramming indicates that the network context is being programmed.
41+
NetworkContextProgrammedReasonProgrammingInProgress = "ProgrammingInProgress"
42+
43+
// NetworkContextProgrammedReasonProgrammed indicates that the network context has been programmed.
44+
NetworkContextProgrammedReasonProgrammed = "Programmed"
45+
46+
// NetworkContextReadyReasonReady indicates that the network context is ready for use.
47+
NetworkContextReadyReasonReady = "Ready"
3148
)
3249

3350
// +kubebuilder:object:root=true
3451
// +kubebuilder:subresource:status
3552

3653
// NetworkContext is the Schema for the networkcontexts API
54+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
55+
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
56+
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`
3757
type NetworkContext struct {
3858
metav1.TypeMeta `json:",inline"`
3959
metav1.ObjectMeta `json:"metadata,omitempty"`
4060

41-
Spec NetworkContextSpec `json:"spec,omitempty"`
61+
Spec NetworkContextSpec `json:"spec,omitempty"`
62+
63+
// +kubebuilder:default={conditions:{{type:"Programmed",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"},{type:"Ready",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
4264
Status NetworkContextStatus `json:"status,omitempty"`
4365
}
4466

api/v1alpha/subnet_types.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,47 @@ type SubnetStatus struct {
5151
Conditions []metav1.Condition `json:"conditions,omitempty"`
5252
}
5353

54+
const (
55+
// SubnetAllocated indicates that the subnet has been allocated a prefix
56+
SubnetAllocated = "Allocated"
57+
58+
// SubnetProgrammed indicates that the subnet has been programmed
59+
SubnetProgrammed = "Programmed"
60+
61+
// SubnetReady indicates that the subnet is ready to use
62+
SubnetReady = "Ready"
63+
)
64+
65+
const (
66+
// SubnetProgrammedReasonNotProgrammed indicates that the subnet has not been programmed
67+
SubnetProgrammedReasonNotProgrammed = "NotProgrammed"
68+
69+
// SubnetProgrammedReasonProgrammingInProgress indicates that the subnet is being programmed.
70+
SubnetProgrammedReasonProgrammingInProgress = "ProgrammingInProgress"
71+
72+
// SubnetProgrammedReasonProgrammed indicates that the subnet has been programmed
73+
SubnetProgrammedReasonProgrammed = "Programmed"
74+
75+
// SubnetReadyReasonReady indicates that the subnet is ready to use
76+
SubnetReadyReasonReady = "Ready"
77+
)
78+
5479
// +kubebuilder:object:root=true
5580
// +kubebuilder:subresource:status
5681

5782
// Subnet is the Schema for the subnets API
83+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
84+
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
85+
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`
86+
// +kubebuilder:printcolumn:name="Start Address",type=string,JSONPath=`.status.startAddress`
87+
// +kubebuilder:printcolumn:name="Prefix Length",type=string,JSONPath=`.status.prefixLength`
5888
type Subnet struct {
5989
metav1.TypeMeta `json:",inline"`
6090
metav1.ObjectMeta `json:"metadata,omitempty"`
6191

62-
Spec SubnetSpec `json:"spec,omitempty"`
92+
Spec SubnetSpec `json:"spec,omitempty"`
93+
94+
// +kubebuilder:default={conditions:{{type:"Allocated",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"},{type:"Programmed",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"},{type:"Ready",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
6395
Status SubnetStatus `json:"status,omitempty"`
6496
}
6597

api/v1alpha/subnetclaim_types.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ type SubnetClaimStatus struct {
5858
// +kubebuilder:subresource:status
5959

6060
// SubnetClaim is the Schema for the subnetclaims API
61+
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
62+
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
63+
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`
6164
type SubnetClaim struct {
6265
metav1.TypeMeta `json:",inline"`
6366
metav1.ObjectMeta `json:"metadata,omitempty"`
6467

65-
Spec SubnetClaimSpec `json:"spec,omitempty"`
68+
Spec SubnetClaimSpec `json:"spec,omitempty"`
69+
70+
// +kubebuilder:default={conditions:{{type:"Allocated",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"},{type:"Programmed",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"},{type:"Ready",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
6671
Status SubnetClaimStatus `json:"status,omitempty"`
6772
}
6873

cmd/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,11 @@ func main() {
219219
os.Exit(1)
220220
}
221221

222+
if err = controller.AddIndexers(ctx, mgr); err != nil {
223+
setupLog.Error(err, "unable to add indexers")
224+
os.Exit(1)
225+
}
226+
222227
validationOpts := validation.GatewayValidationOptions{
223228
ControllerName: serverConfig.Gateway.ControllerName,
224229
PermittedTLSOptions: serverConfig.Gateway.PermittedTLSOptions,

config/crd/bases/networking.datumapis.com_networkbindings.yaml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ spec:
1414
singular: networkbinding
1515
scope: Namespaced
1616
versions:
17-
- name: v1alpha
17+
- additionalPrinterColumns:
18+
- jsonPath: .metadata.creationTimestamp
19+
name: Age
20+
type: date
21+
- jsonPath: .status.conditions[?(@.type=="Ready")].status
22+
name: Ready
23+
type: string
24+
- jsonPath: .status.conditions[?(@.type=="Ready")].reason
25+
name: Reason
26+
type: string
27+
name: v1alpha
1828
schema:
1929
openAPIV3Schema:
2030
description: NetworkBinding is the Schema for the networkbindings API
@@ -72,6 +82,13 @@ spec:
7282
- network
7383
type: object
7484
status:
85+
default:
86+
conditions:
87+
- lastTransitionTime: "1970-01-01T00:00:00Z"
88+
message: Waiting for controller
89+
reason: Pending
90+
status: Unknown
91+
type: Ready
7592
description: NetworkBindingStatus defines the observed state of NetworkBinding
7693
properties:
7794
conditions:

config/crd/bases/networking.datumapis.com_networkcontexts.yaml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ spec:
1414
singular: networkcontext
1515
scope: Namespaced
1616
versions:
17-
- name: v1alpha
17+
- additionalPrinterColumns:
18+
- jsonPath: .metadata.creationTimestamp
19+
name: Age
20+
type: date
21+
- jsonPath: .status.conditions[?(@.type=="Ready")].status
22+
name: Ready
23+
type: string
24+
- jsonPath: .status.conditions[?(@.type=="Ready")].reason
25+
name: Reason
26+
type: string
27+
name: v1alpha
1828
schema:
1929
openAPIV3Schema:
2030
description: NetworkContext is the Schema for the networkcontexts API
@@ -66,6 +76,18 @@ spec:
6676
- network
6777
type: object
6878
status:
79+
default:
80+
conditions:
81+
- lastTransitionTime: "1970-01-01T00:00:00Z"
82+
message: Waiting for controller
83+
reason: Pending
84+
status: Unknown
85+
type: Programmed
86+
- lastTransitionTime: "1970-01-01T00:00:00Z"
87+
message: Waiting for controller
88+
reason: Pending
89+
status: Unknown
90+
type: Ready
6991
description: NetworkContextStatus defines the observed state of NetworkContext
7092
properties:
7193
conditions:

config/crd/bases/networking.datumapis.com_subnetclaims.yaml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ spec:
1414
singular: subnetclaim
1515
scope: Namespaced
1616
versions:
17-
- name: v1alpha
17+
- additionalPrinterColumns:
18+
- jsonPath: .metadata.creationTimestamp
19+
name: Age
20+
type: date
21+
- jsonPath: .status.conditions[?(@.type=="Ready")].status
22+
name: Ready
23+
type: string
24+
- jsonPath: .status.conditions[?(@.type=="Ready")].reason
25+
name: Reason
26+
type: string
27+
name: v1alpha
1828
schema:
1929
openAPIV3Schema:
2030
description: SubnetClaim is the Schema for the subnetclaims API
@@ -84,6 +94,23 @@ spec:
8494
- subnetClass
8595
type: object
8696
status:
97+
default:
98+
conditions:
99+
- lastTransitionTime: "1970-01-01T00:00:00Z"
100+
message: Waiting for controller
101+
reason: Pending
102+
status: Unknown
103+
type: Allocated
104+
- lastTransitionTime: "1970-01-01T00:00:00Z"
105+
message: Waiting for controller
106+
reason: Pending
107+
status: Unknown
108+
type: Programmed
109+
- lastTransitionTime: "1970-01-01T00:00:00Z"
110+
message: Waiting for controller
111+
reason: Pending
112+
status: Unknown
113+
type: Ready
87114
description: SubnetClaimStatus defines the observed state of SubnetClaim
88115
properties:
89116
conditions:

config/crd/bases/networking.datumapis.com_subnets.yaml

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,23 @@ spec:
1414
singular: subnet
1515
scope: Namespaced
1616
versions:
17-
- name: v1alpha
17+
- additionalPrinterColumns:
18+
- jsonPath: .metadata.creationTimestamp
19+
name: Age
20+
type: date
21+
- jsonPath: .status.conditions[?(@.type=="Ready")].status
22+
name: Ready
23+
type: string
24+
- jsonPath: .status.conditions[?(@.type=="Ready")].reason
25+
name: Reason
26+
type: string
27+
- jsonPath: .status.startAddress
28+
name: Start Address
29+
type: string
30+
- jsonPath: .status.prefixLength
31+
name: Prefix Length
32+
type: string
33+
name: v1alpha
1834
schema:
1935
openAPIV3Schema:
2036
description: Subnet is the Schema for the subnets API
@@ -86,6 +102,23 @@ spec:
86102
- subnetClass
87103
type: object
88104
status:
105+
default:
106+
conditions:
107+
- lastTransitionTime: "1970-01-01T00:00:00Z"
108+
message: Waiting for controller
109+
reason: Pending
110+
status: Unknown
111+
type: Allocated
112+
- lastTransitionTime: "1970-01-01T00:00:00Z"
113+
message: Waiting for controller
114+
reason: Pending
115+
status: Unknown
116+
type: Programmed
117+
- lastTransitionTime: "1970-01-01T00:00:00Z"
118+
message: Waiting for controller
119+
reason: Pending
120+
status: Unknown
121+
type: Ready
89122
description: SubnetStatus defines the observed state of a Subnet
90123
properties:
91124
conditions:

0 commit comments

Comments
 (0)