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

chore: fix issue with k8s 1.27 (kustomize v5) not supporting multi-doc patches for the Prometheus addon #4434

Merged

Conversation

rrpolanco
Copy link
Contributor

What this PR does / why we need it:

k8s_27x airgap test was failing due to the following prometheus error:

2023-04-26 20:59:50+00:00 Error from server (NotFound): services "prometheus-k8s" not found
2023-04-26 20:59:51+00:00 # Warning: 'patchesJson6902' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
2023-04-26 20:59:51+00:00 panic: runtime error: invalid memory address or nil pointer dereference
2023-04-26 20:59:51+00:00 [signal SIGSEGV: segmentation violation code=0x1 addr=0x40 pc=0x14d5edf]
2023-04-26 20:59:51+00:00 
2023-04-26 20:59:51+00:00 goroutine 1 [running]:
2023-04-26 20:59:51+00:00 sigs.k8s.io/kustomize/api/internal/builtins.(*PatchJson6902TransformerPlugin).Config(0xc002d01f90, 0xc0036b59e0?, {0xc000cb0920?, 0x1c87478?, 0x1c87440?})
2023-04-26 20:59:51+00:00 	vendor/sigs.k8s.io/kustomize/api/internal/builtins/PatchJson6902Transformer.go:34 +0x9f
2023-04-26 20:59:51+00:00 sigs.k8s.io/kustomize/api/internal/target.(*KustTarget).configureBuiltinPlugin(0xc0009c8f00?, {0x7f8389779360, 0xc002d01f90}, {0x1d2d140?, 0xc0036b59e0?}, 0x0?)
2023-04-26 20:59:51+00:00 	vendor/sigs.k8s.io/kustomize/api/internal/target/kusttarget.go:560 +0x21b
2023-04-26 20:59:51+00:00 sigs.k8s.io/kustomize/api/internal/target.glob..func5(0xc0009c8f00, 0xc000225a70?, 0x21d6a18, 0x40e047?)
+ KURL_EXIT_STATUS=1

After some digging, I discovered the following:

rafael@rafael-k8s127-dev-test-20230426200330:~/kurl/kustomize/prometheus/operator$ kubectl apply -k . --dry-run
W0427 01:17:58.944949   25048 helpers.go:692] --dry-run is deprecated and can be replaced with --dry-run=client.
# Warning: 'patchesJson6902' is deprecated. Please use 'patches' instead. Run 'kustomize edit fix' to update your Kustomization automatically.
error: trouble configuring builtin PatchTransformer with config: `
path: nodeport-services.yaml
`: unable to parse SM or JSON patch from [apiVersion: v1
kind: Service
metadata:
  name: prometheus-alertmanager
  namespace: monitoring
spec:
  ports:
  - name: web
    port: 9093
    protocol: TCP
    nodePort: 30903
  type: "NodePort"
---
apiVersion: v1
kind: Service
metadata:
  name: prometheus-k8s
  namespace: monitoring
spec:
  ports:
  - name: web
    port: 9090
    nodePort: 30900
  type: "NodePort"
---
apiVersion: v1
kind: Service
metadata:
  name: grafana
  namespace: monitoring
spec:
  type: "NodePort"
  ports:
  - name: service
    port: 80
    protocol: TCP
    nodePort: 30902
]
rafael@rafael-k8s127-dev-test-20230426200330:~/kurl/kustomize/prometheus/operator$ cat kustomization.yaml 
resources:
- grafana-secret.yaml
- default.yaml
- ns.yaml
- adapter.yaml

patchesJson6902:
- target:
    group: apps
    version: v1
    kind: DaemonSet
    name: prometheus-node-exporter
  path: matchlabel-instance.yaml
- target:
    group: apps
    version: v1
    kind: Deployment
    name: prometheus-operator
  path: matchlabel-release.yaml
patches:
- path: nodeport-services.yaml

That is, kustomize v5 does not support multi-doc patches which the prometheus addon uses. Resolved this by going back to the deprecated patchesStrategicMerge field until the issue gets fixed.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Steps to reproduce

Does this PR introduce a user-facing change?


Does this PR require documentation?

@rrpolanco rrpolanco requested a review from a team as a code owner April 27, 2023 02:22
@rrpolanco rrpolanco merged commit 26f9331 into main Apr 27, 2023
@rrpolanco rrpolanco deleted the rafaelpolanco/sc-74454/fix-k8s-127-kustomize-patches branch April 27, 2023 03:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants