Skip to content

Commit

Permalink
Support priority class for tidb cluster (#940)
Browse files Browse the repository at this point in the history
* addPriorityClassName

* chart template

* fix fmt

* Update charts/tidb-cluster/values.yaml

Co-Authored-By: weekface <weekface@gmail.com>

* Update values.yaml
  • Loading branch information
Yisaer authored and cofyc committed Sep 23, 2019
1 parent c0d1ecd commit 761daab
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 18 deletions.
9 changes: 9 additions & 0 deletions charts/tidb-cluster/templates/tidb-cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ spec:
hostNetwork: {{ .Values.pd.hostNetwork }}
podSecurityContext:
{{ toYaml .Values.pd.podSecurityContext | indent 6}}
{{- if .Values.pd.priorityClassName }}
priorityClassName: {{ .Values.pd.priorityClassName }}
{{- end }}
tikv:
replicas: {{ .Values.tikv.replicas }}
image: {{ .Values.tikv.image }}
Expand All @@ -75,6 +78,9 @@ spec:
hostNetwork: {{ .Values.tikv.hostNetwork }}
podSecurityContext:
{{ toYaml .Values.tikv.podSecurityContext | indent 6}}
{{- if .Values.tikv.priorityClassName }}
priorityClassName: {{ .Values.tikv.priorityClassName }}
{{- end }}
tidb:
replicas: {{ .Values.tidb.replicas }}
image: {{ .Values.tidb.image }}
Expand All @@ -97,6 +103,9 @@ spec:
hostNetwork: {{ .Values.tidb.hostNetwork }}
podSecurityContext:
{{ toYaml .Values.tidb.podSecurityContext | indent 6}}
{{- if .Values.tidb.priorityClassName }}
priorityClassName: {{ .Values.tidb.priorityClassName }}
{{- end }}
binlogEnabled: {{ .Values.binlog.pump.create | default false }}
maxFailoverCount: {{ .Values.tidb.maxFailoverCount | default 3 }}
separateSlowLog: {{ .Values.tidb.separateSlowLog | default false }}
Expand Down
12 changes: 12 additions & 0 deletions charts/tidb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ pd:
# refer to https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
podSecurityContext: {}

# Specify the priorityClassName for PD Pod.
# refer to https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#how-to-use-priority-and-preemption
priorityClassName: ""

tikv:
# Please refer to https://github.com/tikv/tikv/blob/master/etc/config-template.toml for the default
# tikv configurations (change to the tags of your tikv version),
Expand Down Expand Up @@ -252,6 +256,10 @@ tikv:
# refer to https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
podSecurityContext: {}

# Specify the priorityClassName for TiKV Pod.
# refer to https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#how-to-use-priority-and-preemption
priorityClassName: ""

tidb:
# Please refer to https://github.com/pingcap/tidb/blob/master/config/config.toml.example for the default
# tidb configurations(change to the tags of your tidb version),
Expand Down Expand Up @@ -322,6 +330,10 @@ tidb:
# refer to https://kubernetes.io/docs/tasks/configure-pod-container/security-context/#set-the-security-context-for-a-pod
podSecurityContext: {}

# Specify the priorityClassName for TiDB Pod.
# refer to https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#how-to-use-priority-and-preemption
priorityClassName: ""

maxFailoverCount: 3
service:
type: NodePort
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/pingcap.com/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ type PodAttributesSpec struct {
Annotations map[string]string `json:"annotations,omitempty"`
HostNetwork bool `json:"hostNetwork,omitempty"`
PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"`
PriorityClassName string `json:"priorityClassName,omitempty"`
}

// Service represent service type used in TidbCluster
Expand Down
9 changes: 5 additions & 4 deletions pkg/manager/member/pd_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,11 @@ func (pmm *pdMemberManager) getNewPDSetForTidbCluster(tc *v1alpha1.TidbCluster)
},
},
},
RestartPolicy: corev1.RestartPolicyAlways,
Tolerations: tc.Spec.PD.Tolerations,
Volumes: vols,
SecurityContext: tc.Spec.PD.PodSecurityContext,
RestartPolicy: corev1.RestartPolicyAlways,
Tolerations: tc.Spec.PD.Tolerations,
Volumes: vols,
SecurityContext: tc.Spec.PD.PodSecurityContext,
PriorityClassName: tc.Spec.PD.PriorityClassName,
},
},
VolumeClaimTemplates: []corev1.PersistentVolumeClaim{
Expand Down
21 changes: 11 additions & 10 deletions pkg/manager/member/tidb_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,16 +372,17 @@ func (tmm *tidbMemberManager) getNewTiDBSetForTidbCluster(tc *v1alpha1.TidbClust
Annotations: podAnnotations,
},
Spec: corev1.PodSpec{
SchedulerName: tc.Spec.SchedulerName,
Affinity: tc.Spec.TiDB.Affinity,
NodeSelector: tc.Spec.TiDB.NodeSelector,
HostNetwork: tc.Spec.TiDB.HostNetwork,
DNSPolicy: dnsPolicy,
Containers: containers,
RestartPolicy: corev1.RestartPolicyAlways,
Tolerations: tc.Spec.TiDB.Tolerations,
Volumes: vols,
SecurityContext: tc.Spec.TiDB.PodSecurityContext,
SchedulerName: tc.Spec.SchedulerName,
Affinity: tc.Spec.TiDB.Affinity,
NodeSelector: tc.Spec.TiDB.NodeSelector,
HostNetwork: tc.Spec.TiDB.HostNetwork,
DNSPolicy: dnsPolicy,
Containers: containers,
RestartPolicy: corev1.RestartPolicyAlways,
Tolerations: tc.Spec.TiDB.Tolerations,
Volumes: vols,
SecurityContext: tc.Spec.TiDB.PodSecurityContext,
PriorityClassName: tc.Spec.TiDB.PriorityClassName,
},
},
ServiceName: controller.TiDBPeerMemberName(tcName),
Expand Down
9 changes: 5 additions & 4 deletions pkg/manager/member/tikv_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,11 @@ func (tkmm *tikvMemberManager) getNewSetForTidbCluster(tc *v1alpha1.TidbCluster)
},
},
},
RestartPolicy: corev1.RestartPolicyAlways,
Tolerations: tc.Spec.TiKV.Tolerations,
Volumes: vols,
SecurityContext: tc.Spec.TiKV.PodSecurityContext,
RestartPolicy: corev1.RestartPolicyAlways,
Tolerations: tc.Spec.TiKV.Tolerations,
Volumes: vols,
SecurityContext: tc.Spec.TiKV.PodSecurityContext,
PriorityClassName: tc.Spec.TiKV.PriorityClassName,
},
},
VolumeClaimTemplates: []corev1.PersistentVolumeClaim{
Expand Down

0 comments on commit 761daab

Please sign in to comment.