Skip to content
This repository was archived by the owner on Jul 13, 2026. It is now read-only.
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
apiVersion: v1
Comment thread
lpiwowar marked this conversation as resolved.
kind: Service
Comment thread
lpiwowar marked this conversation as resolved.
metadata:
annotations:
service.beta.openshift.io/serving-cert-secret-name: operator-metrics-tls
creationTimestamp: null
labels:
app.kubernetes.io/managed-by: kustomize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,18 @@ spec:
capabilities:
drop:
- ALL
volumeMounts:
- mountPath: /tmp/k8s-metrics-server/serving-certs
name: cert
readOnly: true
securityContext:
runAsNonRoot: true
serviceAccountName: openstack-lightspeed-operator-controller-manager
terminationGracePeriodSeconds: 10
volumes:
- name: cert
secret:
secretName: operator-metrics-tls
permissions:
- rules:
- apiGroups:
Expand Down
20 changes: 13 additions & 7 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ func main() {
var probeAddr string
var secureMetrics bool
var enableHTTP2 bool
var certDir string
var certName string
var keyName string
var tlsOpts []func(*tls.Config)
flag.StringVar(&metricsAddr, "metrics-bind-address", "0", "The address the metrics endpoint binds to. "+
"Use :8443 for HTTPS or :8080 for HTTP, or leave as 0 to disable the metrics service.")
Expand All @@ -82,6 +85,12 @@ func main() {
"If set, the metrics endpoint is served securely via HTTPS. Use --metrics-secure=false to use HTTP instead.")
flag.BoolVar(&enableHTTP2, "enable-http2", false,
"If set, HTTP/2 will be enabled for the metrics and webhook servers")
flag.StringVar(&certDir, "cert-dir", "/tmp/k8s-metrics-server/serving-certs",
"The directory where the TLS certificates are stored.")
flag.StringVar(&certName, "cert-name", "tls.crt",
"The name of the TLS certificate file.")
flag.StringVar(&keyName, "key-name", "tls.key",
"The name of the TLS key file.")
opts := zap.Options{
Development: true,
}
Expand Down Expand Up @@ -116,13 +125,10 @@ func main() {
metricsServerOptions := metricsserver.Options{
BindAddress: metricsAddr,
SecureServing: secureMetrics,
// TODO(user): TLSOpts is used to allow configuring the TLS config used for the server. If certificates are
// not provided, self-signed certificates will be generated by default. This option is not recommended for
// production environments as self-signed certificates do not offer the same level of trust and security
// as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing
// unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName
// to provide certificates, ensuring the server communicates using trusted and secure certificates.
TLSOpts: tlsOpts,
TLSOpts: tlsOpts,
CertDir: certDir,
CertName: certName,
KeyName: keyName,
}

if secureMetrics {
Expand Down
2 changes: 2 additions & 0 deletions config/default/metrics_service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ metadata:
control-plane: controller-manager
app.kubernetes.io/name: openstack-lightspeed-operator
app.kubernetes.io/managed-by: kustomize
annotations:
service.beta.openshift.io/serving-cert-secret-name: operator-metrics-tls
name: metrics
namespace: system
spec:
Expand Down
8 changes: 8 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,13 @@ spec:
requests:
cpu: 10m
memory: 64Mi
volumeMounts:
- name: cert
mountPath: /tmp/k8s-metrics-server/serving-certs
readOnly: true
serviceAccountName: controller-manager
volumes:
- name: cert
secret:
secretName: operator-metrics-tls
terminationGracePeriodSeconds: 10
Loading