当前位置:网站首页>The running kubernetes cluster wants to adjust the network segment address of pod
The running kubernetes cluster wants to adjust the network segment address of pod
2022-07-07 11:29:00 【Jiangxl~】
Running K8S Cluster adjustment Pod The segment address of
List of articles
- Running K8S Cluster adjustment Pod The segment address of
- 1. modify Pod Background of network segment address
- 2. At present K8S Cluster information
- 3. First in K8S Build a cluster Pod
- 4. adjustment K8S Clustered Pod Network segment
- 4.1. adjustment K8S Network segment of address pool
- 4.2. adjustment Controller-Manager Network segment of component
- 4.4. adjustment Kube-proxy Segment address
- 4.5. adjustment K8S Cluster all nodes yaml The network segment address in the file
- 4.6. All nodes restart kubelet
- 4.7. restart K8S In the cluster Pod
1. modify Pod Background of network segment address
Use sealos The deployment of K8S colony , default Pod Network segment is 100.64.0.0/16, There is no problem running in a privatized environment , But when the cluster is deployed in Alibaba cloud ECS In the following , adopt SLB Seven layers of load K8S Applications in the cluster , There will be access exceptions , The packet cannot be returned to SLB, After discussion with Alibaba cloud engineers, I learned ,SLB forwarding Proxy Network segment is 100.64.0.0/16, And K8S Pod The network segment address of conflicts , Thus, abnormal network phenomena may occur .
2. At present K8S Cluster information
[[email protected] ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready master 6m43s v1.19.16
k8s-node-1 Ready <none> 6m13s v1.19.16
k8s-node-2 Ready <none> 6m13s v1.19.16
Current Pod The network segment address is 100 Network segment , We need to adjust it to 10.10.0.0/18.

3. First in K8S Build a cluster Pod
First in K8S Build a cluster Pod, Observe before and after modifying the network segment Pod Is it available .
1) Resource orchestration file
[[email protected]-master k8s]# cat nginx.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: nginx
name: nginx
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- image: nginx
imagePullPolicy: Always
name: nginx
ports:
- containerPort: 80
name: http
protocol: TCP
- containerPort: 443
name: https
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
labels:
app: nginx
name: nginx-80-443
namespace: default
spec:
ports:
- name: http
port: 80
protocol: TCP
targetPort: 80
- name: https
port: 443
protocol: TCP
targetPort: 443
selector:
app: nginx
type: NodePort
2) Deploy
[[email protected] k8s]# kubectl get all
NAME READY STATUS RESTARTS AGE
pod/nginx-6b89b7f467-ct6md 1/1 Running 0 8m32s
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
service/kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 26m
service/nginx-80-443 NodePort 10.99.243.115 <none> 80:31575/TCP,443:31418/TCP 8m32s
NAME READY UP-TO-DATE AVAILABLE AGE
deployment.apps/nginx 1/1 1 1 8m32s
NAME DESIRED CURRENT READY AGE
replicaset.apps/nginx-6b89b7f467 1 1 1 8m32s
4. adjustment K8S Clustered Pod Network segment
4.1. adjustment K8S Network segment of address pool
1. see K8S Default address pool
[[email protected] k8s]# kubectl get ippool
NAME AGE
default-ipv4-ippool 18m
2. Adjust the address range of the address pool
[[email protected] k8s]# kubectl edit ippool default-ipv4-ippool
cidr: 10.10.0.0/18

4.2. adjustment Controller-Manager Network segment of component
[[email protected] k8s]# vim /etc/kubernetes/manifests/kube-controller-manager.yaml
- --cluster-cidr=10.10.0.0/18

4.4. adjustment Kube-proxy Segment address
[root@k8s-master k8s]# kubectl edit cm kube-proxy -n kube-system
clusterCIDR: 10.10.0.0/18
4.5. adjustment K8S Cluster all nodes yaml The network segment address in the file
How many Node Just perform the same operation for how many times .
[[email protected] k8s]# kubectl get nodes k8s-master -o yaml > master.yaml
[[email protected] k8s]# kubectl get nodes k8s-node-1 -o yaml > node-1.yaml
[[email protected] k8s]# kubectl get nodes k8s-node-2 -o yaml > node-2.yaml
[[email protected] k8s]# vim master.yaml
v:"10.10.0.0/18": {}
spec:
podCIDR: 10.10.0.0/18
podCIDRs:
- 10.10.0.0/18

[root@k8s-master k8s]# kubectl delete node k8s-master
node "k8s-master" deleted
[root@k8s-master k8s]# kubectl apply -f master.yaml
node/k8s-master created
[root@k8s-master k8s]# kubectl delete node k8s-node-1
node "k8s-node-1" deleted
[root@k8s-master k8s]# kubectl delete node k8s-node-2
node "k8s-node-2" deleted
[root@k8s-master k8s]# kubectl apply -f node-1.yaml
node/k8s-node-1 created
[root@k8s-master k8s]# kubectl apply -f node-2.yaml
node/k8s-node-2 created
4.6. All nodes restart kubelet
systemctl restart kubelet
4.7. restart K8S In the cluster Pod
[[email protected] k8s]# kubectl delete pod nginx-6b89b7f467-ct6md
pod "nginx-6b89b7f467-ct6md" deleted
[[email protected] k8s]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
nginx-6b89b7f467-869m2 1/1 Running 0 23s 10.10.5.129 k8s-node-1 <none> <none>
Pod The address has been successfully modified .
边栏推荐
猜你喜欢

From pornographic live broadcast to live broadcast E-commerce

Use metersphere to keep your testing work efficient

Leetcode - interview question 17.24 maximum submatrix

【C#】WinForm运行缩放(变糊)的解决方法

.NET MAUI 性能提升
![[untitled]](/img/15/3db921703147afdf58dfffe532a19b.jpg)
[untitled]

Verilog 实现数码管显视驱动【附源码】

自动化测试框架

Basic knowledge of process (orphan, zombie process)

科普达人丨一文弄懂什么是云计算?
随机推荐
Vuthink正确安装过程
浙江大学周亚金:“又破又立”的顶尖安全学者,好奇心驱动的行动派
How to add aplayer music player in blog
Eth trunk link switching delay is too high
‘module‘ object is not callable错误
Array object sorting
[untitled]
请查收.NET MAUI 的最新学习资源
When initializing 'float', what is the difference between converting to 'float' and adding 'f' as a suffix?
Go slice comparison
Audit migration
The opacity value becomes 1%
聊聊SOC启动(十) 内核启动先导知识
创意信息获2家机构调研:GreatDB 数据库已在9地部署
常用sql语句整理:mysql
How to remove addition and subtraction from inputnumber input box
How to use cherry pick?
CentOS系统下Redis安装和自启动配置的步骤
Distributed database master-slave configuration (MySQL)
使用引用