VictoriaMetrics / operator

Kubernetes operator for Victoria Metrics
Apache License 2.0
406 stars 142 forks source link

bearerTokenSecret missing on Conversion from ServiceMonitor to VMServiceScrape since 0.43.0 #932

Closed marrau closed 2 months ago

marrau commented 2 months ago

When Upgrading from 0.42.4 to 0.43.1 any ServiceMonitor with a bearerTokenSecret set, gets Permission denied on scraping.

Example:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: test-service
spec:
  endpoints:
  - bearerTokenSecret:
      key: PRIVATE_API_KEY
      name: test-secret
    honorLabels: false
    interval: 15s
    path: /metrics
    scrapeTimeout: 15s
    targetPort: 80
  jobLabel: test
  selector:
    matchLabels:
      test: test

Result on 0.43.+ (shortened Output):

apiVersion: operator.victoriametrics.com/v1beta1
kind: VMServiceScrape
metadata:
  name: test-service
spec:
  attach_metadata: {}
  endpoints:
  - attach_metadata: {}
    interval: 15s
    path: /metrics
    scrapeTimeout: 15s
    targetPort: 80
  jobLabel: test
  namespaceSelector: {}
  selector:
    matchLabels:
      test: test

Result on 0.42.4 (shortened Output):

apiVersion: operator.victoriametrics.com/v1beta1
kind: VMServiceScrape
metadata:
  name: test-service
spec:
  endpoints:
  - attach_metadata: {}
    bearerTokenSecret:
      key: PRIVATE_API_KEY
      name: test-secret
    interval: 15s
    path: /metrics
    scrapeTimeout: 15s
    targetPort: 80
  jobLabel: test
  namespaceSelector: {}
  selector:
    matchLabels:
      test: test
marrau commented 2 months ago

Found it to be removed in Commit 0500abb

f41gh7 commented 2 months ago

Looks like bug to me, @Haleygo can you confirm?

Haleygo commented 2 months ago

Hi @marrau , Thanks for the issue, it should be fixed in https://github.com/VictoriaMetrics/operator/pull/935. JFYI, prometheus operator has marked BearerTokenSecret as deprecated and recommended to use authorization instead.

Haleygo commented 2 months ago

The fix is released in https://github.com/VictoriaMetrics/operator/releases/tag/v0.43.3, close this as completed, feel free to reopen if there is further question.