Skip to content

Commit

Permalink
Mount config-data-custom
Browse files Browse the repository at this point in the history
Signed-off-by: Fabricio Aguiar <[email protected]>
  • Loading branch information
fao89 committed Oct 9, 2024
1 parent 9bd221e commit 6e27b4c
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 83 deletions.
11 changes: 0 additions & 11 deletions controllers/heatapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import (
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1"
)

// HeatAPIReconciler reconciles a Heat object
Expand Down Expand Up @@ -849,21 +848,11 @@ func (r *HeatAPIReconciler) generateServiceSecrets(

cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(heat.ServiceName), map[string]string{})

db, err := mariadbv1.GetDatabaseByNameAndAccount(ctx, h, heat.DatabaseCRName, instance.Spec.DatabaseAccount, instance.Namespace)
if err != nil {
return err
}
var tlsCfg *tls.Service
if instance.Spec.TLS.Ca.CaBundleSecretName != "" {
tlsCfg = &tls.Service{}
}

// customData hold any customization for the service.
// custom.conf is going to /etc/heat/heat.conf.d
// TODO: make sure custom.conf can not be overwritten
customData := map[string]string{
heat.CustomServiceConfigFileName: instance.Spec.CustomServiceConfig,
"my.cnf": db.GetDatabaseClientConfig(tlsCfg), //(mschuppert) for now just get the default my.cnf
}

for key, data := range instance.Spec.DefaultConfigOverwrite {
Expand Down
11 changes: 0 additions & 11 deletions controllers/heatcfnapi_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ import (
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1"
)

// HeatCfnAPIReconciler reconciles a Heat object
Expand Down Expand Up @@ -846,21 +845,11 @@ func (r *HeatCfnAPIReconciler) generateServiceSecrets(

cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(heat.CfnServiceName), map[string]string{})

db, err := mariadbv1.GetDatabaseByNameAndAccount(ctx, h, heat.DatabaseCRName, instance.Spec.DatabaseAccount, instance.Namespace)
if err != nil {
return err
}
var tlsCfg *tls.Service
if instance.Spec.TLS.Ca.CaBundleSecretName != "" {
tlsCfg = &tls.Service{}
}

// customData hold any customization for the service.
// custom.conf is going to /etc/heat/heat.conf.d
// TODO: make sure custom.conf can not be overwritten
customData := map[string]string{
heat.CustomServiceConfigFileName: instance.Spec.CustomServiceConfig,
"my.cnf": db.GetDatabaseClientConfig(tlsCfg), //(mschuppert) for now just get the default my.cnf
}

for key, data := range instance.Spec.DefaultConfigOverwrite {
Expand Down
11 changes: 0 additions & 11 deletions controllers/heatengine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ import (
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1"
)

// HeatEngineReconciler reconciles a Heat object
Expand Down Expand Up @@ -558,21 +557,11 @@ func (r *HeatEngineReconciler) generateServiceSecrets(

cmLabels := labels.GetLabels(instance, labels.GetGroupLabel(heat.ServiceName), map[string]string{})

db, err := mariadbv1.GetDatabaseByNameAndAccount(ctx, h, heat.DatabaseCRName, instance.Spec.DatabaseAccount, instance.Namespace)
if err != nil {
return err
}
var tlsCfg *tls.Service
if instance.Spec.TLS.CaBundleSecretName != "" {
tlsCfg = &tls.Service{}
}

// customData hold any customization for the service.
// custom.conf is going to /etc/heat/heat.conf.d
// TODO: make sure custom.conf can not be overwritten
customData := map[string]string{
heat.CustomServiceConfigFileName: instance.Spec.CustomServiceConfig,
"my.cnf": db.GetDatabaseClientConfig(tlsCfg), //(mschuppert) for now just get the default my.cnf
}

for key, data := range instance.Spec.DefaultConfigOverwrite {
Expand Down
6 changes: 0 additions & 6 deletions pkg/heat/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ func GetVolumes(name string) []corev1.Volume {
},
},
},
{
Name: "config-data-merged",
VolumeSource: corev1.VolumeSource{
EmptyDir: &corev1.EmptyDirVolumeSource{Medium: ""},
},
},
}
}

Expand Down
9 changes: 8 additions & 1 deletion pkg/heatapi/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (

// getVolumes -
func getVolumes(parentName string, name string) []corev1.Volume {
var config0644AccessMode int32 = 0644

volumes := []corev1.Volume{
{
Name: "config-data-custom",
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: name + "-config-data",
DefaultMode: &config0644AccessMode,
SecretName: name + "-config-data",
},
},
},
Expand All @@ -32,6 +34,11 @@ func getVolumeMounts() []corev1.VolumeMount {
SubPath: "heat-api-config.json",
ReadOnly: true,
},
{
Name: "config-data-custom",
MountPath: "/etc/heat/heat.conf.d",
ReadOnly: true,
},
}

return append(heat.GetVolumeMounts(), volumeMounts...)
Expand Down
9 changes: 8 additions & 1 deletion pkg/heatcfnapi/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (

// getVolumes -
func getVolumes(parentName string, name string) []corev1.Volume {
var config0644AccessMode int32 = 0644

volumes := []corev1.Volume{
{
Name: "config-data-custom",
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: name + "-config-data",
DefaultMode: &config0644AccessMode,
SecretName: name + "-config-data",
},
},
},
Expand All @@ -32,6 +34,11 @@ func getVolumeMounts() []corev1.VolumeMount {
SubPath: "heat-cfnapi-config.json",
ReadOnly: true,
},
{
Name: "config-data-custom",
MountPath: "/etc/heat/heat.conf.d",
ReadOnly: true,
},
}

return append(heat.GetVolumeMounts(), volumeMounts...)
Expand Down
9 changes: 8 additions & 1 deletion pkg/heatengine/volumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import (

// getVolumes -
func getVolumes(parentName string, name string) []corev1.Volume {
var config0644AccessMode int32 = 0644

volumes := []corev1.Volume{
{
Name: "config-data-custom",
VolumeSource: corev1.VolumeSource{
Secret: &corev1.SecretVolumeSource{
SecretName: name + "-config-data",
DefaultMode: &config0644AccessMode,
SecretName: name + "-config-data",
},
},
},
Expand All @@ -32,6 +34,11 @@ func getVolumeMounts() []corev1.VolumeMount {
SubPath: "heat-engine-config.json",
ReadOnly: true,
},
{
Name: "config-data-custom",
MountPath: "/etc/heat/heat.conf.d",
ReadOnly: true,
},
}

return append(heat.GetVolumeMounts(), volumeMounts...)
Expand Down
12 changes: 0 additions & 12 deletions templates/heat/config/heat-api-config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"command": "/usr/sbin/httpd -DFOREGROUND",
"config_files": [
{
"source": "/var/lib/config-data/default/0*.conf",
"dest": "/etc/heat/heat.conf.d/",
"merge": false,
"preserve_properties": true,
"perm": "0644"
},
{
"source": "/var/lib/config-data/default/heat-api-httpd.conf",
"dest": "/etc/httpd/conf/httpd.conf",
Expand Down Expand Up @@ -39,11 +32,6 @@
}
],
"permissions": [
{
"path": "/etc/heat/heat.conf.d",
"owner": "heat:heat",
"recurse": true
},
{
"path": "/etc/httpd/",
"owner": "apache:apache",
Expand Down
12 changes: 0 additions & 12 deletions templates/heat/config/heat-cfnapi-config.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
{
"command": "/usr/sbin/httpd -DFOREGROUND",
"config_files": [
{
"source": "/var/lib/config-data/default/0*.conf",
"dest": "/etc/heat/heat.conf.d/",
"merge": false,
"preserve_properties": true,
"perm": "0644"
},
{
"source": "/var/lib/config-data/default/heat-cfnapi-httpd.conf",
"dest": "/etc/httpd/conf/httpd.conf",
Expand Down Expand Up @@ -39,11 +32,6 @@
}
],
"permissions": [
{
"path": "/etc/heat/heat.conf.d",
"owner": "heat:heat",
"recurse": true
},
{
"path": "/etc/httpd/",
"owner": "apache:apache",
Expand Down
18 changes: 1 addition & 17 deletions templates/heat/config/heat-engine-config.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
{
"command": "/usr/bin/heat-engine --config-dir /etc/heat/heat.conf.d",
"config_files": [
{
"source": "/var/lib/config-data/default/0*.conf",
"dest": "/etc/heat/heat.conf.d/",
"merge": false,
"preserve_properties": true,
"perm": "0644"
}
],
"permissions": [
{
"path": "/etc/heat/heat.conf.d",
"owner": "heat:heat",
"recurse": true
}
]
"command": "/usr/bin/heat-engine --config-dir /etc/heat/heat.conf.d"
}

0 comments on commit 6e27b4c

Please sign in to comment.