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

Upgrade operator-sdk to 1.38.0 #1040

Merged
merged 15 commits into from
Feb 5, 2025
Prev Previous commit
Next Next commit
fix2
cchen-vertica committed Jan 31, 2025

Unverified

No user is associated with the committer email.
commit 7445bc8c4bb33152cff0a8ade5018fe301aaf879
7 changes: 6 additions & 1 deletion cmd/operator/main.go
Original file line number Diff line number Diff line change
@@ -288,6 +288,10 @@ func main() {
})

secureMetrics := strings.HasSuffix(opcfg.GetMetricsAddr(), "8443")
var metricCertDir string
if opcfg.GetMetricsTLSSecret() != "" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't it better to complain if EnableWithTLS but no secret is passed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That is fine. Normally, the token is good enough to verify the user's identity. No need to use tls secret for "EnableWithTLS".

metricCertDir = "/cert"
}
// Metrics endpoint is enabled in 'config/default/kustomization.yaml'. The Metrics options configure the server.
// More info:
// - https://pkg.go.dev/sigs.k8s.io/[email protected]/pkg/metrics/server
@@ -302,6 +306,7 @@ func main() {
// 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: metricsTLSOpts,
CertDir: metricCertDir,
}

if secureMetrics {
@@ -316,7 +321,7 @@ func main() {

var cacheNamespaces map[string]cache.Config
if opcfg.GetWatchNamespace() != "" {
cacheNamespaces := make(map[string]cache.Config)
cacheNamespaces = make(map[string]cache.Config)
cacheNamespaces[opcfg.GetWatchNamespace()] = cache.Config{}
}
mgr, err := ctrl.NewManager(restCfg, ctrl.Options{
2 changes: 1 addition & 1 deletion config/manager/operator-envs
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ WEBHOOKS_ENABLED
CONTROLLERS_ENABLED
CONTROLLERS_SCOPE
METRICS_ADDR
METRICS_TLS
METRICS_TLS_SECRET
METRICS_PROXY_RBAC
LOG_LEVEL
CONCURRENCY_VERTICADB
5 changes: 5 additions & 0 deletions pkg/opcfg/config.go
Original file line number Diff line number Diff line change
@@ -91,6 +91,11 @@ func GetMetricsAddr() string {
return lookupStringEnvVar("METRICS_ADDR", envCanNotExist)
}

// GetMetricsTLSSecret returns TLS secret name of the manager's Prometheus endpoint.
func GetMetricsTLSSecret() string {
return lookupStringEnvVar("METRICS_TLS_SECRET", envCanNotExist)
}

// GetUseCertManager returns true if cert-manager is used to setup the webhook's
// TLS certs.
func GetUseCertManager() bool {
7 changes: 6 additions & 1 deletion scripts/template-helm-chart.sh
Original file line number Diff line number Diff line change
@@ -114,6 +114,10 @@ do
echo "{{- end }}" >> $f
done

# 11. Template the prometheus metrics service
perl -i -pe 's/^/{{- if hasPrefix "Enable" .Values.prometheus.expose -}}\n/ if 1 .. 1' $TEMPLATE_DIR/verticadb-operator-controller-manager-metrics-service-svc.yaml
echo "{{- end }}" >> $TEMPLATE_DIR/verticadb-operator-controller-manager-metrics-service-svc.yaml

# 11. Template the roles/rolebindings for access to the rbac proxy
for f in verticadb-operator-metrics-reader-cr.yaml
do
@@ -130,8 +134,9 @@ perl -i -0777 -pe 's/(.*endpoints:)/$1\n{{- if eq "EnableWithAuthProxy" .Values.
perl -i -0777 -pe 's/(.*insecureSkipVerify:.*)/$1\n{{- else }}\n - path: \/metrics\n port: metrics\n scheme: http\n{{- end }}/g' $TEMPLATE_DIR/verticadb-operator-metrics-monitor-servicemonitor.yaml

# 13. Template the metrics bind address
perl -i -0777 -pe 's/(METRICS_TLS_SECRET: )(.*)/$1 "{{ .Values.prometheus.tlsSecret }}"/' $TEMPLATE_DIR/verticadb-operator-manager-config-cm.yaml
perl -i -0777 -pe 's/(METRICS_ADDR: )(.*)/$1 "{{ if eq "EnableWithAuthProxy" .Values.prometheus.expose }}127.0.0.1{{ end }}:{{ if eq "EnableWithAuthProxy" .Values.prometheus.expose }}8080{{ else }}8443{{ end }}"/' $TEMPLATE_DIR/verticadb-operator-manager-config-cm.yaml
perl -i -0777 -pe 's/(.*METRICS_ADDR:.*)/{{- if hasPrefix "Enable" .Values.prometheus.expose }}\n$1\n{{- else }}\n METRICS_ADDR: ""\n{{- end }}/g' $TEMPLATE_DIR/verticadb-operator-manager-config-cm.yaml
perl -i -0777 -pe 's/(.*METRICS_ADDR:.*)/{{- if hasPrefix "Enable" .Values.prometheus.expose }}\n$1\n{{- else }}\n METRICS_ADDR: "0"\n{{- end }}/g' $TEMPLATE_DIR/verticadb-operator-manager-config-cm.yaml
perl -i -0777 -pe 's/(.*ports:\n.*containerPort: 9443\n.*webhook-server.*\n.*)/$1\n{{- if hasPrefix "EnableWithoutAuth" .Values.prometheus.expose }}\n - name: metrics\n containerPort: 8443\n protocol: TCP\n{{- end }}/g' $TEMPLATE_DIR/verticadb-operator-manager-deployment.yaml

# 14. Template the rbac container