2016-11-10 10:59:26 -08:00
|
|
|
/*
|
|
|
|
|
Copyright 2016 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.
|
|
|
|
|
*/
|
2018-08-31 13:39:02 -06:00
|
|
|
|
2016-11-10 10:59:26 -08:00
|
|
|
package osd
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
|
|
"path"
|
|
|
|
|
|
2017-06-02 13:44:54 -07:00
|
|
|
"github.com/rook/rook/pkg/clusterd"
|
2020-07-01 22:46:39 -06:00
|
|
|
cephclient "github.com/rook/rook/pkg/daemon/ceph/client"
|
2016-11-10 10:59:26 -08:00
|
|
|
)
|
|
|
|
|
|
2017-09-22 17:54:03 -07:00
|
|
|
const (
|
2018-12-07 08:28:47 -07:00
|
|
|
bootstrapOsdKeyring = "bootstrap-osd/ceph.keyring"
|
2017-09-22 17:54:03 -07:00
|
|
|
)
|
|
|
|
|
|
2016-11-10 10:59:26 -08:00
|
|
|
// create a keyring for the bootstrap-osd client, it gets a limited set of privileges
|
2021-04-19 00:06:10 -07:00
|
|
|
func createOSDBootstrapKeyring(context *clusterd.Context, clusterInfo *cephclient.ClusterInfo, rootDir string) error {
|
2016-11-21 14:24:07 -08:00
|
|
|
username := "client.bootstrap-osd"
|
2018-12-07 08:28:47 -07:00
|
|
|
keyringPath := path.Join(rootDir, bootstrapOsdKeyring)
|
2016-11-21 14:24:07 -08:00
|
|
|
access := []string{"mon", "allow profile bootstrap-osd"}
|
|
|
|
|
keyringEval := func(key string) string {
|
|
|
|
|
return fmt.Sprintf(bootstrapOSDKeyringTemplate, key)
|
2016-11-10 10:59:26 -08:00
|
|
|
}
|
|
|
|
|
|
2020-07-10 16:40:16 -06:00
|
|
|
return cephclient.CreateKeyring(context, clusterInfo, username, keyringPath, access, keyringEval)
|
2016-11-10 10:59:26 -08:00
|
|
|
}
|