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

Make Service port name configurable for tidb and pd service #1822

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
cdc9561
e2e case for clear TiDB failureMembers when scale TiDB to zero
mikechengwei Jan 25, 2020
1b4149b
increase timeout time
mikechengwei Jan 26, 2020
b659c07
optimize comment
mikechengwei Jan 26, 2020
08b16cf
optimize comment
mikechengwei Jan 26, 2020
f87e6f2
Merge branch 'master' of github.com:pingcap/tidb-operator into e2e-sc…
mikechengwei Feb 3, 2020
d9415cc
Merge branch 'master' of github.com:pingcap/tidb-operator
mikechengwei Feb 3, 2020
900a461
optimize code
mikechengwei Feb 3, 2020
14c1fce
Merge branch 'master' into e2e-scale-zero-tidb
mikechengwei Feb 3, 2020
faff123
move code from stability test to e2e test
mikechengwei Feb 3, 2020
09cb55c
Merge branch 'master' of github.com:pingcap/tidb-operator into e2e-sc…
mikechengwei Feb 3, 2020
3601da3
Merge remote-tracking branch 'origin/e2e-scale-zero-tidb' into e2e-sc…
mikechengwei Feb 3, 2020
bc5207d
optimize code
mikechengwei Feb 3, 2020
b94f225
Merge branch 'master' into e2e-scale-zero-tidb
mikechengwei Feb 3, 2020
e0f8e82
optimize code
mikechengwei Feb 3, 2020
ea123ae
Merge branch 'e2e-scale-zero-tidb' of github.com:tongcheng-elong/tidb…
mikechengwei Feb 3, 2020
4abdf94
Merge branch 'master' into e2e-scale-zero-tidb
mikechengwei Feb 4, 2020
4c4474f
optimize code
mikechengwei Feb 4, 2020
0b21bb5
Merge branch 'master' of github.com:pingcap/tidb-operator into e2e-sc…
mikechengwei Feb 4, 2020
7586944
Merge branch 'e2e-scale-zero-tidb' of github.com:tongcheng-elong/tidb…
mikechengwei Feb 4, 2020
cf207d4
optimize code
mikechengwei Feb 4, 2020
493dd0a
optimize code
mikechengwei Feb 4, 2020
04d0248
optimize code
mikechengwei Feb 5, 2020
d6e6d28
Merge branch 'master' into e2e-scale-zero-tidb
mikechengwei Feb 5, 2020
8fcf9dc
change wait poll time
mikechengwei Feb 5, 2020
d2c94b0
Merge branch 'e2e-scale-zero-tidb' of github.com:tongcheng-elong/tidb…
mikechengwei Feb 5, 2020
3b541f4
format code
mikechengwei Feb 5, 2020
95a111b
Merge branch 'master' into e2e-scale-zero-tidb
mikechengwei Feb 5, 2020
7e28703
rm interface
mikechengwei Feb 5, 2020
79cb13b
Merge branch 'e2e-scale-zero-tidb' of github.com:tongcheng-elong/tidb…
mikechengwei Feb 5, 2020
c110598
change to inline implement
mikechengwei Feb 5, 2020
8e174fb
change to inline implement
mikechengwei Feb 5, 2020
bfcf8a5
change to inline implement
mikechengwei Feb 5, 2020
58abc41
Merge branch 'master' of github.com:pingcap/tidb-operator into e2e-sc…
mikechengwei Feb 6, 2020
4ab21f9
e2elog.Fail/Failf replaced with e2elog.Log/Logf
mikechengwei Feb 10, 2020
211c98d
Merge branch 'master' of github.com:pingcap/tidb-operator into e2e-sc…
mikechengwei Feb 10, 2020
4e96524
optimize code
mikechengwei Feb 10, 2020
8c8bd62
Merge branch 'master' of github.com:pingcap/tidb-operator into e2e-sc…
mikechengwei Feb 24, 2020
6682272
feature:make Service port name configurable for tidb and pd service
mikechengwei Feb 28, 2020
b07d4e2
Merge branch 'master' of github.com:tongcheng-elong/tidb-operator int…
mikechengwei Feb 28, 2020
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
2 changes: 2 additions & 0 deletions charts/tidb-cluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ pd:
# we can only specify clusterIP and loadBalancerIP now
service:
clusterIP: "None"
portName: "None"

replicas: 3
image: pingcap/pd:v3.0.8
Expand Down Expand Up @@ -396,6 +397,7 @@ tidb:
service:
type: NodePort
exposeStatus: true
portName: None
# annotations:
# cloud.google.com/load-balancer-type: Internal
separateSlowLog: true
Expand Down
3 changes: 3 additions & 0 deletions pkg/manager/member/pd_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,9 @@ func (pmm *pdMemberManager) getNewPDServiceForTidbCluster(tc *v1alpha1.TidbClust
if svcSpec.ClusterIP != nil {
pdService.Spec.ClusterIP = *svcSpec.ClusterIP
}
if svcSpec.PortName != nil {
pdService.Spec.Ports[0].Name = *svcSpec.PortName
}
}
return pdService
}
Expand Down
64 changes: 64 additions & 0 deletions pkg/manager/member/pd_member_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,70 @@ func TestGetNewPdServiceForTidbCluster(t *testing.T) {
},
},
},
{
name: "basic and specify pd service portname",
tc: v1alpha1.TidbCluster{
ObjectMeta: metav1.ObjectMeta{
Name: "foo",
Namespace: "ns",
},
Spec: v1alpha1.TidbClusterSpec{
Services: []v1alpha1.Service{
{Name: "pd", Type: string(corev1.ServiceTypeLoadBalancer)},
},
PD: v1alpha1.PDSpec{
Service: &v1alpha1.ServiceSpec{Type: corev1.ServiceTypeClusterIP,
ClusterIP: pointer.StringPtr("172.20.10.1"),
PortName: pointer.StringPtr("http-pd"),
},
},
},
},
expected: corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: "foo-pd",
Namespace: "ns",
Labels: map[string]string{
"app.kubernetes.io/name": "tidb-cluster",
"app.kubernetes.io/managed-by": "tidb-operator",
"app.kubernetes.io/instance": "foo",
"app.kubernetes.io/component": "pd",
},
OwnerReferences: []metav1.OwnerReference{
{
APIVersion: "pingcap.com/v1alpha1",
Kind: "TidbCluster",
Name: "foo",
UID: "",
Controller: func(b bool) *bool {
return &b
}(true),
BlockOwnerDeletion: func(b bool) *bool {
return &b
}(true),
},
},
},
Spec: corev1.ServiceSpec{
ClusterIP: "172.20.10.1",
Type: corev1.ServiceTypeClusterIP,
Ports: []corev1.ServicePort{
{
Name: "http-pd",
Port: 2379,
TargetPort: intstr.FromInt(2379),
Protocol: corev1.ProtocolTCP,
},
},
Selector: map[string]string{
"app.kubernetes.io/name": "tidb-cluster",
"app.kubernetes.io/managed-by": "tidb-operator",
"app.kubernetes.io/instance": "foo",
"app.kubernetes.io/component": "pd",
},
},
},
},
}

for _, tt := range tests {
Expand Down
7 changes: 5 additions & 2 deletions pkg/manager/member/tidb_member_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -499,10 +499,13 @@ func getNewTiDBServiceOrNil(tc *v1alpha1.TidbCluster) *corev1.Service {
instanceName := tc.GetInstanceName()
tidbLabels := label.New().Instance(instanceName).TiDB().Labels()
svcName := controller.TiDBMemberName(tcName)

portName := "mysql-client"
if svcSpec.PortName != nil {
portName = *svcSpec.PortName
}
ports := []corev1.ServicePort{
{
Name: "mysql-client",
Name: portName,
Port: 4000,
TargetPort: intstr.FromInt(4000),
Protocol: corev1.ProtocolTCP,
Expand Down
16 changes: 16 additions & 0 deletions pkg/manager/member/tidb_member_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,22 @@ func TestTiDBMemberManagerSyncTidbService(t *testing.T) {
g.Expect(svc.Spec.ClusterIP).To(Equal("8.8.8.8"))
},
},
{
name: "Create service with portName",
prepare: func(tc *v1alpha1.TidbCluster, _ *fakeIndexers) {
tc.Spec.TiDB.Service = &v1alpha1.TiDBServiceSpec{
ServiceSpec: v1alpha1.ServiceSpec{
Type: corev1.ServiceTypeClusterIP,
PortName: pointer.StringPtr("mysql-tidb"),
},
}
},
expectFn: func(g *GomegaWithT, err error, svc *corev1.Service) {
g.Expect(err).NotTo(HaveOccurred())
g.Expect(svc).NotTo(BeNil())
g.Expect(svc.Spec.Ports[0].Name).To(Equal("mysql-tidb"))
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down