使用 kubeadm 安装的k8s集群,master节点的主机名能随便修改吗?
不建议修改 master 节点的主机名,因为 Kubernetes 集群中的许多组件都会使用主机名来进行通信和识别。
如果您修改了 master 节点的主机名,可能会导致某些组件无法正常工作,从而影响整个集群的健康状态。
如果您确实需要修改主机名,建议在修改前备份好相关配置文件,并且在修改后进行全面的测试和验证。
证书签发也跟主机名有关。
在 Kubernetes 集群中,每个节点都需要使用 TLS 证书来进行安全通信。
这些证书通常会包含节点的主机名信息,用于验证通信的身份。
如果您修改了节点的主机名,可能会导致证书无法正常验证,从而影响节点间的安全通信。
因此,在修改节点主机名时,还需要相应地更新证书信息,以确保节点间的安全通信能够正常工作。
$ openssl x509 -noout -text -in /etc/kubernetes/pki/apiserver.crt
$ hostnamectl
Static hostname: k8s-master01
Icon name: computer-vm
Chassis: vm
Machine ID: 4499357261994a4d9e3fe863c45cbdba
Boot ID: 3a81f540569a497585cdbf4db7576b8f
Virtualization: kvm
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-957.el7.x86_64
Architecture: x86-64
Certificate:
Data:
Version: 3 (0x2)
Serial Number: 2014944918723765793 (0x1bf685ba5a822621)
Signature Algorithm: sha256WithRSAEncryption
Issuer: CN=kubernetes
Validity
Not Before: Mar 3 09:13:52 2022 GMT
Not After : Feb 29 09:13:52 2032 GMT
Subject: CN=kube-apiserver
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Modulus:
00:c2:57:89:34:ea:ca:33:19:df:21:b1:83:c4:40:
54:06:78:3c:00:a8:e1:3c:bb:7e:d7:01:cf:d5:a3:
0d:93:38:9e:d7:e6:2a:3c:75:60:c0:d5:85:79:00:
8b:db:97:a3:3e:40:61:24:01:1c:ef:c2:5d:98:4c:
b4:c2:f9:67:f4:14:46:ef:30:20:b1:8d:90:4c:bb:
64:98:e6:ca:e3:a5:56:77:3e:fd:c0:46:b8:bc:eb:
8a:29:7a:2a:07:d0:d4:d7:3a:74:24:54:33:fe:e8:
ab:a5:9c:4c:c1:67:ac:51:54:92:00:59:8b:ba:90:
b1:41:b9:bb:71:ff:2a:02:16:15:ea:2c:2f:79:77:
3d:7b:b5:22:7d:12:69:53:41:58:b8:f4:e4:f7:32:
ae:0b:18:a8:02:be:cb:25:5a:be:46:0b:a3:e6:96:
48:13:d4:46:d2:1e:3c:a0:30:84:46:f7:52:37:66:
09:83:a7:5d:4f:06:c2:5b:b6:f0:81:5c:44:d7:96:
25:06:15:20:49:d8:07:11:88:62:86:02:83:71:41:
85:58:10:79:17:ea:38:4c:be:b1:bd:87:47:50:6e:
96:17:39:88:d2:63:e7:b5:23:65:53:2b:29:27:2d:
c9:81:e0:91:60:df:34:61:c3:c9:cd:9c:83:f5:45:
e2:7f
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Key Usage: critical
Digital Signature, Key Encipherment
X509v3 Extended Key Usage:
TLS Web Server Authentication
X509v3 Subject Alternative Name:
DNS:k8s-master01, DNS:kubernetes, DNS:kubernetes.default, DNS:kubernetes.default.svc, DNS:kubernetes.default.svc.cluster.local, IP Address:10.96.0.1, IP Address:192.168.32.118, IP
Signature Algorithm: sha256WithRSAEncryption
90:22:af:9c:e4:75:59:4d:a9:2e:c9:1f:42:4e:84:7d:49:89:
df:5b:72:60:f3:69:9b:94:ce:f1:33:3f:70:e6:19:b9:ae:8b:
c9:3a:80:31:20:af:0b:ed:f1:b6:48:6a:69:34:00:5a:3d:8e:
36:0a:e8:1e:9d:c1:93:dd:a1:fb:96:71:c4:db:6c:43:74:d2:
cc:73:d1:eb:5b:ad:b1:5c:64:e8:6e:5c:48:97:2c:23:a2:90:
c2:5f:99:96:c1:2e:73:54:b0:f9:7c:16:f5:eb:f5:d5:49:b1:
0c:3c:1a:82:f1:f9:d1:56:ae:78:1d:b2:13:50:9a:1e:29:03:
e0:38:8a:82:4f:09:01:2c:c2:93:0e:34:a1:23:e9:a1:5e:d8:
2d:bc:bc:9a:a0:35:dc:3d:11:55:57:c5:5a:bd:0b:8d:4d:e1:
53:c4:d3:c6:bb:2a:0a:a9:7c:0b:97:5d:f8:08:d7:34:1d:2d:
0d:39:5f:1f:3d:65:81:3f:14:78:51:ac:c7:7e:15:aa:ba:e4:
f3:e6:68:79:54:ac:5a:5b:86:47:4d:3f:97:e5:13:90:53:b6:
d4:39:89:34:e2:62:79:f0:75:1a:a8:15:1d:12:2b:5b:42:53:
fd:31:fb:49:c5:db:dd:2d:21:fe:98:33:70:a2:8f:31:76:7e:
fb:16:01:2b