Files
my-rook-config/pkg/operator/ceph/file/mirror/config.go
T

63 lines
1.8 KiB
Go
Raw Normal View History

2021-01-18 18:57:11 +01:00
/*
Copyright 2021 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 mirror
import (
"fmt"
"github.com/rook/rook/pkg/operator/ceph/config"
"github.com/rook/rook/pkg/operator/ceph/config/keyring"
2021-02-18 13:10:11 +00:00
"github.com/rook/rook/pkg/operator/k8sutil"
2021-01-18 18:57:11 +01:00
)
const (
keyringTemplate = `
2021-02-22 14:54:15 +01:00
[client.fs-mirror]
2021-01-18 18:57:11 +01:00
key = %s
2021-04-08 15:44:27 +02:00
caps mon = "allow profile cephfs-mirror"
2021-01-18 18:57:11 +01:00
caps mgr = "allow r"
caps mds = "allow r"
caps osd = "'allow rw tag cephfs metadata=*, allow r tag cephfs data=*'"
`
2021-02-22 14:54:15 +01:00
user = "client.fs-mirror"
userID = "fs-mirror"
2021-01-18 18:57:11 +01:00
)
// daemonConfig for a single rbd-mirror
type daemonConfig struct {
ResourceName string // the name rook gives to mirror resources in k8s metadata
DataPathMap *config.DataPathMap // location to store data in container
2021-02-18 13:10:11 +00:00
ownerInfo *k8sutil.OwnerInfo
2021-01-18 18:57:11 +01:00
}
func (r *ReconcileFilesystemMirror) generateKeyring(daemonConfig *daemonConfig) (string, error) {
2021-01-18 18:57:11 +01:00
access := []string{
2021-04-08 15:44:27 +02:00
"mon", "allow profile cephfs-mirror",
2021-01-18 18:57:11 +01:00
"mgr", "allow r",
"mds", "allow r",
"osd", "allow rw tag cephfs metadata=*, allow r tag cephfs data=*",
}
s := keyring.GetSecretStore(r.context, r.clusterInfo, daemonConfig.ownerInfo)
2021-01-18 18:57:11 +01:00
key, err := s.GenerateKey(user, access)
if err != nil {
return "", err
}
2021-02-22 14:54:15 +01:00
keyring := fmt.Sprintf(keyringTemplate, key)
2021-01-18 18:57:11 +01:00
return keyring, s.CreateOrUpdate(daemonConfig.ResourceName, keyring)
}