当前位置:网站首页>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 .
边栏推荐
- Qt|多个窗口共有一个提示框类
- Input type= "password" how to solve the problem of password automatically brought in
- 【问道】编译原理
- 【系统设计】指标监控和告警系统
- [untitled]
- Electron adding SQLite database
- [pyqt] the cellwidget in tablewidget uses signal and slot mechanism
- 從色情直播到直播電商
- Design intelligent weighing system based on Huawei cloud IOT (STM32)
- 技术分享 | 抓包分析 TCP 协议
猜你喜欢
Technology sharing | packet capturing analysis TCP protocol
How to remove addition and subtraction from inputnumber input box
禁锢自己的因素,原来有这么多
The opacity value becomes 1%
Verilog realizes nixie tube display driver [with source code]
聊聊SOC启动(十一) 内核初始化
Distributed database master-slave configuration (MySQL)
聊聊SOC启动(七) uboot启动流程三
verilog设计抢答器【附源码】
[untitled]
随机推荐
TDengine 社区问题双周精选 | 第二期
Use metersphere to keep your testing work efficient
Web端自动化测试失败的原因
mif 文件格式记录
From pornographic live broadcast to live broadcast E-commerce
学习笔记|数据小白使用DataEase制作数据大屏
Leetcode - interview question 17.24 maximum submatrix
【愚公系列】2022年7月 Go教学课程 005-变量
Android 面试知识点
[C #] the solution of WinForm operation zoom (blur)
Unsupervised learning of visual features by contracting cluster assignments
Network protocol concept
浙江大学周亚金:“又破又立”的顶尖安全学者,好奇心驱动的行动派
从色情直播到直播电商
QT implements the delete method of the container
Excel公式知多少?
Case study of Jinshan API translation function based on retrofit framework
Network foundation (1)
通过 Play Integrity API 的 nonce 字段提高应用安全性
【问道】编译原理