mirror of
				https://github.com/kelseyhightower/kubernetes-the-hard-way.git
				synced 2025-11-04 10:12:35 +03:00 
			
		
		
		
	set kubelet hostname
This commit is contained in:
		@@ -105,9 +105,10 @@ Set the hostname on each machine listed in the `machines.txt` file:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
while read IP FQDN HOST SUBNET; do
 | 
					while read IP FQDN HOST SUBNET; do
 | 
				
			||||||
    CMD="sed -i 's/^127.0.0.1.*/127.0.0.1\t${FQDN} ${HOST} localhost/' /etc/hosts"
 | 
					    CMD="sed -i 's/^127.0.1.1.*/127.0.1.1\t${FQDN} ${HOST}/' /etc/hosts"
 | 
				
			||||||
    ssh -n root@${IP} "$CMD"
 | 
					    ssh -n root@${IP} "$CMD"
 | 
				
			||||||
    ssh -n root@${IP} hostnamectl hostname ${HOST}
 | 
					    ssh -n root@${IP} hostnamectl set-hostname ${HOST}
 | 
				
			||||||
 | 
					    ssh -n root@${IP} systemctl restart systemd-hostnamed
 | 
				
			||||||
done < machines.txt
 | 
					done < machines.txt
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -199,9 +200,9 @@ done
 | 
				
			|||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```text
 | 
					```text
 | 
				
			||||||
server aarch64 GNU/Linux
 | 
					server.kubernetes.local aarch64 GNU/Linux
 | 
				
			||||||
node-0 aarch64 GNU/Linux
 | 
					node-0.kubernetes.local aarch64 GNU/Linux
 | 
				
			||||||
node-1 aarch64 GNU/Linux
 | 
					node-1.kubernetes.local aarch64 GNU/Linux
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Adding `/etc/hosts` Entries To The Remote Machines
 | 
					## Adding `/etc/hosts` Entries To The Remote Machines
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -122,9 +122,28 @@ mv kube-scheduler.service /etc/systemd/system/
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
> Allow up to 10 seconds for the Kubernetes API Server to fully initialize.
 | 
					> Allow up to 10 seconds for the Kubernetes API Server to fully initialize.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					You can check if the Kubernetes API Server is active by running the following command:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					systemctl is-active kube-apiserver
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					For a more detailed status check run the following command:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					systemctl status kube-apiserver
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					If you run into any errors or want to view the logs run the following command:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					journalctl -u kube-apiserver --no-pager
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
### Verification
 | 
					### Verification
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					At this point the Kubernetes control plane components should be up and running. Verify this using the `kubectl` command line tool:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
kubectl cluster-info \
 | 
					kubectl cluster-info \
 | 
				
			||||||
  --kubeconfig admin.kubeconfig
 | 
					  --kubeconfig admin.kubeconfig
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -156,6 +156,16 @@ Create the `kubelet-config.yaml` configuration file:
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Check if the kubelet service is running:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```bash
 | 
				
			||||||
 | 
					systemctl is-active kubelet
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					```text
 | 
				
			||||||
 | 
					active
 | 
				
			||||||
 | 
					```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Be sure to complete the steps in this section on each worker node, `node-0` and `node-1`, before moving on to the next section.
 | 
					Be sure to complete the steps in this section on each worker node, `node-0` and `node-1`, before moving on to the next section.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Verification
 | 
					## Verification
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user