Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support adding additional pod annotations for PD/TiKV/TiDB #500

Merged
merged 6 commits into from
May 21, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions charts/tidb-cluster/templates/tidb-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ spec:
{{- if .Values.pd.tolerations }}
tolerations:
{{ toYaml .Values.pd.tolerations | indent 4 }}
{{- end }}
{{- if .Values.pd.annotations }}
annotations:
{{ toYaml .Values.pd.annotations | indent 6 }}
{{- end }}
tikv:
replicas: {{ .Values.tikv.replicas }}
Expand All @@ -60,6 +64,10 @@ spec:
{{- if .Values.tikv.tolerations }}
tolerations:
{{ toYaml .Values.tikv.tolerations | indent 4 }}
{{- end }}
{{- if .Values.tikv.annotations }}
annotations:
{{ toYaml .Values.tikv.annotations | indent 6 }}
{{- end }}
tidb:
replicas: {{ .Values.tidb.replicas }}
Expand All @@ -76,6 +84,10 @@ spec:
{{- if .Values.tidb.tolerations }}
tolerations:
{{ toYaml .Values.tidb.tolerations | indent 4 }}
{{- end }}
{{- if .Values.tidb.annotations }}
annotations:
{{ toYaml .Values.tidb.annotations | indent 6 }}
{{- end }}
binlogEnabled: {{ .Values.binlog.pump.create | default false }}
maxFailoverCount: {{ .Values.tidb.maxFailoverCount | default 3 }}
Expand Down
3 changes: 3 additions & 0 deletions charts/tidb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ pd:
# operator: Equal
# value: tidb
# effect: "NoSchedule"
annotations: {}

tikv:
replicas: 3
Expand Down Expand Up @@ -125,6 +126,7 @@ tikv:
# operator: Equal
# value: tidb
# effect: "NoSchedule"
annotations: {}

# block-cache used to cache uncompressed blocks, big block-cache can speed up read.
# in normal cases should tune to 30%-50% tikv.resources.limits.memory
Expand Down Expand Up @@ -203,6 +205,7 @@ tidb:
# operator: Equal
# value: tidb
# effect: "NoSchedule"
annotations: {}
maxFailoverCount: 3
service:
type: NodePort
Expand Down
3 changes: 3 additions & 0 deletions images/tidb-operator-e2e/tidb-cluster-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pd:
# operator: Equal
# value: tidb
# effect: "NoSchedule"
annotations: {}

tikv:
replicas: 3
Expand Down Expand Up @@ -106,6 +107,7 @@ tikv:
# operator: Equal
# value: tidb
# effect: "NoSchedule"
annotations: {}

tikvPromGateway:
image: prom/pushgateway:v0.3.1
Expand Down Expand Up @@ -146,6 +148,7 @@ tidb:
# operator: Equal
# value: tidb
# effect: "NoSchedule"
annotations: {}
maxFailoverCount: 3
service:
type: NodePort
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/pingcap.com/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ type PDSpec struct {
NodeSelectorRequired bool `json:"nodeSelectorRequired,omitempty"`
StorageClassName string `json:"storageClassName,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
}

// TiDBSpec contains details of PD member
Expand All @@ -122,6 +123,7 @@ type TiDBSpec struct {
NodeSelectorRequired bool `json:"nodeSelectorRequired,omitempty"`
StorageClassName string `json:"storageClassName,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
BinlogEnabled bool `json:"binlogEnabled,omitempty"`
MaxFailoverCount int32 `json:"maxFailoverCount,omitempty"`
SeparateSlowLog bool `json:"separateSlowLog,omitempty"`
Expand All @@ -141,6 +143,7 @@ type TiKVSpec struct {
NodeSelectorRequired bool `json:"nodeSelectorRequired,omitempty"`
StorageClassName string `json:"storageClassName,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Annotations map[string]string `json:"annotations,omitempty"`
}

// TiKVPromGatewaySpec runs as a sidecar with TiKVSpec
Expand Down
21 changes: 21 additions & 0 deletions pkg/apis/pingcap.com/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pkg/manager/member/pd_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ func (pmm *pdMemberManager) getNewPDSetForTidbCluster(tc *v1alpha1.TidbCluster)
}
pdLabel := label.New().Instance(instanceName).PD()
setName := controller.PDMemberName(tcName)
podAnnotations := CombineAnnotations(controller.AnnProm(2379), tc.Spec.PD.Annotations)
storageClassName := tc.Spec.PD.StorageClassName
if storageClassName == "" {
storageClassName = controller.DefaultStorageClassName
Expand All @@ -472,7 +473,7 @@ func (pmm *pdMemberManager) getNewPDSetForTidbCluster(tc *v1alpha1.TidbCluster)
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: pdLabel.Labels(),
Annotations: controller.AnnProm(2379),
Annotations: podAnnotations,
},
Spec: corev1.PodSpec{
SchedulerName: tc.Spec.SchedulerName,
Expand Down
3 changes: 2 additions & 1 deletion pkg/manager/member/tidb_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ func (tmm *tidbMemberManager) getNewTiDBSetForTidbCluster(tc *v1alpha1.TidbClust
})

tidbLabel := label.New().Instance(instanceName).TiDB()
podAnnotations := CombineAnnotations(controller.AnnProm(10080), tc.Spec.TiDB.Annotations)
tidbSet := &apps.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: controller.TiDBMemberName(tcName),
Expand All @@ -343,7 +344,7 @@ func (tmm *tidbMemberManager) getNewTiDBSetForTidbCluster(tc *v1alpha1.TidbClust
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: tidbLabel.Labels(),
Annotations: controller.AnnProm(10080),
Annotations: podAnnotations,
},
Spec: corev1.PodSpec{
SchedulerName: tc.Spec.SchedulerName,
Expand Down
3 changes: 2 additions & 1 deletion pkg/manager/member/tikv_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ func (tkmm *tikvMemberManager) getNewSetForTidbCluster(tc *v1alpha1.TidbCluster)

tikvLabel := tkmm.labelTiKV(tc)
setName := controller.TiKVMemberName(tcName)
podAnnotations := CombineAnnotations(controller.AnnProm(20180), tc.Spec.TiKV.Annotations)
capacity := controller.TiKVCapacity(tc.Spec.TiKV.Limits)
headlessSvcName := controller.TiKVPeerMemberName(tcName)
storageClassName := tc.Spec.TiKV.StorageClassName
Expand All @@ -331,7 +332,7 @@ func (tkmm *tikvMemberManager) getNewSetForTidbCluster(tc *v1alpha1.TidbCluster)
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: tikvLabel.Labels(),
Annotations: controller.AnnProm(20180),
Annotations: podAnnotations,
},
Spec: corev1.PodSpec{
SchedulerName: tc.Spec.SchedulerName,
Expand Down
11 changes: 11 additions & 0 deletions pkg/manager/member/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,14 @@ func pdPodName(tcName string, ordinal int32) string {
func tidbPodName(tcName string, ordinal int32) string {
return fmt.Sprintf("%s-%d", controller.TiDBMemberName(tcName), ordinal)
}

// CombineAnnotations merges two annotations maps
func CombineAnnotations(a, b map[string]string) map[string]string {
if a == nil {
a = make(map[string]string)
}
for k, v := range b {
a[k] = v
LinuxGit marked this conversation as resolved.
Show resolved Hide resolved
}
return a
}
LinuxGit marked this conversation as resolved.
Show resolved Hide resolved