Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

重构郑重声明!!! #132

Open
cuisongliu opened this issue Sep 22, 2023 · 5 comments
Open

重构郑重声明!!! #132

cuisongliu opened this issue Sep 22, 2023 · 5 comments

Comments

@cuisongliu
Copy link
Collaborator

cuisongliu commented Sep 22, 2023

在项目的发展过程中,最初采用了Service和Endpoint的方法来解决外部服务的特性问题,以实现对集群外部服务的访问。然而,逐渐发现这种方法无法满足一些有状态服务的需求。其中一个主要原因是Service和Endpoint的定义只允许相同的端口,不能使用不同的端口作为后端地址。为了解决这个问题,项目决定废弃这一设计,重新构思一个新的Operator。

新的Operator设计具备以下特点和能力:

  1. 重复使用lvscare的一部分功能,直接透传IPVS的能力,实现后端地址的自由组合。
  2. 每个ClusterIP都具备独立的探活功能,支持TCP、UDP、GRPC、HTTP等不同的协议。
  3. 支持自动域名管理的能力。

最终目标是允许接入有状态服务,而无需每个主机都有相同的端口设置。这一能力非常重要,未来可以借助这个功能实现外部中间件内部的负载均衡,无需担心云上不同集群之间的访问问题。

@cuisongliu
Copy link
Collaborator Author

  1. 给对应的redis创建service 配置
apiVersion: v1
kind: Service
metadata:
  annotations:
    monitor.kubeblocks.io/agamotto: "false"
    monitor.kubeblocks.io/scrape: "false"
  labels:
    app.kubernetes.io/component: redis
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: kubeblocks
    app.kubernetes.io/name: redis
    apps.kubeblocks.io/component-name: redis
  name: redis-redis-headless-p0
  namespace: redis-cloud
spec:
  ports:
  - name: redis
    port: 6379
    protocol: TCP
    targetPort: redis
  selector:
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: kubeblocks
    apps.kubeblocks.io/component-name: redis
    statefulset.kubernetes.io/pod-name: redis-redis-0
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}
---

apiVersion: v1
kind: Service
metadata:
  annotations:
    monitor.kubeblocks.io/agamotto: "false"
    monitor.kubeblocks.io/scrape: "false"
  labels:
    app.kubernetes.io/component: redis
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: kubeblocks
    app.kubernetes.io/name: redis
    apps.kubeblocks.io/component-name: redis
  name: redis-redis-headless-p1
  namespace: redis-cloud
spec:
  ports:
  - name: redis
    port: 6379
    protocol: TCP
    targetPort: redis
  selector:
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: kubeblocks
    apps.kubeblocks.io/component-name: redis
    statefulset.kubernetes.io/pod-name: redis-redis-1
  sessionAffinity: None
  type: NodePort
status:
  loadBalancer: {}
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    monitor.kubeblocks.io/agamotto: "false"
    monitor.kubeblocks.io/scrape: "false"
  labels:
    app.kubernetes.io/component: redis-sentinel
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: kubeblocks
    app.kubernetes.io/name: redis
    apps.kubeblocks.io/component-name: redis-sentinel
  name: redis-redis-sentinel-headless-p0
  namespace: redis-cloud
spec:
  ports:
  - name: redis-sentinel
    port: 26379
    protocol: TCP
    targetPort: redis-sentinel
  selector:
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: kubeblocks
    apps.kubeblocks.io/component-name: redis-sentinel
    statefulset.kubernetes.io/pod-name: redis-redis-sentinel-0
  type: NodePort
status:
  loadBalancer: {}
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    monitor.kubeblocks.io/agamotto: "false"
    monitor.kubeblocks.io/scrape: "false"
  labels:
    app.kubernetes.io/component: redis-sentinel
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: kubeblocks
    app.kubernetes.io/name: redis
    apps.kubeblocks.io/component-name: redis-sentinel
  name: redis-redis-sentinel-headless-p1
  namespace: redis-cloud
spec:
  ports:
  - name: redis-sentinel
    port: 26379
    protocol: TCP
    targetPort: redis-sentinel
  selector:
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: kubeblocks
    apps.kubeblocks.io/component-name: redis-sentinel
    statefulset.kubernetes.io/pod-name: redis-redis-sentinel-1
  type: NodePort
status:
  loadBalancer: {}
---
apiVersion: v1
kind: Service
metadata:
  annotations:
    monitor.kubeblocks.io/agamotto: "false"
    monitor.kubeblocks.io/scrape: "false"
  labels:
    app.kubernetes.io/component: redis-sentinel
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: kubeblocks
    app.kubernetes.io/name: redis
    apps.kubeblocks.io/component-name: redis-sentinel
  name: redis-redis-sentinel-headless-p2
  namespace: redis-cloud
spec:
  ports:
  - name: redis-sentinel
    port: 26379
    protocol: TCP
    targetPort: redis-sentinel
  selector:
    app.kubernetes.io/instance: redis
    app.kubernetes.io/managed-by: kubeblocks
    apps.kubeblocks.io/component-name: redis-sentinel
    statefulset.kubernetes.io/pod-name: redis-redis-sentinel-2
  type: NodePort
status:
  loadBalancer: {}

@cuisongliu
Copy link
Collaborator Author

cuisongliu commented Sep 22, 2023

  1. 调kube-proxy 的配置 防止自动删除ipvs规则
excludeCIDRs:
      - 10.103.97.2/32
      - 30.96.0.0/16
  1. 新增对应的ipvs规则
ipvsadm -Ln


ipvsadm -D -t 30.96.0.1:6379
ipvsadm -A -t 30.96.0.1:6379 -s rr
ipvsadm -a -t 30.96.0.1:6379 -r 172.18.2.70:30362  -m


ipvsadm -D -t 30.96.0.2:6379
ipvsadm -A -t 30.96.0.2:6379 -s rr
ipvsadm -a -t 30.96.0.2:6379 -r 172.18.2.70:32065  -m



ipvsadm -D -t 30.96.0.3:26379
ipvsadm -A -t 30.96.0.3:26379 -s rr
ipvsadm -a -t 30.96.0.3:26379 -r 172.18.2.70:31012  -m


ipvsadm -D -t 30.96.0.4:26379
ipvsadm -A -t 30.96.0.4:26379 -s rr
ipvsadm -a -t 30.96.0.4:26379 -r 172.18.2.70:30655  -m




ipvsadm -D -t 30.96.0.5:26379
ipvsadm -A -t 30.96.0.5:26379 -s rr
ipvsadm -a -t 30.96.0.5:26379 -r 172.18.2.70:30300  -m




30.96.0.1 redis-redis-0.redis-redis-headless.redis-cloud.svc.cluster.local 
30.96.0.2 redis-redis-1.redis-redis-headless.redis-cloud.svc.cluster.local
30.96.0.3 redis-redis-sentinel-0.redis-redis-sentinel-headless.redis-cloud.svc.cluster.local 
30.96.0.4 redis-redis-sentinel-1.redis-redis-sentinel-headless.redis-cloud.svc.cluster.local 
30.96.0.5 redis-redis-sentinel-2.redis-redis-sentinel-headless.redis-cloud.svc.cluster.local


client:  redis-redis-sentinel-0.redis-redis-sentinel-headless.redis-cloud.svc.cluster.local:26379,redis-redis-sentinel-1.redis-redis-sentinel-headless.redis-cloud.svc.cluster.local:26379,redis-redis-sentinel-2.redis-redis-sentinel-headless.redis-cloud.svc.cluster.local:26379

@cuisongliu
Copy link
Collaborator Author

手动创建规则如何被pod之间访问?

@cuisongliu
Copy link
Collaborator Author

@cuisongliu
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant