Skip to content

Commit

Permalink
[tlse] TLS for telemetry ceilometer, metricstorage
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzigold committed Mar 20, 2024
1 parent a5d2738 commit c659172
Show file tree
Hide file tree
Showing 10 changed files with 253 additions and 46 deletions.
35 changes: 25 additions & 10 deletions apis/bases/core.openstack.org_openstackcontrolplanes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15429,11 +15429,11 @@ spec:
customServiceConfig:
default: '# add your customization here'
type: string
databaseInstance:
type: string
databaseUser:
databaseAccount:
default: aodh
type: string
databaseInstance:
type: string
defaultConfigOverwrite:
additionalProperties:
type: string
Expand Down Expand Up @@ -15505,14 +15505,10 @@ spec:
passwordSelector:
default:
aodhService: AodhPassword
database: AodhDatabasePassword
properties:
aodhService:
default: AodhPassword
type: string
database:
default: AodhDatabasePassword
type: string
service:
default: CeilometerPassword
type: string
Expand Down Expand Up @@ -15568,6 +15564,8 @@ spec:
maximum: 65535
minimum: 1
type: integer
prometheusTLS:
type: boolean
required:
- heatInstance
type: object
Expand Down Expand Up @@ -15602,13 +15600,12 @@ spec:
aodhService:
default: AodhPassword
type: string
database:
default: AodhDatabasePassword
type: string
service:
default: CeilometerPassword
type: string
type: object
proxyImage:
type: string
rabbitMqClusterName:
default: rabbitmq
type: string
Expand All @@ -15619,11 +15616,19 @@ spec:
type: string
sgCoreImage:
type: string
tls:
properties:
caBundleSecretName:
type: string
secretName:
type: string
type: object
required:
- centralImage
- computeImage
- ipmiImage
- notificationImage
- proxyImage
- secret
- sgCoreImage
type: object
Expand Down Expand Up @@ -16217,6 +16222,9 @@ spec:
alertingEnabled:
default: true
type: boolean
dashboardsEnabled:
default: false
type: boolean
dataplaneNetwork:
default: ctlplane
pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9]$
Expand Down Expand Up @@ -16275,6 +16283,13 @@ spec:
required:
- dataplaneNetwork
type: object
prometheusTls:
properties:
caBundleSecretName:
type: string
secretName:
type: string
type: object
type: object
type: object
type: object
Expand Down
23 changes: 11 additions & 12 deletions apis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ module github.com/openstack-k8s-operators/openstack-operator/apis
go 1.20

require (
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect
github.com/onsi/ginkgo/v2 v2.16.0
github.com/onsi/gomega v1.31.1
github.com/openstack-k8s-operators/barbican-operator/api v0.0.0-20240310115941-5124bc86e50e
Expand All @@ -24,13 +28,18 @@ require (
github.com/openstack-k8s-operators/ovn-operator/api v0.3.1-0.20240318052728-f132fab5c943
github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20240313145348-1dd69c7bc338
github.com/openstack-k8s-operators/swift-operator/api v0.3.1-0.20240315154317-8b38ff1e6a8d
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240311060559-4ecd4f5c3961
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240320060823-d7b27511017b
github.com/rabbitmq/cluster-operator/v2 v2.6.0
github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.64.1-rhobs3 // indirect
github.com/rhobs/observability-operator v0.0.20 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect
golang.org/x/tools v0.18.0 // indirect
k8s.io/api v0.28.8
k8s.io/apimachinery v0.28.8
k8s.io/client-go v0.28.8
sigs.k8s.io/controller-runtime v0.16.5

)

require (
Expand All @@ -41,18 +50,14 @@ require (
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.20.2 // indirect
github.com/go-openapi/jsonreference v0.20.4 // indirect
github.com/go-openapi/swag v0.22.9 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gophercloud/gophercloud v1.11.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
Expand All @@ -69,20 +74,14 @@ require (
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.46.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.64.1-rhobs3 // indirect
github.com/rhobs/observability-operator v0.0.20 // indirect
github.com/robfig/cron/v3 v3.0.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240213143201-ec583247a57a // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/oauth2 v0.16.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.18.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/protobuf v1.33.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions apis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I=
github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U=
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 h1:0VpGH+cDhbDtdcweoyCVsF3fhN8kejK6rFe/2FFX2nU=
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49/go.mod h1:BkkQ4L1KS1xMt2aWSPStnn55ChGC0DPOn2FQYj+f25M=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
Expand Down Expand Up @@ -113,8 +113,8 @@ github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.2024031314534
github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20240313145348-1dd69c7bc338/go.mod h1:i7bl0Vg4iyaOR4GCfduMWq0V9k5h9ltKDnx0hZg1JDE=
github.com/openstack-k8s-operators/swift-operator/api v0.3.1-0.20240315154317-8b38ff1e6a8d h1:O4nJMsX3pS3X3CUw7/wjgJXoTIPA68pJowA1CfQP6IM=
github.com/openstack-k8s-operators/swift-operator/api v0.3.1-0.20240315154317-8b38ff1e6a8d/go.mod h1:/7+Ld3BHb9RDaHhXKEtCiWQmhVwpRLVeLutZxyHRPpM=
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240311060559-4ecd4f5c3961 h1:YYeHx9q2/ohmCwezfdw+qDJywpSZVgo9Ud24Oyie2J4=
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240311060559-4ecd4f5c3961/go.mod h1:QUHaxzPPQ1OzWvG8BJIE+D1LSpm+bdv2yfrXHXiYQ+4=
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240320060823-d7b27511017b h1:/+tzjO+2Zsw4dctl0LwdoFTAEe8E2uWEheG292GSito=
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240320060823-d7b27511017b/go.mod h1:y8v2Hv01KPkUIxZf6tCn3TWu7vNjmG65tvAMJFkKG6E=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
Expand Down
35 changes: 25 additions & 10 deletions config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15429,11 +15429,11 @@ spec:
customServiceConfig:
default: '# add your customization here'
type: string
databaseInstance:
type: string
databaseUser:
databaseAccount:
default: aodh
type: string
databaseInstance:
type: string
defaultConfigOverwrite:
additionalProperties:
type: string
Expand Down Expand Up @@ -15505,14 +15505,10 @@ spec:
passwordSelector:
default:
aodhService: AodhPassword
database: AodhDatabasePassword
properties:
aodhService:
default: AodhPassword
type: string
database:
default: AodhDatabasePassword
type: string
service:
default: CeilometerPassword
type: string
Expand Down Expand Up @@ -15568,6 +15564,8 @@ spec:
maximum: 65535
minimum: 1
type: integer
prometheusTLS:
type: boolean
required:
- heatInstance
type: object
Expand Down Expand Up @@ -15602,13 +15600,12 @@ spec:
aodhService:
default: AodhPassword
type: string
database:
default: AodhDatabasePassword
type: string
service:
default: CeilometerPassword
type: string
type: object
proxyImage:
type: string
rabbitMqClusterName:
default: rabbitmq
type: string
Expand All @@ -15619,11 +15616,19 @@ spec:
type: string
sgCoreImage:
type: string
tls:
properties:
caBundleSecretName:
type: string
secretName:
type: string
type: object
required:
- centralImage
- computeImage
- ipmiImage
- notificationImage
- proxyImage
- secret
- sgCoreImage
type: object
Expand Down Expand Up @@ -16217,6 +16222,9 @@ spec:
alertingEnabled:
default: true
type: boolean
dashboardsEnabled:
default: false
type: boolean
dataplaneNetwork:
default: ctlplane
pattern: ^[a-zA-Z0-9][a-zA-Z0-9\-_]*[a-zA-Z0-9]$
Expand Down Expand Up @@ -16275,6 +16283,13 @@ spec:
required:
- dataplaneNetwork
type: object
prometheusTls:
properties:
caBundleSecretName:
type: string
secretName:
type: string
type: object
type: object
type: object
type: object
Expand Down
45 changes: 45 additions & 0 deletions controllers/client/openstackclient_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import (
helper "github.com/openstack-k8s-operators/lib-common/modules/common/helper"
common_rbac "github.com/openstack-k8s-operators/lib-common/modules/common/rbac"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
telemetryv1 "github.com/openstack-k8s-operators/telemetry-operator/api/v1beta1"

"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
Expand All @@ -72,6 +73,7 @@ func (r *OpenStackClientReconciler) GetLogger(ctx context.Context) logr.Logger {
//+kubebuilder:rbac:groups=client.openstack.org,resources=openstackclients/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=client.openstack.org,resources=openstackclients/finalizers,verbs=update
//+kubebuilder:rbac:groups=keystone.openstack.org,resources=keystoneapis,verbs=get;list;watch
//+kubebuilder:rbac:groups=telemetry.openstack.org,resources=metricstorages,verbs=get;list;watch
//+kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch;
//+kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;
// service account, role, rolebinding
Expand Down Expand Up @@ -275,6 +277,15 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
configVars[instance.Spec.CaBundleSecretName] = env.SetValue(secretHash)
}

metricStorage := &telemetryv1.MetricStorage{}
err = helper.GetClient().Get(ctx, client.ObjectKey{
Namespace: instance.Namespace,
Name: telemetryv1.DefaultServiceName,
}, metricStorage)
if err == nil {
configVars["PrometheusTls"] = env.SetValue(fmt.Sprint(metricStorage.Spec.PrometheusTLS.Enabled()))
}

configVarsHash, err := util.HashOfInputHashes(configVars)
if err != nil {
return ctrl.Result{}, err
Expand Down Expand Up @@ -453,6 +464,33 @@ func (r *OpenStackClientReconciler) SetupWithManager(mgr ctrl.Manager) error {
return err
}

Log := r.GetLogger(context.Background())
metricStorageFn := func(ctx context.Context, o client.Object) []reconcile.Request {
result := []reconcile.Request{}

// get all openstackclient CRs
openstackclients := &clientv1.OpenStackClientList{}
listOpts := []client.ListOption{
client.InNamespace(o.GetNamespace()),
}
if err := r.Client.List(context.Background(), openstackclients, listOpts...); err != nil {
Log.Error(err, "Unable to retrieve OpenstackClient CRs %v")
return nil
}
for _, cr := range openstackclients.Items {
name := client.ObjectKey{
Namespace: o.GetNamespace(),
Name: cr.Name,
}
Log.Info(fmt.Sprintf("OpenStackClient %s will be reconciled, because a MetricStorage %s changed", cr.Name, o.GetName()))
result = append(result, reconcile.Request{NamespacedName: name})
}
if len(result) > 0 {
return result
}
return nil
}

return ctrl.NewControllerManagedBy(mgr).
For(&clientv1.OpenStackClient{}).
Owns(&corev1.Pod{}).
Expand All @@ -474,6 +512,13 @@ func (r *OpenStackClientReconciler) SetupWithManager(mgr ctrl.Manager) error {
handler.EnqueueRequestsFromMapFunc(r.findObjectsForSrc),
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
).
Watches(
// Reconcile all openstackclients when a MetricStorage changes.
// This is needed to ensure the observability client is
// configured correctly when tls is enabled or disabled.
&telemetryv1.MetricStorage{},
handler.EnqueueRequestsFromMapFunc(metricStorageFn),
).
Complete(r)
}

Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require (
github.com/openstack-k8s-operators/ovn-operator/api v0.3.1-0.20240318052728-f132fab5c943
github.com/openstack-k8s-operators/placement-operator/api v0.3.1-0.20240313145348-1dd69c7bc338
github.com/openstack-k8s-operators/swift-operator/api v0.3.1-0.20240315154317-8b38ff1e6a8d
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240311060559-4ecd4f5c3961
github.com/openstack-k8s-operators/telemetry-operator/api v0.3.1-0.20240320060823-d7b27511017b
github.com/operator-framework/api v0.20.0
github.com/rabbitmq/cluster-operator/v2 v2.6.0
go.uber.org/zap v1.27.0
Expand All @@ -63,7 +63,7 @@ require (
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20230926050212-f7f687d19a98 // indirect
Expand Down
Loading

0 comments on commit c659172

Please sign in to comment.