additional printer columns for CRDs
This commit is contained in:
parent
7715e58da0
commit
a22d510595
|
|
@ -18,6 +18,26 @@ spec:
|
||||||
singular: postgresql
|
singular: postgresql
|
||||||
shortNames:
|
shortNames:
|
||||||
- pg
|
- pg
|
||||||
|
additionalPrinterColumns:
|
||||||
|
- name: Team
|
||||||
|
type: string
|
||||||
|
description: Team responsible for Postgres CLuster
|
||||||
|
JSONPath: .spec.teamId
|
||||||
|
- name: Status
|
||||||
|
type: string
|
||||||
|
description: Current status of Postgres cluster
|
||||||
|
JSONPath: .status.PostgresClusterStatus
|
||||||
|
- name: Instances
|
||||||
|
type: integer
|
||||||
|
description: Number of instances per Postgres cluster
|
||||||
|
JSONPath: .spec.numberOfInstances
|
||||||
|
- name: Volume
|
||||||
|
type: string
|
||||||
|
description: Size of the bound volume
|
||||||
|
JSONPath: .spec.volume.size
|
||||||
|
- name: Age
|
||||||
|
type: date
|
||||||
|
JSONPath: .metadata.creationTimestamp
|
||||||
scope: Namespaced
|
scope: Namespaced
|
||||||
subresources:
|
subresources:
|
||||||
status: {}
|
status: {}
|
||||||
|
|
@ -42,7 +62,27 @@ spec:
|
||||||
plural: operatorconfigurations
|
plural: operatorconfigurations
|
||||||
singular: operatorconfiguration
|
singular: operatorconfiguration
|
||||||
shortNames:
|
shortNames:
|
||||||
- pgc
|
- opconfig
|
||||||
|
additionalPrinterColumns:
|
||||||
|
- name: Image
|
||||||
|
type: string
|
||||||
|
description: Spilo image to be used for Pods
|
||||||
|
JSONPath: .configuration.docker_image
|
||||||
|
- name: Cluster-Label
|
||||||
|
type: string
|
||||||
|
description: Label for K8s resources created by operator
|
||||||
|
JSONPath: .configuration.kubernetes.cluster_name_label
|
||||||
|
- name: Service-Account
|
||||||
|
type: string
|
||||||
|
description: Name of service account to be used
|
||||||
|
JSONPath: .configuration.kubernetes.pod_service_account_name
|
||||||
|
- name: Min-Instances
|
||||||
|
type: integer
|
||||||
|
description: Minimum number of instances per Postgres cluster
|
||||||
|
JSONPath: .configuration.min_instances
|
||||||
|
- name: Age
|
||||||
|
type: date
|
||||||
|
JSONPath: .metadata.creationTimestamp
|
||||||
scope: Namespaced
|
scope: Namespaced
|
||||||
subresources:
|
subresources:
|
||||||
status: {}
|
status: {}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,73 @@ const (
|
||||||
OperatorConfigCRDResourceShort = "opconfig"
|
OperatorConfigCRDResourceShort = "opconfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
func buildCRD(name, kind, plural, short string) *apiextv1beta1.CustomResourceDefinition {
|
// PostgresCRDResourceColumns definition of AdditionalPrinterColumns for postgresql CRD
|
||||||
|
var PostgresCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
Name: "Team",
|
||||||
|
Type: "string",
|
||||||
|
Description: "Team responsible for Postgres cluster",
|
||||||
|
JSONPath: ".spec.teamId",
|
||||||
|
},
|
||||||
|
apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
Name: "Status",
|
||||||
|
Type: "string",
|
||||||
|
Description: "Current status of Postgres cluster",
|
||||||
|
JSONPath: ".status.PostgresClusterStatus",
|
||||||
|
},
|
||||||
|
apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
Name: "Instances",
|
||||||
|
Type: "integer",
|
||||||
|
Description: "Number of instances per Postgres cluster",
|
||||||
|
JSONPath: ".spec.numberOfInstances",
|
||||||
|
},
|
||||||
|
apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
Name: "Volume",
|
||||||
|
Type: "string",
|
||||||
|
Description: "Size of the bound volume",
|
||||||
|
JSONPath: ".spec.volume.size",
|
||||||
|
},
|
||||||
|
apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
Name: "Age",
|
||||||
|
Type: "date",
|
||||||
|
JSONPath: ".metadata.creationTimestamp",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperatorConfigCRDResourceColumns definition of AdditionalPrinterColumns for OperatorConfiguration CRD
|
||||||
|
var OperatorConfigCRDResourceColumns = []apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
Name: "Image",
|
||||||
|
Type: "string",
|
||||||
|
Description: "Spilo image to be used for Pods",
|
||||||
|
JSONPath: ".configuration.docker_image",
|
||||||
|
},
|
||||||
|
apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
Name: "Cluster-Label",
|
||||||
|
Type: "string",
|
||||||
|
Description: "Label for K8s resources created by operator",
|
||||||
|
JSONPath: ".configuration.kubernetes.cluster_name_label",
|
||||||
|
},
|
||||||
|
apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
Name: "Service-Account",
|
||||||
|
Type: "string",
|
||||||
|
Description: "Name of service account to be used",
|
||||||
|
JSONPath: ".configuration.kubernetes.pod_service_account_name",
|
||||||
|
},
|
||||||
|
apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
Name: "Min-Instances",
|
||||||
|
Type: "integer",
|
||||||
|
Description: "Minimum number of instances per Postgres cluster",
|
||||||
|
JSONPath: ".configuration.min_instances",
|
||||||
|
},
|
||||||
|
apiextv1beta1.CustomResourceColumnDefinition{
|
||||||
|
Name: "Age",
|
||||||
|
Type: "date",
|
||||||
|
JSONPath: ".metadata.creationTimestamp",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func buildCRD(name, kind, plural, short string, columns []apiextv1beta1.CustomResourceColumnDefinition) *apiextv1beta1.CustomResourceDefinition {
|
||||||
return &apiextv1beta1.CustomResourceDefinition{
|
return &apiextv1beta1.CustomResourceDefinition{
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
Name: name,
|
Name: name,
|
||||||
|
|
@ -36,6 +102,7 @@ func buildCRD(name, kind, plural, short string) *apiextv1beta1.CustomResourceDef
|
||||||
Subresources: &apiextv1beta1.CustomResourceSubresources{
|
Subresources: &apiextv1beta1.CustomResourceSubresources{
|
||||||
Status: &apiextv1beta1.CustomResourceSubresourceStatus{},
|
Status: &apiextv1beta1.CustomResourceSubresourceStatus{},
|
||||||
},
|
},
|
||||||
|
AdditionalPrinterColumns: columns,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +112,8 @@ func PostgresCRD() *apiextv1beta1.CustomResourceDefinition {
|
||||||
return buildCRD(PostgresCRDResouceName,
|
return buildCRD(PostgresCRDResouceName,
|
||||||
PostgresCRDResourceKind,
|
PostgresCRDResourceKind,
|
||||||
PostgresCRDResourcePlural,
|
PostgresCRDResourcePlural,
|
||||||
PostgresCRDResourceShort)
|
PostgresCRDResourceShort,
|
||||||
|
PostgresCRDResourceColumns)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ConfigurationCRD returns CustomResourceDefinition built from OperatorConfigCRDResource
|
// ConfigurationCRD returns CustomResourceDefinition built from OperatorConfigCRDResource
|
||||||
|
|
@ -53,5 +121,6 @@ func ConfigurationCRD() *apiextv1beta1.CustomResourceDefinition {
|
||||||
return buildCRD(OperatorConfigCRDResourceName,
|
return buildCRD(OperatorConfigCRDResourceName,
|
||||||
OperatorConfigCRDResouceKind,
|
OperatorConfigCRDResouceKind,
|
||||||
OperatorConfigCRDResourcePlural,
|
OperatorConfigCRDResourcePlural,
|
||||||
OperatorConfigCRDResourceShort)
|
OperatorConfigCRDResourceShort,
|
||||||
|
OperatorConfigCRDResourceColumns)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue