Skip to content

Commit

Permalink
Add columns of kubectl outputs for Multi-cluster types (#3923)
Browse files Browse the repository at this point in the history
Signed-off-by: Jianjun Shen <shenj@vmware.com>
  • Loading branch information
jianjuns committed Jun 22, 2022
1 parent b2c245c commit f12f150
Show file tree
Hide file tree
Showing 17 changed files with 294 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ const (
// +genclient
//+kubebuilder:object:root=true

// ClusterClaim is the Schema for the clusterclaims API
// +kubebuilder:printcolumn:name="Value",type=string,JSONPath=`.value`,description="Value of the ClusterClaim"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`
// ClusterClaim is the Schema for the clusterclaims API.
type ClusterClaim struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ type ClusterInfoImportStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// +kubebuilder:printcolumn:name="Cluster ID",type=string,JSONPath=`.spec.clusterID`,description="Member Cluster ID"
// +kubebuilder:printcolumn:name="Service CIDR",type=string,JSONPath=`.spec.serviceCIDR`,description="Service CIDR of the cluster"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`
type ClusterInfoImport struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
10 changes: 7 additions & 3 deletions multicluster/apis/multicluster/v1alpha1/clusterset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ type ClusterSetSpec struct {
Members []MemberCluster `json:"members,omitempty"`
// Leaders include leader clusters known to the member clusters.
Leaders []MemberCluster `json:"leaders,omitempty"`
// Namespace to connect to in leader clusters.
// The leader cluster Namespace in which the ClusterSet is defined.
// Used in member cluster.
Namespace string `json:"namespace,omitempty"`
}
Expand Down Expand Up @@ -107,7 +107,7 @@ type ClusterStatus struct {

// ClusterSetStatus defines the observed state of ClusterSet.
type ClusterSetStatus struct {
// Total number of member clusters configured in the set.
// Total number of member clusters configured in the ClusterSet.
TotalClusters int32 `json:"totalClusters,omitempty"`
// Total number of clusters ready and connected.
ReadyClusters int32 `json:"readyClusters,omitempty"`
Expand All @@ -123,7 +123,11 @@ type ClusterSetStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// ClusterSet is the Schema for the clustersets API.
// +kubebuilder:printcolumn:name="Leader Cluster Namespace",type=string,JSONPath=`.spec.namespace`,description="The leader cluster Namespace for the ClusterSet"
// +kubebuilder:printcolumn:name="Total Clusters",type=string,JSONPath=`.status.totalClusters`,description="Total number of clusters in the ClusterSet"
// +kubebuilder:printcolumn:name="Ready Clusters",type=string,JSONPath=`.status.readyClusters`,description="Number of ready clusters in the ClusterSet"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`
// ClusterSet represents a ClusterSet.
type ClusterSet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand Down
8 changes: 5 additions & 3 deletions multicluster/apis/multicluster/v1alpha1/gateway_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,17 @@ type GatewayInfo struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// +kubebuilder:printcolumn:name="Gateway IP",type=string,JSONPath=`.gatewayIP`,description="Cross-cluster tunnel IP"
// +kubebuilder:printcolumn:name="Internal IP",type=string,JSONPath=`.internalIP`,description="In-cluster tunnel IP"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`
// Gateway includes information of a Multi-cluster Gateway.
type Gateway struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// Tunnel IP of the Gateway. It might be assigned by user manually
// through a Node annotation.
// Cross-cluster tunnel IP of the Gateway.
GatewayIP string `json:"gatewayIP,omitempty"`
// Internal tunnel IP of the Gateway.
// In-cluster tunnel IP of the Gateway.
InternalIP string `json:"internalIP,omitempty"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ import (
// +genclient
//+kubebuilder:object:root=true

// +kubebuilder:printcolumn:name="Cluster ID",type=string,JSONPath=`.spec.clusterID`,description="Cluster ID of the member cluster"
// +kubebuilder:printcolumn:name="ClusterSet ID",type=string,JSONPath=`.spec.clusterSetID`,description="ClusterSet ID"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`
// MemberClusterAnnounce is the Schema for the memberclusterannounces API
type MemberClusterAnnounce struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// ClusterID of the member cluster.
// Cluster ID of the member cluster.
ClusterID string `json:"clusterID,omitempty"`
// ClusterSet this member belongs to.
ClusterSetID string `json:"clusterSetID,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ const (

//+kubebuilder:object:root=true

// +kubebuilder:printcolumn:name="Gateway IP Precedence",type=string,JSONPath=`.gatewayIPPrecedence`,description="Precedence of Gateway IP types"
// +kubebuilder:printcolumn:name="Service CIDR",type=string,JSONPath=`.serviceCIDR`,description="Manually specified Service CIDR"
type MultiClusterConfig struct {
metav1.TypeMeta `json:",inline"`
// ControllerManagerConfigurationSpec returns the contfigurations for controllers.
// ControllerManagerConfigurationSpec defines the contfigurations for controllers.
config.ControllerManagerConfigurationSpec `json:",inline"`
// ServiceCIDR allows user to set the ClusterIP range of the cluster manually.
ServiceCIDR string `json:"serviceCIDR,omitempty"`
// The precedence about which IP (private or public one) of Node is preferred to
// be used as tunnel endpoint. if not specified, private IP will be chosen.
// The precedence about which IP address (internal or external IP) of Node is preferred to
// be used as the cross-cluster tunnel endpoint. if not specified, internal IP will be chosen.
GatewayIPPrecedence Precedence `json:"gatewayIPPrecedence,omitempty"`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ type ResourceExportStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// +kubebuilder:printcolumn:name="Cluster ID",type=string,JSONPath=`.spec.clusterID`,description="Cluster ID of the exporting cluster"
// +kubebuilder:printcolumn:name="Kind",type=string,JSONPath=`.spec.kind`,description="Kind of the exported resource"
// +kubebuilder:printcolumn:name="Namespace",type=string,JSONPath=`.spec.namespace`,description="Namespace of the exported resource"
// +kubebuilder:printcolumn:name="Name",type=string,JSONPath=`.spec.name`,description="Name of the exported resource"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=`.metadata.creationTimestamp`
// ResourceExport is the Schema for the resourceexports API.
type ResourceExport struct {
metav1.TypeMeta `json:",inline"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ type ResourceImportStatus struct {
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// +kubebuilder:printcolumn:name="Kind",type=string,JSONPath=`.spec.kind`,description="Kind of the imported resource"
// +kubebuilder:printcolumn:name="Namespace",type=string,JSONPath=`.spec.namespace`,description="Namespace of the imported resource"
// +kubebuilder:printcolumn:name="Name",type=string,JSONPath=`.spec.name`,description="Name of the imported resource"
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// ResourceImport is the Schema for the resourceimports API.
type ResourceImport struct {
metav1.TypeMeta `json:",inline"`
Expand Down
96 changes: 85 additions & 11 deletions multicluster/build/yamls/antrea-multicluster-leader-global.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,18 @@ spec:
singular: clusterclaim
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- description: Value of the ClusterClaim
jsonPath: .value
name: Value
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: ClusterClaim is the Schema for the clusterclaims API
description: ClusterClaim is the Schema for the clusterclaims API.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand All @@ -42,6 +50,7 @@ spec:
type: object
served: true
storage: true
subresources: {}
status:
acceptedNames:
kind: ""
Expand All @@ -67,10 +76,26 @@ spec:
singular: clusterset
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- description: The leader cluster Namespace for the ClusterSet
jsonPath: .spec.namespace
name: Leader Cluster Namespace
type: string
- description: Total number of clusters in the ClusterSet
jsonPath: .status.totalClusters
name: Total Clusters
type: string
- description: Number of ready clusters in the ClusterSet
jsonPath: .status.readyClusters
name: Ready Clusters
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: ClusterSet is the Schema for the clustersets API.
description: ClusterSet represents a ClusterSet.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
Expand Down Expand Up @@ -131,8 +156,8 @@ spec:
type: object
type: array
namespace:
description: Namespace to connect to in leader clusters. Used in member
cluster.
description: The leader cluster Namespace in which the ClusterSet
is defined. Used in member cluster.
type: string
type: object
status:
Expand Down Expand Up @@ -208,7 +233,7 @@ spec:
format: int32
type: integer
totalClusters:
description: Total number of member clusters configured in the set.
description: Total number of member clusters configured in the ClusterSet.
format: int32
type: integer
type: object
Expand Down Expand Up @@ -242,7 +267,19 @@ spec:
singular: memberclusterannounce
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- description: Cluster ID of the member cluster
jsonPath: .spec.clusterID
name: Cluster ID
type: string
- description: ClusterSet ID
jsonPath: .spec.clusterSetID
name: ClusterSet ID
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: MemberClusterAnnounce is the Schema for the memberclusterannounces
Expand All @@ -254,7 +291,7 @@ spec:
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
clusterID:
description: ClusterID of the member cluster.
description: Cluster ID of the member cluster.
type: string
clusterSetID:
description: ClusterSet this member belongs to.
Expand All @@ -272,6 +309,7 @@ spec:
type: object
served: true
storage: true
subresources: {}
status:
acceptedNames:
kind: ""
Expand All @@ -297,7 +335,27 @@ spec:
singular: resourceexport
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- description: Cluster ID of the exporting cluster
jsonPath: .spec.clusterID
name: Cluster ID
type: string
- description: Kind of the exported resource
jsonPath: .spec.kind
name: Kind
type: string
- description: Namespace of the exported resource
jsonPath: .spec.namespace
name: Namespace
type: string
- description: Name of the exported resource
jsonPath: .spec.name
name: Name
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: ResourceExport is the Schema for the resourceexports API.
Expand Down Expand Up @@ -3077,7 +3135,23 @@ spec:
singular: resourceimport
scope: Namespaced
versions:
- name: v1alpha1
- additionalPrinterColumns:
- description: Kind of the imported resource
jsonPath: .spec.kind
name: Kind
type: string
- description: Namespace of the imported resource
jsonPath: .spec.namespace
name: Namespace
type: string
- description: Name of the imported resource
jsonPath: .spec.name
name: Name
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: ResourceImport is the Schema for the resourceimports API.
Expand Down
Loading

0 comments on commit f12f150

Please sign in to comment.