Files
my-rook-config/pkg/operator/ceph/cluster/utils.go
T

57 lines
1.8 KiB
Go
Raw Normal View History

/*
Copyright 2020 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Package cluster to manage a Ceph cluster.
package cluster
import (
"context"
"github.com/pkg/errors"
"github.com/rook/rook/pkg/clusterd"
"github.com/rook/rook/pkg/operator/k8sutil"
v1 "k8s.io/api/core/v1"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// populateConfigOverrideConfigMap creates the "rook-config-override" config map
// Its content allows modifying Ceph configuration flags
2021-02-18 13:10:11 +00:00
func populateConfigOverrideConfigMap(clusterdContext *clusterd.Context, namespace string, ownerInfo *k8sutil.OwnerInfo) error {
ctx := context.TODO()
placeholderConfig := map[string]string{
k8sutil.ConfigOverrideVal: "",
}
cm := &v1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
2021-02-18 13:10:11 +00:00
Name: k8sutil.ConfigOverrideName,
Namespace: namespace,
},
Data: placeholderConfig,
}
2021-02-18 13:10:11 +00:00
err := ownerInfo.SetControllerReference(cm)
if err != nil {
return errors.Wrapf(err, "failed to set owner reference to override configmap %q", cm.Name)
}
_, err = clusterdContext.Clientset.CoreV1().ConfigMaps(namespace).Create(ctx, cm, metav1.CreateOptions{})
if err != nil && !kerrors.IsAlreadyExists(err) {
return errors.Wrapf(err, "failed to create override configmap %s", namespace)
}
return nil
}