Kubernetes无头服务多接口Pod

时间:2020-07-08 15:54:14

标签: kubernetes

我无法对此问题添加评论 Kubernetes Headless Service resolves to specific interface of a multi-interface Pod

我有相同的要求,但是帖子没有说明问题是否已解决,因此请重新发布。

这是Yaml:

apiVersion: v1
kind: Service
metadata:
  name: ovnkube-db
  namespace: ovn-kubernetes
spec:
  ports:
  - name: north
    port: 6641
    protocol: TCP
    targetPort: 6641
  - name: south
    port: 6642
    protocol: TCP
    targetPort: 6642
  sessionAffinity: None
  clusterIP: None
  type: ClusterIP

---

apiVersion: v1
kind: Endpoints
metadata:
  name: ovnkube-db
subsets:
  - addresses:
      - ip: 253.255.0.33
      - ip: 253.255.0.34
      - ip: 253.255.0.35
    ports:
    - name: north
      port: 6641
    - name: south
      port: 6642
---

apiVersion: policy/v1beta1
apiVersion: policy/v1beta1
kind: PodDisruptionBudget
metadata:
  name: ovndb-raft-pdb
  namespace: ovn-kubernetes

etc...

根据我引用的帖子和kubernetes文档,我想添加 端点部分可以解决我的问题,但不能:

kubectl describe services --namespace=ovn-kubernetes
Name:              ovnkube-db
Namespace:         ovn-kubernetes
Labels:            <none>
Annotations:       kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"ovnkube-db","namespace":"ovn-kubernetes"},"spec":{"clusterIP":"None","ports":[...
Selector:          <none>
Type:              ClusterIP
IP:                None
Port:              north  6641/TCP
TargetPort:        6641/TCP
Endpoints:         10.68.48.204:6641,10.68.48.205:6641,10.68.48.206:6641
Port:              south  6642/TCP
TargetPort:        6642/TCP
Endpoints:         10.68.48.204:6642,10.68.48.205:6642,10.68.48.206:6642
Session Affinity:  None
Events:            <none>

我的IP地址是:

ip a | grep "inet "
    inet 127.0.0.1/8 scope host lo
    inet 10.68.48.204/22 brd 10.68.51.255 scope global eno1
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
    inet 253.255.0.33/16 brd 253.255.255.255 scope global bond0.3900
    inet 253.255.0.32/32 scope global bond0.3900
    inet 10.244.0.0/32 scope global flannel.1
    inet 10.244.0.1/24 brd 10.244.0.255 scope global cni0
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0

我的kube-apiserver位于253.255:

kubectl config view | grep server
    server: https://253.255.0.33:6443
    enter code here

2 个答案:

答案 0 :(得分:1)

是的,它是名称空间,所以我可以确认,这是可行的:)

答案 1 :(得分:1)

问题是namespace丢失了。这样就可以解决。

apiVersion: v1
kind: Endpoints
metadata:
  name: ovnkube-db
  namespace: ovn-kubernetes
subsets:
  - addresses:
      - ip: 253.255.0.33
      - ip: 253.255.0.34
      - ip: 253.255.0.35
    ports:
    - name: north
      port: 6641
    - name: south
      port: 6642