-
Notifications
You must be signed in to change notification settings - Fork 500
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
Auto generate and sign certificates for TLS enabled cluster #782
Changes from 50 commits
f31172f
5bb2384
99956b7
84cc8bd
71bf08d
ecfe87e
926073e
e4b319a
4da9be3
451011a
b6cd879
030a04c
b392aa2
4b27ddd
665e2fa
57ff597
d8e982e
4f9bea5
04a9b59
0602bb5
eea2feb
7d9d03b
990b357
8e5ba66
2d5dd87
f5cbf7f
93402b0
65f2567
d7eb4f4
8675b05
dfaa79b
813eb6b
6380c96
fc44046
8862e18
327b53b
ad7e4ad
a8d526c
9b7d18c
227def6
6eae832
12a60ea
5b2a1c3
78b2860
5a12d06
2aaa919
6a1dd49
2c95860
92a8e98
4525e37
ee807e9
fce4683
a243d90
0280899
f206b08
9c45b97
5c65005
d847d40
43578ee
0e455fe
1a7a78b
53d9656
2536060
3ddbe77
8dbb955
7067a6d
26edb7e
a80e244
deb628c
8bb8f53
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ detect-interval = {{ .Values.binlog.drainer.detectInterval | default 10 }} | |
data-dir = "/data" | ||
|
||
# a comma separated list of PD endpoints | ||
pd-urls = "http://{{ template "cluster.name" . }}-pd:2379" | ||
pd-urls = "{{ if .Values.enableTLSCluster }}https{{ else }}http{{ end }}://{{ template "cluster.name" . }}-pd:2379" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. define scheme as a var like: https://github.com/pingcap/tidb-operator/pull/782/files#diff-d636dd7eac2fffa04bb4a9d148d705afR27 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's an YAML template, not a shell script here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can define a |
||
|
||
# Use the specified compressor to compress payload between pump and drainer | ||
compressor = "" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ data-dir = "/data" | |
heartbeat-interval = {{ .Values.binlog.pump.heartbeatInterval | default 2 }} | ||
|
||
# a comma separated list of PD endpoints | ||
pd-urls = "http://{{ template "cluster.name" . }}-pd:2379" | ||
pd-urls = "{{ if .Values.enableTLSCluster }}https{{ else }}http{{ end }}://{{ template "cluster.name" . }}-pd:2379" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
|
||
#[security] | ||
# Path of file that contains list of trusted SSL CAs for connection with cluster components. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,4 +45,3 @@ spec: | |
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,6 +136,10 @@ func main() { | |
} | ||
|
||
tcController := tidbcluster.NewController(kubeCli, cli, informerFactory, kubeInformerFactory, autoFailover, pdFailoverPeriod, tikvFailoverPeriod, tidbFailoverPeriod) | ||
secControl := controller.NewRealSecretControl(kubeCli, kubeInformerFactory.Core().V1().Secrets().Lister()) | ||
certController := controller.NewRealCertControl(kubeCli, | ||
AstroProfundis marked this conversation as resolved.
Show resolved
Hide resolved
|
||
kubeInformerFactory.Certificates().V1beta1().CertificateSigningRequests().Lister(), | ||
secControl) | ||
backupController := backup.NewController(kubeCli, cli, informerFactory, kubeInformerFactory) | ||
restoreController := restore.NewController(kubeCli, cli, informerFactory, kubeInformerFactory) | ||
bsController := backupschedule.NewController(kubeCli, cli, informerFactory, kubeInformerFactory) | ||
|
@@ -145,6 +149,9 @@ func main() { | |
go kubeInformerFactory.Start(controllerCtx.Done()) | ||
|
||
onStarted := func(ctx context.Context) { | ||
if err := generateClientCert(ns, "tidb-operator", certController); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I recommend creating the operator client certificate in the tidb-operator installation. |
||
return | ||
} | ||
go wait.Forever(func() { backupController.Run(workers, ctx.Done()) }, waitDuration) | ||
go wait.Forever(func() { restoreController.Run(workers, ctx.Done()) }, waitDuration) | ||
go wait.Forever(func() { bsController.Run(workers, ctx.Done()) }, waitDuration) | ||
|
@@ -170,3 +177,25 @@ func main() { | |
|
||
glog.Fatal(http.ListenAndServe(":6060", nil)) | ||
} | ||
|
||
func generateClientCert(ns string, commonName string, certController controller.CertControlInterface) error { | ||
secretName := "tidb-operator-pd-client" | ||
if certController.CheckSecret(ns, secretName) { | ||
return nil | ||
} | ||
|
||
hostList := []string{ | ||
commonName, | ||
} | ||
|
||
certOpts := &controller.TiDBClusterCertOptions{ | ||
Namespace: ns, | ||
Instance: commonName, | ||
CommonName: commonName, | ||
HostList: hostList, | ||
Component: "tidb-operator", | ||
Suffix: "pd-client", | ||
} | ||
|
||
return certController.Create(certOpts) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refer #750 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
security
config section here is fragile, users may provide this section in the.Values.pd.config
too thus causing invalid configuration file.