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

Kustomizing namespace seems that it doesn't work. #1935

Open
1 task done
cleanior opened this issue Nov 8, 2023 · 0 comments
Open
1 task done

Kustomizing namespace seems that it doesn't work. #1935

cleanior opened this issue Nov 8, 2023 · 0 comments
Labels

Comments

@cleanior
Copy link

cleanior commented Nov 8, 2023

Is there an existing issue for this?

Current Behavior

I just want to deploy multiple instances of a simple ServiceMonitor resource on a kubernetes cluster with different namespaces.

all I want to do is just modifying the namespace and adding a namespaceSelector field for each.

So I created a common Service monitor on a base directory and tried to modify the namespace of it and add namespaceSelector for each namespace under overlay directories.

The direcotry hierarchy is like below.

├── base-manifest
│   ├── kustomization.yaml
│   └── service-monitor.yaml
├── fleet.yaml
└── overlays
    ├── namespaceA
    │   ├── kustomization.yaml
    │   └── service-monitor-patch.yaml
    └── namespaceB
        ├── kustomization.yaml
        └── service-monitor-patch.yaml

fleet.yaml

---
targetCustomizations:
- name: namespaceA
  namespace: namespaceA
  kustomize:
    dir: overlays/namespaceA

- name: namespaceB
  namespace: namespaceB
  kustomize:
    dir: overlays/namespaceB
...

base-manifest/service-monitor.yaml

---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    app: service-monitor
  name: service-monitor
spec:
  endpoints:
  - interval: 30s
    path: /service/v2/metrics/cluster
    port: http-service
  - interval: 30s
    path: /service/v2/metrics/bucket
    port: http-service
  selector:
    matchLabels:
      app: serviceS
...

overlays/namespaceA/kustomization.yaml

---
resources:
- ../../base-manifest

namespace: namespaceA

patchesStrategicMerge:
- service-monitor-patch.yaml
...

overlays/namespaceA/service-monitor-patch.yaml

---
kind: ServiceMonitor
metadata:
  name: service-monitor
spec:
  namespaceSelector:
    matchNames:
    - namespaceA
...

But the fleet(especially the rancher GUI) just shows as if there are 3 service monitors created for each namespace(default, namespaceA, namespaceB) by the GitRepo and what is even more confusing is that there is actually only 1 service monitor with the default namespace in a cluster.

Expected Behavior

What I expected is, and it should be working as,

There is 1 service monitor deployed for each namespace, so 2 service monitors in total in a cluster with the resource yaml like below(example for namespaceA, and the service monitor on namespaceB will have its own namespace information, respectively),

---
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    app: service-monitor
  name: service-monitor
  namespace: namespaceA
spec:
  endpoints:
  - interval: 30s
    path: /service/v2/metrics/cluster
    port: http-service
  - interval: 30s
    path: /service/v2/metrics/bucket
    port: http-service
  selector:
    matchLabels:
      app: serviceS
  namespaceSelector:
    matchNames:
    - namespaceA
...

Steps To Reproduce

No response

Environment

- Architecture: amd64
- Fleet Version:0.7.1
- Cluster:
  - Provider: RKE2 with "Rancher v2.7.7"
  - Options:
  - Kubernetes Version:1.26 (v1.26+rke2r1)

Logs

No response

Anything else?

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants