Skip to content

Commit

Permalink
add tidbinitializer crd (#1391)
Browse files Browse the repository at this point in the history
* add tidbinitializer crd

Signed-off-by: Aylei <rayingecho@gmail.com>
  • Loading branch information
aylei authored and Yisaer committed Dec 22, 2019
1 parent 90ead3d commit c781ba1
Show file tree
Hide file tree
Showing 18 changed files with 1,106 additions and 22 deletions.
10 changes: 1 addition & 9 deletions charts/tidb-operator/templates/controller-manager-rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,7 @@ rules:
resources: ["statefulsets","deployments"]
verbs: ["*"]
- apiGroups: ["pingcap.com"]
resources:
- tidbclusters
- tidbclusters/finalizers
- backups
- backups/finalizers
- backupschedules
- backupschedules/finalizers
- restores
- restores/finalizers
resources: ["*"]
verbs: ["*"]
{{- if .Values.features | has "AdvancedStatefulSet=true" }}
- apiGroups:
Expand Down
1 change: 1 addition & 0 deletions hack/crd-groups.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function generate_crd {
$1/bin/to-crdgen generate restore >> $2
$1/bin/to-crdgen generate backupschedule >> $2
$1/bin/to-crdgen generate tidbmonitor >> $2
$1/bin/to-crdgen generate tidbinitializer >> $2
}

if test $ACTION == 'generate' ;then
Expand Down
98 changes: 98 additions & 0 deletions manifests/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3183,3 +3183,101 @@ spec:
type: object
type: object
version: v1alpha1
---
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
creationTimestamp: null
name: tidbinitializers.pingcap.com
spec:
additionalPrinterColumns:
- JSONPath: .status.phase
description: The current phase of initialization
name: Phase
priority: 1
type: string
group: pingcap.com
names:
kind: TidbInitializer
plural: tidbinitializers
shortNames:
- ti
scope: Namespaced
validation:
openAPIV3Schema:
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
spec:
description: TidbInitializer spec encode the desired state of tidb initializer
Job
properties:
cluster:
description: TidbClusterRef reference to a TidbCluster
properties:
name:
description: Name is the name of TidbCluster object
type: string
namespace:
description: Namespace is the namespace that TidbCluster object
locates, default to the same namespace with TidbMonitor
type: string
required:
- name
type: object
image:
type: string
imagePullPolicy:
type: string
initSql:
description: InitSql is the SQL statements executed after the TiDB cluster
is bootstrapped.
type: string
initSqlConfigMap:
description: LocalObjectReference contains enough information to let
you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
type: object
passwordSecret:
description: LocalObjectReference contains enough information to let
you locate the referenced object inside the same namespace.
properties:
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
type: object
permitHost:
description: permitHost is the host which will only be allowed to connect
to the TiDB.
type: string
resources:
description: ResourceRequirements describes the compute resource requirements.
properties:
limits:
description: 'Limits describes the maximum amount of compute resources
allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
requests:
description: 'Requests describes the minimum amount of compute resources
required. If Requests is omitted for a container, it defaults
to Limits if that is explicitly specified, otherwise to an implementation-defined
value. More info: https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/'
type: object
type: object
required:
- image
- cluster
type: object
type: object
version: v1alpha1
30 changes: 18 additions & 12 deletions pkg/apis/pingcap/v1alpha1/crd_kinds.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const (
TiDBMonitorKind = "TidbMonitor"
TiDBMonitorKindKey = "tidbmonitor"

TiDBInitializerName = "tidbinitializers"
TiDBInitializerKind = "TidbInitializer"
TiDBInitializerKindKey = "tidbinitializer"

SpecPath = "github.com/pingcap/tidb-operator/pkg/apis/pingcap/v1alpha1."
)

Expand All @@ -53,19 +57,21 @@ type CrdKind struct {
}

type CrdKinds struct {
KindsString string
TiDBCluster CrdKind
Backup CrdKind
Restore CrdKind
BackupSchedule CrdKind
TiDBMonitor CrdKind
KindsString string
TiDBCluster CrdKind
Backup CrdKind
Restore CrdKind
BackupSchedule CrdKind
TiDBMonitor CrdKind
TiDBInitializer CrdKind
}

var DefaultCrdKinds = CrdKinds{
KindsString: "",
TiDBCluster: CrdKind{Plural: TiDBClusterName, Kind: TiDBClusterKind, ShortNames: []string{"tc"}, SpecName: SpecPath + TiDBClusterKind},
Backup: CrdKind{Plural: BackupName, Kind: BackupKind, ShortNames: []string{"bk"}, SpecName: SpecPath + BackupKind},
Restore: CrdKind{Plural: RestoreName, Kind: RestoreKind, ShortNames: []string{"rt"}, SpecName: SpecPath + RestoreKind},
BackupSchedule: CrdKind{Plural: BackupScheduleName, Kind: BackupScheduleKind, ShortNames: []string{"bks"}, SpecName: SpecPath + BackupScheduleKind},
TiDBMonitor: CrdKind{Plural: TiDBMonitorName, Kind: TiDBMonitorKind, ShortNames: []string{}, SpecName: SpecPath + TiDBMonitorKind},
KindsString: "",
TiDBCluster: CrdKind{Plural: TiDBClusterName, Kind: TiDBClusterKind, ShortNames: []string{"tc"}, SpecName: SpecPath + TiDBClusterKind},
Backup: CrdKind{Plural: BackupName, Kind: BackupKind, ShortNames: []string{"bk"}, SpecName: SpecPath + BackupKind},
Restore: CrdKind{Plural: RestoreName, Kind: RestoreKind, ShortNames: []string{"rt"}, SpecName: SpecPath + RestoreKind},
BackupSchedule: CrdKind{Plural: BackupScheduleName, Kind: BackupScheduleKind, ShortNames: []string{"bks"}, SpecName: SpecPath + BackupScheduleKind},
TiDBMonitor: CrdKind{Plural: TiDBMonitorName, Kind: TiDBMonitorKind, ShortNames: []string{}, SpecName: SpecPath + TiDBMonitorKind},
TiDBInitializer: CrdKind{Plural: TiDBInitializerName, Kind: TiDBInitializerKind, ShortNames: []string{"ti"}, SpecName: SpecPath + TiDBInitializerKind},
}
Loading

0 comments on commit c781ba1

Please sign in to comment.