Skip to content

Commit fd807a3

Browse files
authored
Merge pull request #1814 from prankul88/external-etcd-improvement
📖 External etcd doc improvement
2 parents 48b7f34 + f2cdbb5 commit fd807a3

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

bootstrap/kubeadm/docs/external-etcd.md

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Cluster API Bootstrap Provider Kubeadm supports using an external etcd cluster for your workload Kubernetes clusters.
44

5-
### ⚠️ Warnings ⚠️
5+
## ⚠️ Warnings ⚠️
66

77
Before getting started you should be aware of the expectations that come with using an external etcd cluster.
88

@@ -11,14 +11,38 @@ Before getting started you should be aware of the expectations that come with us
1111
* As an example, cross availability zone traffic can cost money on cloud providers. You don't have to deploy etcd
1212
across availability zones, but if you do please be aware of the costs.
1313

14-
### Getting started
14+
## Getting started
1515

1616
To use this, you will need to create an etcd cluster and generate an apiserver-etcd-client key/pair.
17-
[`etcdadm`](https://github.com/kubernetes-sigs/etcdadm) is a good way to get started if you'd like to test this
18-
behavior.
17+
This behaviour can be tested using [`kubeadm`](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/setup-ha-etcd-with-kubeadm/) and [`etcdadm`](https://github.com/kubernetes-sigs/etcdadm).
18+
19+
### Setting up etcd with kubeadm
1920

20-
Once you create an etcd cluster, you will want to base64 encode the `/etc/etcd/pki/apiserver-etcd-client.crt`,
21-
`/etc/etcd/pki/apiserver-etcd-client.key`, and `/etc/etcd/pki/server.crt` files and put them in two secrets. The secrets
21+
CA certificates are required to setup etcd cluster.
22+
If you already have a CA then the CA's `key` and `crt` must be copied to `/etc/kubernetes/pki/etcd/ca.crt` and `/etc/kubernetes/pki/etcd/ca.key`.
23+
24+
If you do not already have a CA then run command `kubeadm init phase certs etcd-ca`. This creates two files
25+
26+
* `/etc/kubernetes/pki/etcd/ca.crt`
27+
* `/etc/kubernetes/pki/etcd/ca.key`
28+
29+
These key/pair are used to sign etcd server, peer certificates and eventually apiserver-etcd client. More information on how to setup external etcd with kubeadm can be found [`here`](https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/setup-ha-etcd-with-kubeadm/#setting-up-the-cluster).
30+
31+
You would require files `/etc/kubernetes/pki/apiserver-etcd-client.key`, `/etc/kubernetes/pki/apiserver-etcd-client.crt` and `/etc/kubernetes/pki/etcd/server.crt` to setup etcd cluster. These are put in 2 secrets.
32+
33+
```
34+
# Kubernetes APIServer etcd client certificate
35+
$ kubectl create secret tls $CLUSTER_NAME-apiserver-etcd-client \
36+
--cert /etc/kubernetes/pki/apiserver-etcd-client.crt --key /etc/kubernetes/pki/apiserver-etcd-client.crt \
37+
--namespace $CLUSTER_NAMESPACE
38+
39+
# Etcd's CA crt file to validate the generated client certificates
40+
$ kubectl create secret tls $CLUSTER_NAME-etcd --cert /etc/kubernetes/pki/etcd/server.crt \
41+
--namespace $CLUSTER_NAMESPACE
42+
```
43+
**Note:** Above command has key/pair base64 encoded by default.
44+
45+
**Note:** Alternatively you can base64 encode the files and put them in two secrets. The secrets
2246
must be formatted as follows and the cert material must be base64 encoded:
2347

2448
```yaml
@@ -53,6 +77,14 @@ data:
5377
...
5478
```
5579
80+
### Setting up etcd with etcdadm (Alpha)
81+
`etcdadm` creates the CA if one does not exist, uses it to sign it's server and peer certificates, and finally to sign the apiserver etcd client certificate.
82+
CA's `key` and `crt` generated using `etcdadm` are stored in `/etc/etcd/pki/apiserver-etcd-client.crt`, `/etc/etcd/pki/apiserver-etcd-client.key` and `/etc/etcd/pki/server.crt` .
83+
84+
85+
Just like kubeadm, it is required to create 2 [`secrets`](https://kubernetes.io/docs/concepts/configuration/secret/#creating-a-secret-using-kubectl-create-secret) using these server and etcd client key/pair.
86+
87+
## Configuring CABPK
5688
After that the rest is standard Kubeadm. Config your ClusterConfiguration as follows:
5789

5890
```yaml

0 commit comments

Comments
 (0)