Skip to content

Commit

Permalink
additionalPrinterColumns tidbautoscaler
Browse files Browse the repository at this point in the history
  • Loading branch information
shonge committed Mar 16, 2020
1 parent ecd980b commit 9c87ce2
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/basic/tidb-autoscaler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: pingcap.com/v1alpha1
kind: TidbClusterAutoScaler
metadata:
name: basic-autosacler
spec:
cluster:
name: basic
tidb:
maxReplicas: 5
minReplicas: 2
tikv:
maxReplicas: 5
minReplicas: 2
17 changes: 17 additions & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8932,6 +8932,23 @@ metadata:
creationTimestamp: null
name: tidbclusterautoscalers.pingcap.com
spec:
additionalPrinterColumns:
- JSONPath: .spec.tidb.maxReplicas
description: The max replicas number of TiDB cluster
name: TiDB-MaxReplicas
type: integer
- JSONPath: .spec.tidb.minReplicas
description: The Min replicas number of TiDB cluster
name: TiDB-MinReplicas
type: integer
- JSONPath: .spec.tikv.maxReplicas
description: The max replicas number of TiKV cluster
name: TiKV-MaxReplicas
type: integer
- JSONPath: .spec.tikv.minReplicas
description: The Min replicas number of TiKV cluster
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 max replicas number of TiKV cluster",
JSONPath: ".spec.tikv.maxReplicas",
}
autoScalerTiKVMinReplicasColumn = extensionsobj.CustomResourceColumnDefinition{
Name: "TiKV-MinReplicas",
Type: "integer",
Description: "The Min replicas number of TiKV cluster",
JSONPath: ".spec.tikv.minReplicas",
}
// TODO add The current replicas number of TiDB cluster
autoScalerTiDBMaxReplicasColumn = extensionsobj.CustomResourceColumnDefinition{
Name: "TiDB-MaxReplicas",
Type: "integer",
Description: "The max replicas number of TiDB cluster",
JSONPath: ".spec.tidb.maxReplicas",
}
autoScalerTiDBMinReplicasColumn = extensionsobj.CustomResourceColumnDefinition{
Name: "TiDB-MinReplicas",
Type: "integer",
Description: "The Min replicas number of TiDB cluster",
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 9c87ce2

Please sign in to comment.