karmada-io / karmada

Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
https://karmada.io
Apache License 2.0
4.39k stars 867 forks source link

mcs 连接失败 #4281

Open 13567436138 opened 10 months ago

13567436138 commented 10 months ago

serviceimport/cpp-ServiceExport-ServiceImport.yaml

# propagate ServiceExport CRD
apiVersion: policy.karmada.io/v1alpha1
kind: ClusterPropagationPolicy
metadata:
  name: serviceexport-policy
spec:
  resourceSelectors:
    - apiVersion: apiextensions.k8s.io/v1
      kind: CustomResourceDefinition
      name: serviceexports.multicluster.x-k8s.io
  placement:
    clusterAffinity:
      clusterNames:
        - cluster1
        - cluster2
---        
# propagate ServiceImport CRD
apiVersion: policy.karmada.io/v1alpha1
kind: ClusterPropagationPolicy
metadata:
  name: serviceimport-policy
spec:
  resourceSelectors:
    - apiVersion: apiextensions.k8s.io/v1
      kind: CustomResourceDefinition
      name: serviceimports.multicluster.x-k8s.io
  placement:
    clusterAffinity:
      clusterNames:
        - cluster1
        - cluster2
 kubectl get serviceexports.multicluster.x-k8s.io --kubeconfig ~/kube-karmada --context karmada-apiserver 

 kubectl apply -f cpp-ServiceExport-ServiceImport.yaml -n karmada --kubeconfig ~/kube-karmada --context karmada-apiserver 

serviceimport/nginx-deploy.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx
        name: nginx
 kubectl apply -f nginx-deploy.yaml  -n karmada --kubeconfig ~/kube-karmada 

serviceimport/PropagationPolicy-cluster2-nginx.yaml

apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: nginx-cluster2
spec:
  resourceSelectors:
    - apiVersion: apps/v1
      kind: Deployment
      name: nginx
  placement:
    clusterAffinity:
      clusterNames:
        - cluster2
 kubectl apply -f PropagationPolicy-cluster2-nginx.yaml  -n karmada --kubeconfig ~/kube-karmada

serviceimport/svc-nginx.yaml

apiVersion: v1 
kind: Service 
metadata:
  name: nginx 
spec:
  type: ClusterIP 
  selector:
    app: nginx 
  ports:
  - name: http 
    port: 80 
    targetPort: 80
 kubectl apply -f svc-nginx.yaml -n karmada --kubeconfig ~/kube-karmada 

serviceimport/nginx-svc-propagation-policy-cluster2.yaml

apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: nginx-propagation-policy-cluster2
spec:
  resourceSelectors:
    - apiVersion: v1
      kind: Service
      name: nginx
  placement:
    clusterAffinity:
      clusterNames:
        - cluster2
 kubectl apply -f nginx-svc-propagation-policy-cluster2.yaml  -n karmada --kubeconfig ~/kube-karmada

serviceimport/se-server-cluster2.yaml

kubectl apply -f se-server-cluster2.yaml -n karmada

apiVersion: multicluster.x-k8s.io/v1alpha1
kind: ServiceExport
metadata:
  name: nginx
---
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: nginx-export-policy
spec:
  resourceSelectors:
    - apiVersion: multicluster.x-k8s.io/v1alpha1
      kind: ServiceExport
      name: nginx
  placement:
    clusterAffinity:
      clusterNames:
        - cluster2
 kubectl apply -f se-server-cluster2.yaml  -n karmada --kubeconfig ~/kube-karmada

serviceimport/si-nginx-sessionAffinity-None.yaml

kubectl apply -f si-nginx-sessionAffinity-None.yaml -n karmada --kubeconfig ~/kube-karmada

apiVersion: multicluster.x-k8s.io/v1alpha1
kind: ServiceImport
metadata:
  name: nginx
spec:
  type: ClusterSetIP
  ports:
  - port: 80
    protocol: TCP
  sessionAffinity: None 
---
apiVersion: policy.karmada.io/v1alpha1
kind: PropagationPolicy
metadata:
  name: nginx-import-policy
spec:
  resourceSelectors:
    - apiVersion: multicluster.x-k8s.io/v1alpha1
      kind: ServiceImport
      name: nginx
  placement:
    clusterAffinity:
      clusterNames:
        - cluster1

报错: Connecting to derived-nginx.karmada.svc.cluster.local:80 (10.69.176.180:80) wget: can't connect to remote host (10.69.176.180): Connection refused

endpointslice也生成了

[root@member1-153 ~]# kubectl get endpointslices.discovery.k8s.io -n karmada
NAME                            ADDRESSTYPE   PORTS   ENDPOINTS      AGE
imported-cluster2-nginx-zn5w8   IPv4          80      172.22.0.97    32m
nginx-xx689                     IPv4          80      10.70.220.56   30m

就是访问不了集群2

karmada版本1.4.0 k8s版本1.23.1

Task description:

Solution:

Who can join or take the task:

The good first issue is intended for first-time contributors to get started on his/her contributor journey.

After a contributor has successfully completed 1-2 good first issue's, they should be ready to move on to help wanted items, saving the remaining good first issue for other new contributors.

How to join or take the task:

Just reply on the issue with the message /assign in a separate line.

Then, the issue will be assigned to you.

How to ask for help:

If you need help or have questions, please feel free to ask on this issue. The issue author or other members of the community will guide you through the contribution process.

XiShanYongYe-Chang commented 9 months ago

Is the container network between clusters not connected? For karmada mcs, the synchronization of endpoints is considered successful once completed.

XiShanYongYe-Chang commented 9 months ago

/kind question /remove-good first issue

13567436138 commented 9 months ago

only endpointslice no endpoints

XiShanYongYe-Chang commented 9 months ago

Yes, currently only the EndpointSlice resource has been processed.