当前位置:网站首页>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 .
边栏推荐
- Graduation season | keep company with youth and look forward to the future together!
- Input type= "password" how to solve the problem of password automatically brought in
- electron添加SQLite数据库
- Distributed database master-slave configuration (MySQL)
- 科普达人丨一文弄懂什么是云计算?
- Web端自动化测试失败的原因
- Eth trunk link switching delay is too high
- oracle常见锁表处理方式
- The opacity value becomes 1%
- RationalDMIS2022阵列工件测量
猜你喜欢
Basic knowledge of process (orphan, zombie process)
2021-05-21
對比學習之 Unsupervised Learning of Visual Features by Contrasting Cluster Assignments
Excel公式知多少?
关于SIoU《SIoU Loss: More Powerful Learning for Bounding Box Regression Zhora Gevorgyan 》的一些看法及代码实现
Web端自动化测试失败的原因
聊聊SOC启动(十一) 内核初始化
MPX plug-in
JS add spaces to the string
What if copying is prohibited?
随机推荐
在我有限的软件测试经历里,一段专职的自动化测试经验总结
网络协议 概念
Template initial level template
Learning notes | data Xiaobai uses dataease to make a large data screen
CentOS系统下Redis安装和自启动配置的步骤
PostgreSQL中的表复制
Verilog 实现数码管显视驱动【附源码】
[untitled]
[question] Compilation Principle
Antd select selector drop-down box follows the scroll bar to scroll through the solution
Input type= "password" how to solve the problem of password automatically brought in
From pornographic live broadcast to live broadcast E-commerce
Android 面试知识点
通过 Play Integrity API 的 nonce 字段提高应用安全性
测试优惠券要怎么写测试用例?
R language uses image of magick package_ Mosaic functions and images_ The flatten function stacks multiple pictures together to form a stack layers on top of each other
R語言使用magick包的image_mosaic函數和image_flatten函數把多張圖片堆疊在一起形成堆疊組合圖像(Stack layers on top of each other)
QT implements the delete method of the container
How to remove addition and subtraction from inputnumber input box
What if copying is prohibited?