Skip to content

Commit cc6aaf5

Browse files
authored
update nnc printcols for kubectl output (#1908)
Signed-off-by: Evan Baker <[email protected]>
1 parent aa163aa commit cc6aaf5

File tree

2 files changed

+43
-23
lines changed

2 files changed

+43
-23
lines changed

crd/nodenetworkconfig/api/v1alpha/nodenetworkconfig.go

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ import (
1515
// +kubebuilder:resource:scope=Namespaced
1616
// +kubebuilder:resource:shortName=nnc
1717
// +kubebuilder:subresource:status
18-
// +kubebuilder:printcolumn:name="Status",type=string,JSONPath=`.status.status`
19-
// +kubebuilder:printcolumn:name="Requested IPs",type=string,JSONPath=`.spec.requestedIPCount`
20-
// +kubebuilder:printcolumn:name="Assigned IPs",type=string,JSONPath=`.status.assignedIPCount`
21-
// +kubebuilder:printcolumn:name="Subnet",type=string,JSONPath=`.status.networkContainers[*].subnetName`
22-
// +kubebuilder:printcolumn:name="Subnet CIDR",type=string,JSONPath=`.status.networkContainers[*].subnetAddressSpace`
23-
// +kubebuilder:printcolumn:name="NC ID",type=string,JSONPath=`.status.networkContainers[*].id`
24-
// +kubebuilder:printcolumn:name="NC Version",type=string,JSONPath=`.status.networkContainers[*].version`
18+
// +kubebuilder:printcolumn:name="Requested IPs",type=integer,priority=1,JSONPath=`.spec.requestedIPCount`
19+
// +kubebuilder:printcolumn:name="Allocated IPs",type=integer,priority=0,JSONPath=`.status.assignedIPCount`
20+
// +kubebuilder:printcolumn:name="Subnet",type=string,priority=1,JSONPath=`.status.networkContainers[*].subnetName`
21+
// +kubebuilder:printcolumn:name="Subnet CIDR",type=string,priority=1,JSONPath=`.status.networkContainers[*].subnetAddressSpace`
22+
// +kubebuilder:printcolumn:name="NC ID",type=string,priority=1,JSONPath=`.status.networkContainers[*].id`
23+
// +kubebuilder:printcolumn:name="NC Mode",type=string,priority=0,JSONPath=`.status.networkContainers[*].assignmentMode`
24+
// +kubebuilder:printcolumn:name="NC Type",type=string,priority=1,JSONPath=`.status.networkContainers[*].type`
25+
// +kubebuilder:printcolumn:name="NC Version",type=integer,priority=0,JSONPath=`.status.networkContainers[*].version`
2526
type NodeNetworkConfig struct {
2627
metav1.TypeMeta `json:",inline"`
2728
metav1.ObjectMeta `json:"metadata,omitempty"`
@@ -41,7 +42,9 @@ type NodeNetworkConfigList struct {
4142

4243
// NodeNetworkConfigSpec defines the desired state of NetworkConfig
4344
type NodeNetworkConfigSpec struct {
44-
RequestedIPCount int64 `json:"requestedIPCount,omitempty"`
45+
// +kubebuilder:default=0
46+
// +kubebuilder:validation:Optional
47+
RequestedIPCount int64 `json:"requestedIPCount"`
4548
IPsNotInUse []string `json:"ipsNotInUse,omitempty"`
4649
}
4750

@@ -57,7 +60,9 @@ const (
5760

5861
// NodeNetworkConfigStatus defines the observed state of NetworkConfig
5962
type NodeNetworkConfigStatus struct {
60-
AssignedIPCount int `json:"assignedIPCount,omitempty"`
63+
// +kubebuilder:default=0
64+
// +kubebuilder:validation:Optional
65+
AssignedIPCount int `json:"assignedIPCount"`
6166
Scaler Scaler `json:"scaler,omitempty"`
6267
Status Status `json:"status,omitempty"`
6368
NetworkContainers []NetworkContainer `json:"networkContainers,omitempty"`
@@ -93,19 +98,22 @@ const (
9398
type NetworkContainer struct {
9499
ID string `json:"id,omitempty"`
95100
// +kubebuilder:default=dynamic
96-
AssignmentMode AssignmentMode `json:"assignmentMode,omitempty"`
101+
AssignmentMode AssignmentMode `json:"assignmentMode,omitempty"`
102+
// +kubebuilder:default=vnet
97103
Type NCType `json:"type,omitempty"`
98104
PrimaryIP string `json:"primaryIP,omitempty"`
99105
SubnetName string `json:"subnetName,omitempty"`
100106
IPAssignments []IPAssignment `json:"ipAssignments,omitempty"`
101107
DefaultGateway string `json:"defaultGateway,omitempty"`
102108
SubnetAddressSpace string `json:"subnetAddressSpace,omitempty"`
103-
Version int64 `json:"version,omitempty"`
104-
NodeIP string `json:"nodeIP,omitempty"`
105-
SubscriptionID string `json:"subcriptionID,omitempty"`
106-
ResourceGroupID string `json:"resourceGroupID,omitempty"`
107-
VNETID string `json:"vnetID,omitempty"`
108-
SubnetID string `json:"subnetID,omitempty"`
109+
// +kubebuilder:default=0
110+
// +kubebuilder:validation:Optional
111+
Version int64 `json:"version"`
112+
NodeIP string `json:"nodeIP,omitempty"`
113+
SubscriptionID string `json:"subcriptionID,omitempty"`
114+
ResourceGroupID string `json:"resourceGroupID,omitempty"`
115+
VNETID string `json:"vnetID,omitempty"`
116+
SubnetID string `json:"subnetID,omitempty"`
109117
}
110118

111119
// IPAssignment groups an IP address and Name. Name is a UUID set by the the IP address assigner.

crd/nodenetworkconfig/manifests/acn.azure.com_nodenetworkconfigs.yaml

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,35 @@ spec:
1818
scope: Namespaced
1919
versions:
2020
- additionalPrinterColumns:
21-
- jsonPath: .status.status
22-
name: Status
23-
type: string
2421
- jsonPath: .spec.requestedIPCount
2522
name: Requested IPs
26-
type: string
23+
priority: 1
24+
type: integer
2725
- jsonPath: .status.assignedIPCount
28-
name: Assigned IPs
29-
type: string
26+
name: Allocated IPs
27+
type: integer
3028
- jsonPath: .status.networkContainers[*].subnetName
3129
name: Subnet
30+
priority: 1
3231
type: string
3332
- jsonPath: .status.networkContainers[*].subnetAddressSpace
3433
name: Subnet CIDR
34+
priority: 1
3535
type: string
3636
- jsonPath: .status.networkContainers[*].id
3737
name: NC ID
38+
priority: 1
39+
type: string
40+
- jsonPath: .status.networkContainers[*].assignmentMode
41+
name: NC Mode
42+
type: string
43+
- jsonPath: .status.networkContainers[*].type
44+
name: NC Type
45+
priority: 1
3846
type: string
3947
- jsonPath: .status.networkContainers[*].version
4048
name: NC Version
41-
type: string
49+
type: integer
4250
name: v1alpha
4351
schema:
4452
openAPIV3Schema:
@@ -64,13 +72,15 @@ spec:
6472
type: string
6573
type: array
6674
requestedIPCount:
75+
default: 0
6776
format: int64
6877
type: integer
6978
type: object
7079
status:
7180
description: NodeNetworkConfigStatus defines the observed state of NetworkConfig
7281
properties:
7382
assignedIPCount:
83+
default: 0
7484
type: integer
7585
networkContainers:
7686
items:
@@ -115,10 +125,12 @@ spec:
115125
subnetName:
116126
type: string
117127
type:
128+
default: vnet
118129
description: NCType is the specific type of network this NC
119130
represents.
120131
type: string
121132
version:
133+
default: 0
122134
format: int64
123135
type: integer
124136
vnetID:

0 commit comments

Comments
 (0)