You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 30, 2021. It is now read-only.
Add support for generating and using etcd TLS assets.
This change adds rendering options to allow the apiserver to connect
to etcd using TLS. This applies to both the temporary and self-hosted
control plane.
There are also some options (mostly intended for development) to help
generate the etcd (client/server) certificates. Obviously this is only
useful if etcd is not already up.
Self-hosted etcd is not supported at this time.
Copy file name to clipboardExpand all lines: cmd/bootkube/render.go
+77-19Lines changed: 77 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -18,11 +18,12 @@ import (
18
18
)
19
19
20
20
const (
21
-
apiOffset=1
22
-
dnsOffset=10
23
-
etcdOffset=15
24
-
defaultServiceBaseIP="10.3.0.0"
25
-
defaultEtcdServers="http://127.0.0.1:2379"
21
+
apiOffset=1
22
+
dnsOffset=10
23
+
etcdOffset=15
24
+
defaultServiceBaseIP="10.3.0.0"
25
+
defaultEtcdServers="http://127.0.0.1:2379"
26
+
defaultEtcdTLSServers="https://127.0.0.1:2379"
26
27
)
27
28
28
29
var (
@@ -36,17 +37,21 @@ var (
36
37
}
37
38
38
39
renderOptsstruct {
39
-
assetDirstring
40
-
caCertificatePathstring
41
-
caPrivateKeyPathstring
42
-
etcdServersstring
43
-
apiServersstring
44
-
altNamesstring
45
-
podCIDRstring
46
-
serviceCIDRstring
47
-
selfHostKubeletbool
48
-
cloudProviderstring
49
-
selfHostedEtcdbool
40
+
assetDirstring
41
+
caCertificatePathstring
42
+
caPrivateKeyPathstring
43
+
etcdCAPathstring
44
+
etcdCertificatePathstring
45
+
etcdPrivateKeyPathstring
46
+
etcdServersstring
47
+
etcdUseTLSbool
48
+
apiServersstring
49
+
altNamesstring
50
+
podCIDRstring
51
+
serviceCIDRstring
52
+
selfHostKubeletbool
53
+
cloudProviderstring
54
+
selfHostedEtcdbool
50
55
}
51
56
)
52
57
@@ -55,6 +60,9 @@ func init() {
55
60
cmdRender.Flags().StringVar(&renderOpts.assetDir, "asset-dir", "", "Output path for rendered assets")
56
61
cmdRender.Flags().StringVar(&renderOpts.caCertificatePath, "ca-certificate-path", "", "Path to an existing PEM encoded CA. If provided, TLS assets will be generated using this certificate authority.")
57
62
cmdRender.Flags().StringVar(&renderOpts.caPrivateKeyPath, "ca-private-key-path", "", "Path to an existing Certificate Authority RSA private key. Required if --ca-certificate is set.")
63
+
cmdRender.Flags().StringVar(&renderOpts.etcdCAPath, "etcd-ca-path", "", "Path to an existing PEM encoded CA that will be used for TLS-enabled communication between the apiserver and etcd. Must be used in conjunction with --etcd-certificate-path and --etcd-private-key-path, and must have etcd configured to use TLS with matching secrets.")
64
+
cmdRender.Flags().StringVar(&renderOpts.etcdCertificatePath, "etcd-certificate-path", "", "Path to an existing server certificate that will be used for TLS-enabled communication between the apiserver and etcd. Must be used in conjunction with --etcd-ca-path and --etcd-private-key-path, and must have etcd configured to use TLS with matching secrets.")
65
+
cmdRender.Flags().StringVar(&renderOpts.etcdPrivateKeyPath, "etcd-private-key-path", "", "Path to an existing server private key that will be used for TLS-enabled communication between the apiserver and etcd. Must be used in conjunction with --etcd-ca-path and --etcd-certificate-path, and must have etcd configured to use TLS with matching secrets.")
58
66
cmdRender.Flags().StringVar(&renderOpts.etcdServers, "etcd-servers", defaultEtcdServers, "List of etcd servers URLs including host:port, comma separated")
59
67
cmdRender.Flags().StringVar(&renderOpts.apiServers, "api-servers", "https://127.0.0.1:443", "List of API server URLs including host:port, commma seprated")
60
68
cmdRender.Flags().StringVar(&renderOpts.altNames, "api-server-alt-names", "", "List of SANs to use in api-server certificate. Example: 'IP=127.0.0.1,IP=127.0.0.2,DNS=localhost'. If empty, SANs will be extracted from the --api-servers flag.")
@@ -63,6 +71,7 @@ func init() {
63
71
cmdRender.Flags().BoolVar(&renderOpts.selfHostKubelet, "experimental-self-hosted-kubelet", false, "(Experimental) Create a self-hosted kubelet daemonset.")
64
72
cmdRender.Flags().StringVar(&renderOpts.cloudProvider, "cloud-provider", "", "The provider for cloud services. Empty string for no provider")
cmdRender.Flags().BoolVar(&renderOpts.etcdUseTLS, "etcd-use-tls", false, "If true, uses TLS for etcd. Implicitly true if --etcd-ca-path,--etcd-certificate-path,--etcd-private-key-path are set. If true but those flags are not set etcd TLS certificates will be generated. Not supported if --experimental-self-hosted-etcd=true.")
returnerrors.New("You must provide the --ca-certificate-path flag when --ca-private-key-path is provided.")
88
97
}
98
+
if (renderOpts.etcdCAPath!=""||renderOpts.etcdCertificatePath!=""||renderOpts.etcdPrivateKeyPath!="") && (renderOpts.etcdCAPath==""||renderOpts.etcdCertificatePath==""||renderOpts.etcdPrivateKeyPath=="") {
99
+
returnerrors.New("You must specify either all or none of --etcd-ca-path, --etcd-certificate-path, and --etcd-private-key-path")
// TODO: Find better option than asking users to make manual changes
173
219
ifserviceNet.IP.String() !=defaultServiceBaseIP {
174
220
fmt.Printf("You have selected a non-default service CIDR %s - be sure your kubelet service file uses --cluster-dns=%s\n", serviceNet.String(), dnsServiceIP.String())
0 commit comments