Make the Rook config-init unnecessary for mons, and remove that init container. Perform all mon configuration steps in the operator, and set up the mon pods and k8s environment such that only Ceph containers are needed for running mons. This should help streamline changes to the mons, as there will be no need to change the `daemon/mon` code or `cmd/rook/ceph` code with mon changes in the future. This work starts to lay the groundwork for supporting the `design/ceph-config-updates.md` design. Notable new bits: Create a keyring secret store helper for storing dameon keyrings, and use it to store the mon keyring. Mon pods mount the keyring into a k8s secret-backed volume. Create a configmap store for the Ceph config file which can be mounted into pods/containers directly to /etc/ceph/ceph.conf. Also store individual mon_host and mon_initial_members values which can be mapped into pods as environment variables and used in Ceph commandline flags, enabling the mon pods to have the most up-to-date information about the mon cluster when restarting and without need for operator intervention. Signed-off-by: Blaine Gardner <blaine.gardner@suse.com>
49 lines
1.5 KiB
Go
49 lines
1.5 KiB
Go
/*
|
|
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.
|
|
*/
|
|
|
|
package mon
|
|
|
|
import (
|
|
"testing"
|
|
|
|
cephconfig "github.com/rook/rook/pkg/daemon/ceph/config"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMonFlattening(t *testing.T) {
|
|
|
|
// single endpoint
|
|
mons := map[string]*cephconfig.MonInfo{
|
|
"foo": {Name: "foo", Endpoint: "1.2.3.4:5000"},
|
|
}
|
|
flattened := FlattenMonEndpoints(mons)
|
|
assert.Equal(t, "foo=1.2.3.4:5000", flattened)
|
|
parsed := ParseMonEndpoints(flattened)
|
|
assert.Equal(t, 1, len(parsed))
|
|
assert.Equal(t, "foo", parsed["foo"].Name)
|
|
assert.Equal(t, "1.2.3.4:5000", parsed["foo"].Endpoint)
|
|
|
|
// multiple endpoints
|
|
mons["bar"] = &cephconfig.MonInfo{Name: "bar", Endpoint: "2.3.4.5:6000"}
|
|
flattened = FlattenMonEndpoints(mons)
|
|
parsed = ParseMonEndpoints(flattened)
|
|
assert.Equal(t, 2, len(parsed))
|
|
assert.Equal(t, "foo", parsed["foo"].Name)
|
|
assert.Equal(t, "1.2.3.4:5000", parsed["foo"].Endpoint)
|
|
assert.Equal(t, "bar", parsed["bar"].Name)
|
|
assert.Equal(t, "2.3.4.5:6000", parsed["bar"].Endpoint)
|
|
}
|