当前位置:网站首页>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 .
边栏推荐
- 请查收.NET MAUI 的最新学习资源
- .NET MAUI 性能提升
- Use metersphere to keep your testing work efficient
- Array object sorting
- R語言使用magick包的image_mosaic函數和image_flatten函數把多張圖片堆疊在一起形成堆疊組合圖像(Stack layers on top of each other)
- 分布式数据库主从配置(MySQL)
- Vscode 尝试在目标目录创建文件时发生一个错误:拒绝访问【已解决】
- 毕业季|与青春作伴,一起向未来!
- Electron adding SQLite database
- Table replication in PostgreSQL
猜你喜欢
Drive HC based on de2115 development board_ SR04 ultrasonic ranging module [source code attached]
RationalDMIS2022阵列工件测量
[pyqt] the cellwidget in tablewidget uses signal and slot mechanism
分布式数据库主从配置(MySQL)
Verilog realizes nixie tube display driver [with source code]
Force buckle 1002 Find common characters
测试开发基础,教你做一个完整功能的Web平台之环境准备
The annual salary of general test is 15W, and the annual salary of test and development is 30w+. What is the difference between the two?
Zhou Yajin, a top safety scholar of Zhejiang University, is a curiosity driven activist
Unsupervised learning of visual features by contracting cluster assignments
随机推荐
基于STC8G1K08的0.96寸IIC液晶屏驱动程序
Unsupervised learning of visual features by contracting cluster assignments
基于DE2 115开发板驱动HC_SR04超声波测距模块【附源码】
Table replication in PostgreSQL
自动化测试框架
What if copying is prohibited?
Learning notes | data Xiaobai uses dataease to make a large data screen
[untitled]
Activity生命周期
创意信息获2家机构调研:GreatDB 数据库已在9地部署
[C #] the solution of WinForm operation zoom (blur)
关于SIoU《SIoU Loss: More Powerful Learning for Bounding Box Regression Zhora Gevorgyan 》的一些看法及代码实现
How to remove addition and subtraction from inputnumber input box
Basic knowledge of process (orphan, zombie process)
【系统设计】指标监控和告警系统
CentOS系统下Redis安装和自启动配置的步骤
Design intelligent weighing system based on Huawei cloud IOT (STM32)
使用引用
自律,提升自制力原来也有方法
JS array delete the specified element