Adapt IP address and external IP gathering

pull/582/head
Nemo 2020-06-20 14:48:34 +02:00
parent aaff76b9db
commit 318431cbc5
1 changed files with 18 additions and 23 deletions

View File

@ -4,10 +4,10 @@ Kubernetes components are stateless and store cluster state in [etcd](https://gi
## Prerequisites ## Prerequisites
The commands in this lab must be run on each controller instance: `controller-0`, `controller-1`, and `controller-2`. Login to each controller instance using the `gcloud` command. Example: The commands in this lab must be run on each controller instance: `controller-0`, `controller-1`, and `controller-2`. Login to each controller instance using the `ssh` command. Example for `controller-0`:
```bash ```bash
gcloud compute ssh controller-0 ssh controller-0
``` ```
### Running commands in parallel with tmux ### Running commands in parallel with tmux
@ -28,28 +28,25 @@ wget -q --show-progress --https-only --timestamping \
Extract and install the `etcd` server and the `etcdctl` command line utility: Extract and install the `etcd` server and the `etcdctl` command line utility:
```bash ```bash
{ tar -xvf etcd-v3.4.0-linux-amd64.tar.gz
tar -xvf etcd-v3.4.0-linux-amd64.tar.gz sudo mv etcd-v3.4.0-linux-amd64/etcd* /usr/local/bin/
sudo mv etcd-v3.4.0-linux-amd64/etcd* /usr/local/bin/
}
``` ```
### Configure the etcd Server ### Configure the etcd Server
```bash ```bash
{ sudo mkdir -p /etc/etcd /var/lib/etcd
sudo mkdir -p /etc/etcd /var/lib/etcd sudo cp ca.pem kubernetes-key.pem kubernetes.pem /etc/etcd/
sudo cp ca.pem kubernetes-key.pem kubernetes.pem /etc/etcd/
}
``` ```
The instance internal IP address will be used to serve client requests and communicate with etcd cluster peers. Retrieve the internal IP address for the current compute instance: The instance internal IP address will be used to serve client requests and communicate with etcd cluster peers. Define the INTERNAL_IP (replace MY_NODE_INTERNAL_IP by the value):
```bash ```bash
INTERNAL_IP=$(curl -s -H "Metadata-Flavor: Google" \ INTERNAL_IP=MY_NODE_INTERNAL_IP
http://metadata.google.internal/computeMetadata/v1/instance/network-interfaces/0/ip)
``` ```
> Example for controller-0 : 192.168.8.10
Each etcd member must have a unique name within an etcd cluster. Set the etcd name to match the hostname of the current compute instance: Each etcd member must have a unique name within an etcd cluster. Set the etcd name to match the hostname of the current compute instance:
```bash ```bash
@ -81,7 +78,7 @@ ExecStart=/usr/local/bin/etcd \\
--listen-client-urls https://${INTERNAL_IP}:2379,https://127.0.0.1:2379 \\ --listen-client-urls https://${INTERNAL_IP}:2379,https://127.0.0.1:2379 \\
--advertise-client-urls https://${INTERNAL_IP}:2379 \\ --advertise-client-urls https://${INTERNAL_IP}:2379 \\
--initial-cluster-token etcd-cluster-0 \\ --initial-cluster-token etcd-cluster-0 \\
--initial-cluster controller-0=https://10.240.0.10:2380,controller-1=https://10.240.0.11:2380,controller-2=https://10.240.0.12:2380 \\ --initial-cluster controller-0=https://192.168.8.10:2380,controller-1=https://192.168.8.11:2380,controller-2=https://192.168.8.12:2380 \\
--initial-cluster-state new \\ --initial-cluster-state new \\
--data-dir=/var/lib/etcd --data-dir=/var/lib/etcd
Restart=on-failure Restart=on-failure
@ -95,11 +92,9 @@ EOF
### Start the etcd Server ### Start the etcd Server
```bash ```bash
{ sudo systemctl daemon-reload
sudo systemctl daemon-reload sudo systemctl enable etcd
sudo systemctl enable etcd sudo systemctl start etcd
sudo systemctl start etcd
}
``` ```
> Remember to run the above commands on each controller node: `controller-0`, `controller-1`, and `controller-2`. > Remember to run the above commands on each controller node: `controller-0`, `controller-1`, and `controller-2`.
@ -116,12 +111,12 @@ sudo ETCDCTL_API=3 etcdctl member list \
--key=/etc/etcd/kubernetes-key.pem --key=/etc/etcd/kubernetes-key.pem
``` ```
> output > Output:
```bash ```bash
3a57933972cb5131, started, controller-2, https://10.240.0.12:2380, https://10.240.0.12:2379 3a57933972cb5131, started, controller-2, https://192.168.8.12:2380, https://192.168.8.12:2379
f98dc20bce6225a0, started, controller-0, https://10.240.0.10:2380, https://10.240.0.10:2379 f98dc20bce6225a0, started, controller-0, https://192.168.8.10:2380, https://192.168.8.10:2379
ffed16798470cab5, started, controller-1, https://10.240.0.11:2380, https://10.240.0.11:2379 ffed16798470cab5, started, controller-1, https://192.168.8.11:2380, https://192.168.8.11:2379
``` ```
Next: [Bootstrapping the Kubernetes Control Plane](08-bootstrapping-kubernetes-controllers.md) Next: [Bootstrapping the Kubernetes Control Plane](08-bootstrapping-kubernetes-controllers.md)