Skip to content

vmanomaly: add spec.server.tlsConfig to serve the UI over HTTPS - #2794

Open
fred-navruzov wants to merge 4 commits into
masterfrom
vmanomaly-server-tls
Open

fred-navruzov wants to merge 4 commits into
masterfrom
vmanomaly-server-tls

Conversation

@fred-navruzov

@fred-navruzov fred-navruzov commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Why

VMAnomaly cannot serve the anomaly UI and API over HTTPS. The operator builds the vmanomaly server section from a fixed schema, so TLS options can't be set through spec.server, configRawYaml or configSecret, and users need a TLS-terminating proxy in front of the UI.

What

Add spec.server.tlsConfig, reusing the TLSConfig type already used by spec.reader.tlsConfig:

spec.server.tlsConfig generated vmanomaly server option
cert / certFile tls_cert_file
keySecret / keyFile tls_key_file
ca / caFile (optional, enables mTLS) mtls_ca_file
spec:
  server:
    tlsConfig:
      cert: {secret: {name: vmanomaly-tls, key: tls.crt}}
      keySecret: {name: vmanomaly-tls, key: tls.key}
      ca: {secret: {name: vmanomaly-tls, key: ca.crt}}  # optional: require client certificates

How

  • Secret and ConfigMap references go through the existing TLS asset cache (BuildTLSCreds), so they are mounted the same way as reader, writer and monitoring TLS assets; file paths are passed through.
  • VMAnomaly.Validate() requires a certificate and a key, and rejects insecureSkipVerify and serverName, which have no server-side meaning.
  • Liveness and readiness probes and VMPodScrape already target spec.monitoring.pull.port over plain HTTP. Validation rejects spec.server.port equal to that port when TLS is enabled, so probes never hit the TLS listener.
  • AsURL() returns https:// when TLS is enabled, so routing to the resource (for example from VMUser targetRef) uses the right scheme.
  • Regenerated deepcopy, CRDs and docs/api.md; added a docs section and a CHANGELOG entry.

Compatibility

  • No change when spec.server.tlsConfig is unset.
  • Requires vmanomaly v1.32.0 or newer, which is now released. Older versions reject these options at config validation.

Tests

  • config_test.go: secret references with mTLS and pre-mounted files map to the expected server options.
  • vmanomaly_types_test.go: validation cases and the AsURL() scheme.
  • go test for api/operator/v1, factory/vmanomaly/... and factory/vmauth; go vet and golangci-lint v2.15.0 report no issues.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread docs/resources/vmanomaly.md Resolved
Comment thread docs/resources/vmanomaly.md Resolved
Comment thread api/operator/v1/vmanomaly_types.go Resolved
Comment thread docs/CHANGELOG.md Resolved
Comment thread api/operator/v1/vmanomaly_types_test.go Resolved
Comment thread docs/resources/vmanomaly.md Resolved
// If ca or caFile is set, clients must present a certificate signed by this CA (mTLS).
// insecureSkipVerify and serverName are not supported.
// Probes and metrics scraping use the separate monitoring.pull port, which must differ from the server port.
// +optional

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// +optional
// +notes={available_from: "v0.76.0"}
// +optional

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added the v0.76.0 availability marker and regenerated docs/api.md with the pinned generator in 1f4e192.

Comment thread docs/CHANGELOG.md

* BUGFIX: [vmoperator](https://docs.victoriametrics.com/operator/): respect `http.listenAddr` set in `spec.configReloaderExtraArgs` in all config-reloader related configs, such as the container port and health probes. Previously, it was hardcoded to `8435`, which caused config-reloader probes to fail when the listen address was overridden, and multiple `hostNetwork` instances on the same node to conflict. See [#2584](https://github.com/VictoriaMetrics/operator/issues/2584). Thanks to @cesium147.

* FEATURE: [vmanomaly](https://docs.victoriametrics.com/operator/resources/vmanomaly/): add `spec.server.tlsConfig` to serve the anomaly UI and API over HTTPS, with optional client certificate verification (mTLS) when `ca` or `caFile` is set. Probes and scraping keep using the plain HTTP `spec.monitoring.pull.port`. Requires vmanomaly v1.32.0 or newer. The `VMAnomaly` CRD must be updated to use this field. See [these docs](https://docs.victoriametrics.com/operator/resources/vmanomaly/#serving-the-ui-over-https) and [#2794](https://github.com/VictoriaMetrics/operator/pull/2794).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to put it to the top on rebase

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rebased on latest master and moved the TLS feature to the top of the tip changelog in 1f4e192. Targeted VMAnomaly configuration, API and VMAuth tests pass after the rebase.

fred-navruzov and others added 4 commits November 5, 2026 13:14
Map spec.server.tlsConfig to the vmanomaly server TLS options
(tls_cert_file, tls_key_file and, for mTLS, mtls_ca_file), using the
same TLS asset handling as spec.reader.tlsConfig. Return an https URL
for the resource when TLS is enabled, and reject settings that would
make probes hit the TLS listener.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants