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

feat: TLS support for the Prometheus web endpoint #492

Merged
merged 5 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions bundle/manifests/monitoring.rhobs_monitoringstacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,68 @@ spec:
description: Default interval between scrapes.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
webTLSConfig:
description: Configure TLS options for the Prometheus web server.
properties:
certificate:
description: Reference to the TLS public certificate for the
web server.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
minLength: 1
type: string
name:
description: The name of the secret in the object's namespace
to select from.
minLength: 1
type: string
required:
- key
- name
type: object
certificateAuthority:
description: Reference to the root Certificate Authority used
to verify the web server's certificate.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
minLength: 1
type: string
name:
description: The name of the secret in the object's namespace
to select from.
minLength: 1
type: string
required:
- key
- name
type: object
privateKey:
description: Reference to the TLS private key for the web
server.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
minLength: 1
type: string
name:
description: The name of the secret in the object's namespace
to select from.
minLength: 1
type: string
required:
- key
- name
type: object
required:
- certificate
- certificateAuthority
- privateKey
type: object
type: object
resourceSelector:
description: |-
Expand Down
62 changes: 62 additions & 0 deletions deploy/crds/common/monitoring.rhobs_monitoringstacks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1163,6 +1163,68 @@ spec:
description: Default interval between scrapes.
pattern: ^(0|(([0-9]+)y)?(([0-9]+)w)?(([0-9]+)d)?(([0-9]+)h)?(([0-9]+)m)?(([0-9]+)s)?(([0-9]+)ms)?)$
type: string
webTLSConfig:
description: Configure TLS options for the Prometheus web server.
properties:
certificate:
description: Reference to the TLS public certificate for the
web server.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
minLength: 1
type: string
name:
description: The name of the secret in the object's namespace
to select from.
minLength: 1
type: string
required:
- key
- name
type: object
certificateAuthority:
description: Reference to the root Certificate Authority used
to verify the web server's certificate.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
minLength: 1
type: string
name:
description: The name of the secret in the object's namespace
to select from.
minLength: 1
type: string
required:
- key
- name
type: object
privateKey:
description: Reference to the TLS private key for the web
server.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
minLength: 1
type: string
name:
description: The name of the secret in the object's namespace
to select from.
minLength: 1
type: string
required:
- key
- name
type: object
required:
- certificate
- certificateAuthority
- privateKey
type: object
type: object
resourceSelector:
description: |-
Expand Down
150 changes: 150 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ The resulting endpoint is /api/v1/otlp/v1/metrics.<br/>
Default interval between scrapes.<br/>
</td>
<td>false</td>
</tr><tr>
<td><b><a href="#monitoringstackspecprometheusconfigwebtlsconfig">webTLSConfig</a></b></td>
<td>object</td>
<td>
Configure TLS options for the Prometheus web server.<br/>
</td>
<td>false</td>
</tr></tbody>
</table>

Expand Down Expand Up @@ -2455,6 +2462,149 @@ Regex capture groups are available.<br/>
</table>


### MonitoringStack.spec.prometheusConfig.webTLSConfig
<sup><sup>[↩ Parent](#monitoringstackspecprometheusconfig)</sup></sup>



Configure TLS options for the Prometheus web server.

<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Required</th>
</tr>
</thead>
<tbody><tr>
<td><b><a href="#monitoringstackspecprometheusconfigwebtlsconfigcertificate">certificate</a></b></td>
<td>object</td>
<td>
Reference to the TLS public certificate for the web server.<br/>
</td>
<td>true</td>
</tr><tr>
<td><b><a href="#monitoringstackspecprometheusconfigwebtlsconfigcertificateauthority">certificateAuthority</a></b></td>
<td>object</td>
<td>
Reference to the root Certificate Authority used to verify the web server's certificate.<br/>
</td>
<td>true</td>
</tr><tr>
<td><b><a href="#monitoringstackspecprometheusconfigwebtlsconfigprivatekey">privateKey</a></b></td>
<td>object</td>
<td>
Reference to the TLS private key for the web server.<br/>
</td>
<td>true</td>
</tr></tbody>
</table>


### MonitoringStack.spec.prometheusConfig.webTLSConfig.certificate
<sup><sup>[↩ Parent](#monitoringstackspecprometheusconfigwebtlsconfig)</sup></sup>



Reference to the TLS public certificate for the web server.

<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Required</th>
</tr>
</thead>
<tbody><tr>
<td><b>key</b></td>
<td>string</td>
<td>
The key of the secret to select from. Must be a valid secret key.<br/>
</td>
<td>true</td>
</tr><tr>
<td><b>name</b></td>
<td>string</td>
<td>
The name of the secret in the object's namespace to select from.<br/>
</td>
<td>true</td>
</tr></tbody>
</table>


### MonitoringStack.spec.prometheusConfig.webTLSConfig.certificateAuthority
<sup><sup>[↩ Parent](#monitoringstackspecprometheusconfigwebtlsconfig)</sup></sup>



Reference to the root Certificate Authority used to verify the web server's certificate.

<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Required</th>
</tr>
</thead>
<tbody><tr>
<td><b>key</b></td>
<td>string</td>
<td>
The key of the secret to select from. Must be a valid secret key.<br/>
</td>
<td>true</td>
</tr><tr>
<td><b>name</b></td>
<td>string</td>
<td>
The name of the secret in the object's namespace to select from.<br/>
</td>
<td>true</td>
</tr></tbody>
</table>


### MonitoringStack.spec.prometheusConfig.webTLSConfig.privateKey
<sup><sup>[↩ Parent](#monitoringstackspecprometheusconfigwebtlsconfig)</sup></sup>



Reference to the TLS private key for the web server.

<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Description</th>
<th>Required</th>
</tr>
</thead>
<tbody><tr>
<td><b>key</b></td>
<td>string</td>
<td>
The key of the secret to select from. Must be a valid secret key.<br/>
</td>
<td>true</td>
</tr><tr>
<td><b>name</b></td>
<td>string</td>
<td>
The name of the secret in the object's namespace to select from.<br/>
</td>
<td>true</td>
</tr></tbody>
</table>


### MonitoringStack.spec.resourceSelector
<sup><sup>[↩ Parent](#monitoringstackspec)</sup></sup>

Expand Down
28 changes: 28 additions & 0 deletions pkg/apis/monitoring/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ type PrometheusConfig struct {
// Default interval between scrapes.
// +optional
ScrapeInterval *monv1.Duration `json:"scrapeInterval,omitempty"`
// Configure TLS options for the Prometheus web server.
// +optional
WebTLSConfig *WebTLSConfig `json:"webTLSConfig,omitempty"`
}

type AlertmanagerConfig struct {
Expand Down Expand Up @@ -278,3 +281,28 @@ type ThanosQuerierSpec struct {
// ThanosQuerierStatus defines the observed state of ThanosQuerier.
// It should always be reconstructable from the state of the cluster and/or outside world.
type ThanosQuerierStatus struct{}

// SecretKeySelector selects a key of a secret.
type SecretKeySelector struct {
// The name of the secret in the object's namespace to select from.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Required
Name string `json:"name"`
// The key of the secret to select from. Must be a valid secret key.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:Required
Key string `json:"key"`
}

// WebTLSConfig contains configuration to enable TLS on web endpoints.
type WebTLSConfig struct {
// Reference to the TLS private key for the web server.
// +kubebuilder:validation:Required
PrivateKey SecretKeySelector `json:"privateKey"`
// Reference to the TLS public certificate for the web server.
// +kubebuilder:validation:Required
Certificate SecretKeySelector `json:"certificate"`
// Reference to the root Certificate Authority used to verify the web server's certificate.
// +kubebuilder:validation:Required
CertificateAuthority SecretKeySelector `json:"certificateAuthority"`
}
38 changes: 38 additions & 0 deletions pkg/apis/monitoring/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading