Skip to content

Commit

Permalink
UCP: additionalPrinterColumns tidbautoscaler (#1943)
Browse files Browse the repository at this point in the history
  • Loading branch information
shonge authored Mar 25, 2020
1 parent f4acf0e commit 8a6521f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
17 changes: 17 additions & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9037,6 +9037,23 @@ metadata:
creationTimestamp: null
name: tidbclusterautoscalers.pingcap.com
spec:
additionalPrinterColumns:
- JSONPath: .spec.tidb.maxReplicas
description: The maximal replicas of TiDB
name: TiDB-MaxReplicas
type: integer
- JSONPath: .spec.tidb.minReplicas
description: The minimal replicas of TiDB
name: TiDB-MinReplicas
type: integer
- JSONPath: .spec.tikv.maxReplicas
description: The maximal replicas of TiKV
name: TiKV-MaxReplicas
type: integer
- JSONPath: .spec.tikv.minReplicas
description: The minimal replicas of TiKV
name: TiKV-MinReplicas
type: integer
group: pingcap.com
names:
kind: TidbClusterAutoScaler
Expand Down
31 changes: 31 additions & 0 deletions pkg/util/crdutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,33 @@ var (
Priority: 1,
JSONPath: ".status.phase",
}
autoScalerPrinterColumns []extensionsobj.CustomResourceColumnDefinition
// TODO add The current replicas number of TiKV cluster
autoScalerTiKVMaxReplicasColumn = extensionsobj.CustomResourceColumnDefinition{
Name: "TiKV-MaxReplicas",
Type: "integer",
Description: "The maximal replicas of TiKV",
JSONPath: ".spec.tikv.maxReplicas",
}
autoScalerTiKVMinReplicasColumn = extensionsobj.CustomResourceColumnDefinition{
Name: "TiKV-MinReplicas",
Type: "integer",
Description: "The minimal replicas of TiKV",
JSONPath: ".spec.tikv.minReplicas",
}
// TODO add The current replicas number of TiDB cluster
autoScalerTiDBMaxReplicasColumn = extensionsobj.CustomResourceColumnDefinition{
Name: "TiDB-MaxReplicas",
Type: "integer",
Description: "The maximal replicas of TiDB",
JSONPath: ".spec.tidb.maxReplicas",
}
autoScalerTiDBMinReplicasColumn = extensionsobj.CustomResourceColumnDefinition{
Name: "TiDB-MinReplicas",
Type: "integer",
Description: "The minimal replicas of TiDB",
JSONPath: ".spec.tidb.minReplicas",
}
)

func init() {
Expand All @@ -182,6 +209,8 @@ func init() {
restoreAdditionalPrinterColumns = append(restoreAdditionalPrinterColumns, restoreStartedColumn, restoreCompletedColumn)
bksAdditionalPrinterColumns = append(bksAdditionalPrinterColumns, bksScheduleColumn, bksMaxBackups, bksLastBackup, bksLastBackupTime)
tidbInitializerPrinterColumns = append(tidbInitializerPrinterColumns, tidbInitializerPhase)
autoScalerPrinterColumns = append(autoScalerPrinterColumns, autoScalerTiDBMaxReplicasColumn, autoScalerTiDBMinReplicasColumn,
autoScalerTiKVMaxReplicasColumn, autoScalerTiKVMinReplicasColumn)
}

func NewCustomResourceDefinition(crdKind v1alpha1.CrdKind, group string, labels map[string]string, validation bool) *extensionsobj.CustomResourceDefinition {
Expand Down Expand Up @@ -242,6 +271,8 @@ func addAdditionalPrinterColumnsForCRD(crd *extensionsobj.CustomResourceDefiniti
case v1alpha1.DefaultCrdKinds.TiDBInitializer.Kind:
crd.Spec.AdditionalPrinterColumns = tidbInitializerPrinterColumns
break
case v1alpha1.DefaultCrdKinds.TidbClusterAutoScaler.Kind:
crd.Spec.AdditionalPrinterColumns = autoScalerPrinterColumns
default:
break
}
Expand Down

0 comments on commit 8a6521f

Please sign in to comment.