Skip to content

Commit 1300059

Browse files
Lin RuLin Ru
authored andcommitted
update
1 parent fbd4126 commit 1300059

27 files changed

+919
-97
lines changed

docker/trust-self-signed-certificates.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
yum install -y ca-certificates
99
```
1010

11-
12-
1311
2. 复制 CA 证书
1412

1513
```shell
@@ -29,7 +27,4 @@
2927

3028
```shell
3129
systemctl restart docker
32-
```
33-
34-
35-
30+
```

elasticsearch/secure-es-with-tls.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,13 @@ IP.3 = 10.10.20.153
7474
- IP 为 ES Node IP,不在列表中的IP将无法加入本集群
7575
对应配置为 `xpack.security.transport.ssl.verification_mode: full`
7676

77-
78-
7977
##### 生成 es-server Key
8078

8179
```shell
8280
openssl genrsa -out es-server.key 3072
8381
```
8482

8583

86-
8784
##### 生成 es-server 证书签发请求
8885

8986
```shell

keepalived/README.md

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@ dnf install -y keepalived
1616
global_defs {
1717
router_id nginx-ha-21
1818
}
19-
vrrp_sync_group VG_1 {
20-
group {
21-
VI_1
22-
}
23-
}
24-
vrrp_script nginx_check {
19+
20+
vrrp_script nginx_check
21+
{
2522
script "/usr/libexec/keepalived/check-nginx-status"
2623
interval 3
2724
}
28-
vrrp_instance VI_1 {
25+
26+
vrrp_instance vi_nginx {
2927
state MASTER
3028
interface eth0
3129
virtual_router_id 18
3230
priority 100
3331
advert_int 1
3432
authentication {
3533
auth_type PASS
36-
auth_pass 1111
34+
auth_pass h3m5Ewvk
3735
}
36+
3837
track_script {
3938
nginx_check weight 0
4039
}
40+
4141
virtual_ipaddress {
4242
192.168.20.18 dev eth0
4343
}
@@ -50,28 +50,28 @@ dnf install -y keepalived
5050
global_defs {
5151
router_id nginx-ha-22
5252
}
53-
vrrp_sync_group VG_1 {
54-
group {
55-
VI_1
56-
}
57-
}
58-
vrrp_script nginx_check {
53+
54+
vrrp_script nginx_check
55+
{
5956
script "/usr/libexec/keepalived/check-nginx-status"
6057
interval 3
6158
}
62-
vrrp_instance VI_1 {
59+
60+
vrrp_instance vi_nginx {
6361
state BACKUP
6462
interface eth0
6563
virtual_router_id 18
6664
priority 90
6765
advert_int 1
6866
authentication {
6967
auth_type PASS
70-
auth_pass 1111
68+
auth_pass h3m5Ewvk
7169
}
70+
7271
track_script {
7372
nginx_check weight 0
7473
}
74+
7575
virtual_ipaddress {
7676
192.168.20.18 dev eth0
7777
}
@@ -97,16 +97,27 @@ chmod 755 /usr/libexec/keepalived/check-nginx-status
9797
chcon -u system_u -t keepalived_unconfined_script_exec_t /usr/libexec/keepalived/check-nginx-status
9898
```
9999

100-
### 防火墙打开端口
100+
### 防火墙
101101

102+
##### 查看防火墙运行状态
102103
```shell
103-
firewall-cmd --direct --permanent --add-rule ipv4 filter INPUT 0 --destination 224.0.0.18 --protocol vrrp -j ACCEPT
104-
firewall-cmd --direct --permanent --add-rule ipv4 filter OUTPUT 0 --destination 224.0.0.18 --protocol vrrp -j ACCEPT
105-
firewall-cmd --zone public --add-port 6443/tcp --permanent
104+
firewall-cmd --state
105+
```
106+
107+
108+
##### 添加规则
109+
110+
```shell
111+
firewall-cmd --add-rich-rule='rule protocol value="vrrp" family=ipv4 destination address=224.0.0.18 accept' --permanent
106112
firewall-cmd --reload
107113
```
108114

109115

116+
##### 查看规则
117+
```shell
118+
firewall-cmd --list-all
119+
```
120+
110121
## 启动
111122

112123
```shell

kubernetes/install/091.config-kernel-parameters.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,15 @@
1010
modprobe ip_vs
1111
modprobe ip_vs_rr
1212
modprobe ip_vs_wrr
13+
modprobe ip_vs_lc
1314
modprobe ip_vs_wlc
1415
modprobe ip_vs_sh
16+
modprobe ip_vs_dh
17+
modprobe ip_vs_sed
18+
modprobe bridge
1519
modprobe overlay
20+
modprobe ip_tables
21+
modprobe iptable_filter
1622
modprobe br_netfilter
1723
modprobe nf_conntrack
1824
```
@@ -29,9 +35,15 @@ cat << EOF > /etc/modules-load.d/k8s_ipvs.conf
2935
ip_vs
3036
ip_vs_rr
3137
ip_vs_wrr
38+
ip_vs_lc
3239
ip_vs_wlc
3340
ip_vs_sh
41+
ip_vs_dh
42+
ip_vs_sed
43+
bridge
3444
overlay
45+
ip_tables
46+
iptable_filter
3547
br_netfilter
3648
nf_conntrack
3749
EOF
@@ -58,20 +70,12 @@ EOF
5870
fs.file-max = 1000000
5971
kernel.sysrq = 1
6072

61-
net.ipv4.neigh.default.gc_stale_time = 120
62-
net.ipv4.conf.all.rp_filter = 0
63-
net.ipv4.conf.default.rp_filter = 0
64-
net.ipv4.conf.default.arp_announce = 2
65-
net.ipv4.conf.lo.arp_announce = 2
66-
net.ipv4.conf.all.arp_announce = 2
67-
68-
net.ipv4.tcp_max_tw_buckets = 5000
69-
net.ipv4.tcp_syncookies = 1
70-
net.ipv4.tcp_max_syn_backlog = 1024
71-
net.ipv4.tcp_synack_retries = 2
72-
net.ipv4.tcp_slow_start_after_idle = 0
7373
net.ipv4.ip_forward = 1
7474

75+
net.netfilter.nf_conntrack_max = 2310720
76+
net.bridge.bridge-nf-call-iptables = 1
77+
net.bridge.bridge-nf-call-ip6tables = 1
78+
7579
vm.max_map_count = 500000
7680
vm.swappiness = 0
7781
```

kubernetes/install/101.install-etcd-cluster.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ yum install -y etcd
279279
ETCD_INITIAL_ADVERTISE_PEER_URLS="https://192.168.20.31:2380"
280280
ETCD_INITIAL_CLUSTER="etcd1=https://192.168.20.31:2380"
281281
ETCD_INITIAL_CLUSTER_STATE="new"
282+
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster"
282283
ETCD_ADVERTISE_CLIENT_URLS="https://192.168.20.31:2379"
283284
[security]
284285
ETCD_CERT_FILE="/etc/etcd/pki/etcd-server.pem"
@@ -313,7 +314,7 @@ WorkingDirectory=/var/lib/etcd/
313314
EnvironmentFile=-/etc/etcd/etcd.conf
314315
User=etcd
315316
316-
ExecStart=/bin/bash -c "GOMAXPROCS=$(nproc) /usr/bin/etcd"
317+
ExecStart=/usr/bin/etcd
317318
318319
Restart=on-failure
319320
LimitNOFILE=65536
@@ -324,6 +325,26 @@ WantedBy=multi-user.target
324325

325326
##### 依次修改3个节点的 /etc/etcd/etc.conf 和 /usr/lib/systemd/system/etcd.service 文件
326327

328+
329+
### 4. 添加用户
330+
331+
```shell
332+
useradd -u 2380 etcd
333+
```
334+
335+
### 5. 配置证书权限
336+
337+
```shell
338+
setfacl -m u:etcd:r etcd-server.key etcd-peer.key
339+
```
340+
341+
342+
### 6. 修改数据目录权限
343+
344+
```shell
345+
chown etcd. /var/lib/etcd
346+
```
347+
327348
### 重新载入配置
328349

329350
由于修改了 systemd 配置,所以需要重新载入配置

kubernetes/install/103.add-user.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
### Add Group & User `kube`
44

55
```shell
6-
groupadd -g 200 kube
7-
useradd -g 200 kube -u 200 -d / -s /sbin/nologin -M
6+
groupadd -g 2000 kube
7+
useradd -g 2000 kube -u 2000 -d / -s /sbin/nologin -M
88
```
99

1010

kubernetes/install/104.gen-certs.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,16 @@ openssl genrsa -out ca.key 4096
8484
#### 签发CA
8585

8686
```shell
87-
openssl req -x509 -new -nodes -key ca.key -days 1825 -out ca.pem -subj \
87+
openssl req -x509 -new -nodes -key ca.key -days 3650 -out ca.pem -subj \
8888
"/CN=kubernetes/OU=System/C=CN/ST=Shanghai/L=Shanghai/O=k8s" \
8989
-config ca.cnf -extensions v3_req
9090
```
9191

92-
- 有效期 **1825** (d) = 3 years
9392
- 注意 -subj 参数中仅 'C=CN' 与 'Shanghai' 可以修改,除非您清楚它们在 Kubernetes TLS 认证体系中的作用,否则建议**保持原样**,以免集群遇到权限异常问题
9493

9594
### kube-apiserver
9695

97-
#### apiserver.cnf
96+
#### kube-apiserver.cnf
9897

9998
```
10099
[ req ]
@@ -132,15 +131,15 @@ DNS.5 = kubernetes.default.svc.cluster.local
132131
#### 生成 key
133132

134133
```shell
135-
openssl genrsa -out apiserver.key 4096
134+
openssl genrsa -out kube-apiserver.key 4096
136135
```
137136

138137
#### 生成证书签名请求
139138

140139
```shell
141-
openssl req -new -key apiserver.key -out apiserver.csr -subj \
140+
openssl req -new -key kube-apiserver.key -out kube-apiserver.csr -subj \
142141
"/CN=kubernetes/OU=System/C=CN/ST=Shanghai/L=Shanghai/O=k8s" \
143-
-config apiserver.cnf
142+
-config kube-apiserver.cnf
144143
```
145144
- CN、OU、O 字段为认证时使用, 请勿修改
146145

@@ -151,10 +150,10 @@ openssl req -new -key apiserver.key -out apiserver.csr -subj \
151150
#### 签发证书
152151

153152
```shell
154-
openssl x509 -req -in apiserver.csr \
153+
openssl x509 -req -in kube-apiserver.csr \
155154
-CA ca.pem -CAkey ca.key -CAcreateserial \
156-
-out apiserver.pem -days 1825 \
157-
-extfile apiserver.cnf -extensions v3_req
155+
-out kube-apiserver.pem -days 3650 \
156+
-extfile kube-apiserver.cnf -extensions v3_req
158157
```
159158

160159
### kube-apiserver-kubelet-client
@@ -198,7 +197,7 @@ openssl req -new -key kube-apiserver-kubelet-client.key -out kube-apiserver-kube
198197
```shell
199198
openssl x509 -req -in kube-apiserver-kubelet-client.csr \
200199
-CA ca.pem -CAkey ca.key -CAcreateserial \
201-
-out kube-apiserver-kubelet-client.pem -days 1825 \
200+
-out kube-apiserver-kubelet-client.pem -days 3650 \
202201
-extfile kube-apiserver-kubelet-client.cnf -extensions v3_req
203202
```
204203

@@ -249,7 +248,7 @@ openssl req -new -key kube-controller-manager.key \
249248
```shell
250249
openssl x509 -req -in kube-controller-manager.csr \
251250
-CA ca.pem -CAkey ca.key -CAcreateserial \
252-
-out kube-controller-manager.pem -days 1825 \
251+
-out kube-controller-manager.pem -days 3650 \
253252
-extfile kube-controller-manager.cnf -extensions v3_req
254253
```
255254

@@ -288,7 +287,7 @@ openssl req -new -key kube-scheduler.key \
288287
```shell
289288
openssl x509 -req -in kube-scheduler.csr \
290289
-CA ca.pem -CAkey ca.key -CAcreateserial \
291-
-out kube-scheduler.pem -days 1865 \
290+
-out kube-scheduler.pem -days 3650 \
292291
-extfile kube-scheduler.cnf -extensions v3_req
293292
```
294293

@@ -400,7 +399,7 @@ openssl genrsa -out front-proxy-ca.key 4096
400399
#### 签发CA
401400

402401
```shell
403-
openssl req -x509 -new -nodes -key front-proxy-ca.key -days 1825 -out front-proxy-ca.pem -subj \
402+
openssl req -x509 -new -nodes -key front-proxy-ca.key -days 3650 -out front-proxy-ca.pem -subj \
404403
"/CN=kubernetes/OU=System/C=CN/ST=Shanghai/L=Shanghai/O=k8s" \
405404
-config front-proxy-ca.cnf -extensions v3_req
406405
```

kubernetes/install/105.install-depends.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
## 安装依赖项
22

33
```shell
4-
yum install -y libnetfilter_conntrack-devel libnetfilter_conntrack conntrack-tools ipvsadm ipset nmap-ncat bash-completion nscd chrony
4+
yum install -y libnetfilter_conntrack conntrack-tools ipvsadm ipset nmap-ncat bash-completion nscd chrony
55
```
66

77
### 启动时间同步服务

kubernetes/install/106.install-contaierd.io.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ dnf install -y containerd.io
1616
containerd config default > /etc/containerd/config.toml
1717
```
1818

19+
```shell
20+
sed -i 's#^root = ".*"#root = "/data/containerd"#' /etc/containerd/config.toml
21+
```
22+
1923
> 设置 root = "/data/containerd"
2024
2125
创建数据目录

0 commit comments

Comments
 (0)