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

[Close #254] feat: support custom tls config #327

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

volker-raschek
Copy link
Contributor

The following patch adjusts the podMonitor and serviceMonitor resource. The static configuration tlsConfig is replaced so that the TLS configuration can be configured individually by the user.

The option insecureSkipVerify: true has been removed as it is a security risk. Users also have the option of redefining the insecureSkipVerify property directly via tlsConfig if necessary. With regard to the previous rbac auth option, however, this is superfluous.

Furthermore, the schema, i.e. HTTP or HTTPS, can now be defined to tell Prometheus which protocol should be used for communication.

The following sample configuration specifies that the x509-certificate-exporter encrypts requests via HTTPS and the HTTP client must authenticate itself via HTTPS (client auth).

prometheusServiceMonitor:
  tlsConfig:
    caFile: /etc/prometheus/tls/ca/ca.crt
    certFile: /etc/prometheus/tls/app2app/tls.crt
    keyFile: /etc/prometheus/tls/app2app/tls.key
    insecureSkipVerify: false
    serverName: prometheus-x509-certificate-exporter

prometheusPodMonitor:
  tlsConfig:
    caFile: /etc/prometheus/tls/ca/ca.crt
    certFile: /etc/prometheus/tls/app2app/tls.crt
    keyFile: /etc/prometheus/tls/app2app/tls.key
    insecureSkipVerify: false
    serverName: prometheus-x509-certificate-exporter

Important Note: The serverName attribute must correspond to the CommonName or a Subject Alternative Name (SAN) of the TLS certificate. If this is not the case, prometheus will reject the connection trying to match the IP address of the pod with the CommonName / SAN.

The client certificate and private key as well as the certificate of the certificate authorithy must be mounted additionally via the extraVolumes and extraVolumeMounts option. This configuration is not standard and must also be implemented by the user if TLS client authentication is required.

@volker-raschek
Copy link
Contributor Author

Here is an excerpt from my prometheus instance, which now retrieves the metrics using HTTPS authentication and encryption.

Bildschirmfoto vom 2024-09-04 18-53-30

@npdgm npdgm self-assigned this Oct 18, 2024
@npdgm npdgm added the helm label Oct 18, 2024
The following patch adjusts the podMonitor and serviceMonitor resource. The
static configuration `tlsConfig` is replaced so that the TLS configuration can be
configured individually by the user.

The option `insecureSkipVerify: true` has been removed as it is a security risk.
Users also have the option of redefining the `insecureSkipVerify` property
directly via `tlsConfig` if necessary. With regard to the previous rbac auth
option, however, this is superfluous.

Furthermore, the schema, i.e. HTTP or HTTPS, can now be defined to tell
Prometheus which protocol should be used for communication.

The following sample configuration specifies that the x509-certificate-exporter
encrypts requests via HTTPS and the HTTP client must authenticate itself via
HTTPS (client auth).

```yaml
prometheusServiceMonitor:
  tlsConfig:
    caFile: /etc/prometheus/tls/ca/ca.crt
    certFile: /etc/prometheus/tls/app2app/tls.crt
    keyFile: /etc/prometheus/tls/app2app/tls.key
    insecureSkipVerify: false
    serverName: prometheus-x509-certificate-exporter

prometheusPodMonitor:
  tlsConfig:
    caFile: /etc/prometheus/tls/ca/ca.crt
    certFile: /etc/prometheus/tls/app2app/tls.crt
    keyFile: /etc/prometheus/tls/app2app/tls.key
    insecureSkipVerify: false
    serverName: prometheus-x509-certificate-exporter
```

Important Note: The `serverName` attribute must correspond to the CommonName or a
Subject Alternative Name (SAN) of the TLS certificate. If this is not the case,
prometheus will reject the connection trying to match the IP address of the pod
with the CommonName / SAN.

The client certificate and private key as well as the certificate of the
certificate authorithy must be mounted additionally via the `extraVolumes` and
`extraVolumeMounts` option. This configuration is not standard and must also be
implemented by the user if TLS client authentication is required.

Signed-off-by: Markus Pesch <[email protected]>
@npdgm
Copy link
Member

npdgm commented Oct 18, 2024

Hi @volker-raschek
This is great, everything looks good.
Thanks for opening the PR and your thorough descriptions.
Also, sorry it took ages.

@monkeynator
Copy link
Member

🎉 This PR is included in version 3.16.0-beta.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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.

3 participants