Skip to content

Commit 938643c

Browse files
authored
Merge pull request #1277 from randomvariable/kubectl-get-awsmachine-info
✨ Add printer columns
2 parents 6fbf994 + 644d254 commit 938643c

4 files changed

+55
-2
lines changed

api/v1alpha3/awscluster_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ type AWSClusterStatus struct {
6868
// +kubebuilder:resource:path=awsclusters,scope=Namespaced,categories=cluster-api
6969
// +kubebuilder:storageversion
7070
// +kubebuilder:subresource:status
71+
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this AWSCluster belongs"
72+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Cluster infrastructure is ready for EC2 instances"
73+
// +kubebuilder:printcolumn:name="VPC",type="string",JSONPath=".spec.networkSpec.vpc.id",description="AWS VPC the cluster is using"
74+
// +kubebuilder:printcolumn:name="Endpoint",type="string",JSONPath=".status.apiEndpoints[0]",description="API Endpoint",priority=1
75+
// +kubebuilder:printcolumn:name="Bastion IP",type="string",JSONPath=".status.bastion.publicIp",description="Bastion IP address for breakglass access"
7176

7277
// AWSCluster is the Schema for the awsclusters API
7378
type AWSCluster struct {

api/v1alpha3/awsmachine_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ type AWSMachineStatus struct {
146146
// +kubebuilder:resource:path=awsmachines,scope=Namespaced,categories=cluster-api
147147
// +kubebuilder:storageversion
148148
// +kubebuilder:subresource:status
149+
// +kubebuilder:printcolumn:name="Cluster",type="string",JSONPath=".metadata.labels.cluster\\.x-k8s\\.io/cluster-name",description="Cluster to which this AWSMachine belongs"
150+
// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.instanceState",description="EC2 instance state"
151+
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Machine ready status"
152+
// +kubebuilder:printcolumn:name="InstanceID",type="string",JSONPath=".spec.providerID",description="EC2 instance ID"
153+
// +kubebuilder:printcolumn:name="Machine",type="string",JSONPath=".metadata.ownerReferences[?(@.kind==\"Machine\")].name",description="Machine object which owns with this AWSMachine"
149154

150155
// AWSMachine is the Schema for the awsmachines API
151156
type AWSMachine struct {

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,29 @@ spec:
396396
- name: v1alpha2
397397
served: true
398398
storage: false
399-
- name: v1alpha3
399+
- additionalPrinterColumns:
400+
- JSONPath: .metadata.labels.cluster\.x-k8s\.io/cluster-name
401+
description: Cluster to which this AWSCluster belongs
402+
name: Cluster
403+
type: string
404+
- JSONPath: .status.ready
405+
description: Cluster infrastructure is ready for EC2 instances
406+
name: Ready
407+
type: string
408+
- JSONPath: .spec.networkSpec.vpc.id
409+
description: AWS VPC the cluster is using
410+
name: VPC
411+
type: string
412+
- JSONPath: .status.apiEndpoints[0]
413+
description: API Endpoint
414+
name: Endpoint
415+
priority: 1
416+
type: string
417+
- JSONPath: .status.bastion.publicIp
418+
description: Bastion IP address for breakglass access
419+
name: Bastion IP
420+
type: string
421+
name: v1alpha3
400422
served: true
401423
storage: true
402424
status:

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,28 @@ spec:
254254
- name: v1alpha2
255255
served: true
256256
storage: false
257-
- name: v1alpha3
257+
- additionalPrinterColumns:
258+
- JSONPath: .metadata.labels.cluster\.x-k8s\.io/cluster-name
259+
description: Cluster to which this AWSMachine belongs
260+
name: Cluster
261+
type: string
262+
- JSONPath: .status.instanceState
263+
description: EC2 instance state
264+
name: State
265+
type: string
266+
- JSONPath: .status.ready
267+
description: Machine ready status
268+
name: Ready
269+
type: string
270+
- JSONPath: .spec.providerID
271+
description: EC2 instance ID
272+
name: InstanceID
273+
type: string
274+
- JSONPath: .metadata.ownerReferences[?(@.kind=="Machine")].name
275+
description: Machine object which owns with this AWSMachine
276+
name: Machine
277+
type: string
278+
name: v1alpha3
258279
served: true
259280
storage: true
260281
status:

0 commit comments

Comments
 (0)