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

Append a new matchLabels in subscription, the original matchLabel will lost #38

Closed
DanielXLee opened this issue Jul 28, 2021 · 2 comments
Labels
kind/question Further information is requested

Comments

@DanielXLee
Copy link
Contributor

What happened:

Append a new matchLabels "clusters.clusternet.io/cluster-id": "c817745f-f46b-4a2b-95fd-86521c81cc79" in the subscription, the original matchLabels "clusters.clusternet.io/cluster-id": "46919132-9639-4c72-a187-975d8cfe0f6c" will lost

~  k get sub helm-demo -ojson | jq '.spec.subscribers'
[
  {
    "clusterAffinity": {
      "matchLabels": {
        "clusters.clusternet.io/cluster-id": "c817745f-f46b-4a2b-95fd-86521c81cc79"
      }
    }
  }
]

What you expected to happen:

~  k get sub helm-demo -ojson | jq '.spec.subscribers'
[
  {
    "clusterAffinity": {
      "matchLabels": {
        "clusters.clusternet.io/cluster-id": "46919132-9639-4c72-a187-975d8cfe0f6c"
        "clusters.clusternet.io/cluster-id": "c817745f-f46b-4a2b-95fd-86521c81cc79"
      }
    }
  }
]

How to reproduce it (as minimally and precisely as possible):

There are 2 managed cluster, and a subscription in my test env.

~  k get mcls -A
NAMESPACE          NAME                       CLUSTER ID                             SYNC MODE   KUBERNETES   READYZ   AGE
clusternet-4jxfq   clusternet-cluster-l2bmc   46919132-9639-4c72-a187-975d8cfe0f6c   Dual        v1.21.1      true     23h
clusternet-dwgrd   clusternet-cluster-kx2b2   c817745f-f46b-4a2b-95fd-86521c81cc79   Dual        v1.21.1      true     23h
☁  ~  cat sub.yaml
apiVersion: apps.clusternet.io/v1alpha1
kind: Subscription
metadata:
  name: helm-demo
  namespace: default
spec:
  subscribers:
    - clusterAffinity:
        matchLabels:
          clusters.clusternet.io/cluster-id: 46919132-9639-4c72-a187-975d8cfe0f6c
  feeds:
    - apiVersion: apps.clusternet.io/v1alpha1
      kind: HelmChart
      name: mysql
      namespace: default
    - apiVersion: apps.clusternet.io/v1alpha1
      kind: HelmChart
      namespace: default
      feedSelector:
        matchLabels:
          app: wordpress

Apply this subscription, and check hr, looks good so far.

~  k apply -f sub.yaml
subscription.apps.clusternet.io/helm-demo created
☁  ~  k get hr -A
NAMESPACE          NAME                  CHART       VERSION   REPO                                 STATUS     AGE
clusternet-4jxfq   helm-demo-mysql       mysql       8.6.2     https://charts.bitnami.com/bitnami   deployed   20s
clusternet-4jxfq   helm-demo-wordpress   wordpress   11.0.17   https://charts.bitnami.com/bitnami   deployed   20s

Edit the subscription, and append a new matchLabels clusters.clusternet.io/cluster-id: c817745f-f46b-4a2b-95fd-86521c81cc79 in this sub.

Expect result:,

~  k get sub helm-demo -ojson | jq '.spec.subscribers'
[
  {
    "clusterAffinity": {
      "matchLabels": {
        "clusters.clusternet.io/cluster-id": "46919132-9639-4c72-a187-975d8cfe0f6c"
        "clusters.clusternet.io/cluster-id": "c817745f-f46b-4a2b-95fd-86521c81cc79"
      }
    }
  }
]

After edit subscription,

~  k get sub helm-demo -ojson | jq '.spec.subscribers'
[
  {
    "clusterAffinity": {
      "matchLabels": {
        "clusters.clusternet.io/cluster-id": "c817745f-f46b-4a2b-95fd-86521c81cc79"
      }
    }
  }
]

Anything else we need to know?:

Environment:

  • Clusternet version:

    • Clusternet-agent version (user clusternet-agent --version=json):
    • Clusternet-hub version (user clusternet-hub --version=json): "ghcr.io/clusternet/clusternet-hub:v0.2.0"
  • Kubernetes version (use kubectl version):

~  kubectl version
Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.3", GitCommit:"ca643a4d1f7bfe34773c74f79527be4afd95bf39", GitTreeState:"clean", BuildDate:"2021-07-15T21:04:39Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.1", GitCommit:"5e58841cce77d4bc13713ad2b91fa0d961e69192", GitTreeState:"clean", BuildDate:"2021-05-21T23:01:33Z", GoVersion:"go1.16.4", Compiler:"gc", Platform:"linux/amd64"}

This is kind cluster

~  kind get clusters
cluster1
cluster2
hub
  • Cloud provider or hardware configuration:
  • OS (e.g: cat /etc/os-release):
  • Kernel (e.g. uname -a):
  • Others:
@DanielXLee DanielXLee added the kind/bug Something isn't working label Jul 28, 2021
@dixudx
Copy link
Member

dixudx commented Jul 28, 2021

@DanielXLee matchLabels is a map[string]string where you cannot set multiple items with the same key.

If you want to add multiple cluster IDs, you can try matchExpressions, such as

spec:
  subscribers:
    - clusterAffinity:
        matchExpressions:
          - {key: clusters.clusternet.io/cluster-id, operator: In, values: [46919132-9639-4c72-a187-975d8cfe0f6c,c817745f-f46b-4a2b-95fd-86521c81cc79]}

@dixudx dixudx added kind/question Further information is requested and removed kind/bug Something isn't working labels Jul 28, 2021
@DanielXLee
Copy link
Contributor Author

Thanks @dixudx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants