You can now use Rook along with Multus. Multus must be up and running
and the right ressources must exist such as NetworkAttachmentDefinition
CR.
The Cluster CR spec has new fields to work with multus:
network:
provider: multus (or 'host' for hostNetworking)
selectors:
public: NetworkAttachmentDefinition name
cluster: NetworkAttachmentDefinition name
If only a single NetworkAttachmentDefinition is provided Rook will use
both anyway for the Ceph traffic.
Please refer to the doc to learn more.
Closes: https://github.com/rook/rook/issues/4716
Signed-off-by: Sébastien Han <seb@redhat.com>
114 lines
3.9 KiB
Go
114 lines
3.9 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 rbd
|
|
|
|
import (
|
|
"github.com/rook/rook/pkg/operator/ceph/cluster/mon"
|
|
"github.com/rook/rook/pkg/operator/ceph/config"
|
|
"github.com/rook/rook/pkg/operator/ceph/controller"
|
|
"github.com/rook/rook/pkg/operator/k8sutil"
|
|
apps "k8s.io/api/apps/v1"
|
|
v1 "k8s.io/api/core/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
)
|
|
|
|
func (m *Mirroring) makeDeployment(daemonConfig *daemonConfig) *apps.Deployment {
|
|
podSpec := v1.PodTemplateSpec{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: daemonConfig.ResourceName,
|
|
Labels: controller.PodLabels(AppName, m.Namespace, config.RbdMirrorType, daemonConfig.DaemonID),
|
|
},
|
|
Spec: v1.PodSpec{
|
|
InitContainers: []v1.Container{
|
|
m.makeChownInitContainer(daemonConfig),
|
|
},
|
|
Containers: []v1.Container{
|
|
m.makeMirroringDaemonContainer(daemonConfig),
|
|
},
|
|
RestartPolicy: v1.RestartPolicyAlways,
|
|
Volumes: controller.DaemonVolumes(daemonConfig.DataPathMap, daemonConfig.ResourceName),
|
|
HostNetwork: m.Network.IsHost(),
|
|
PriorityClassName: m.priorityClassName,
|
|
},
|
|
}
|
|
// Replace default unreachable node toleration
|
|
k8sutil.AddUnreachableNodeToleration(&podSpec.Spec)
|
|
|
|
if m.Network.IsHost() {
|
|
podSpec.Spec.DNSPolicy = v1.DNSClusterFirstWithHostNet
|
|
} else if m.Network.NetworkSpec.IsMultus() {
|
|
k8sutil.ApplyMultus(m.Network.NetworkSpec, &podSpec.ObjectMeta)
|
|
}
|
|
m.placement.ApplyToPodSpec(&podSpec.Spec)
|
|
|
|
replicas := int32(1)
|
|
d := &apps.Deployment{
|
|
ObjectMeta: metav1.ObjectMeta{
|
|
Name: daemonConfig.ResourceName,
|
|
Namespace: m.Namespace,
|
|
Annotations: m.annotations,
|
|
Labels: controller.PodLabels(AppName, m.Namespace, config.RbdMirrorType, daemonConfig.DaemonID),
|
|
},
|
|
Spec: apps.DeploymentSpec{
|
|
Selector: &metav1.LabelSelector{
|
|
MatchLabels: podSpec.Labels,
|
|
},
|
|
Template: podSpec,
|
|
Replicas: &replicas,
|
|
},
|
|
}
|
|
k8sutil.AddRookVersionLabelToDeployment(d)
|
|
controller.AddCephVersionLabelToDeployment(m.ClusterInfo.CephVersion, d)
|
|
k8sutil.SetOwnerRef(&d.ObjectMeta, &m.ownerRef)
|
|
return d
|
|
}
|
|
|
|
func (m *Mirroring) makeChownInitContainer(daemonConfig *daemonConfig) v1.Container {
|
|
return controller.ChownCephDataDirsInitContainer(
|
|
*daemonConfig.DataPathMap,
|
|
m.cephVersion.Image,
|
|
controller.DaemonVolumeMounts(daemonConfig.DataPathMap, daemonConfig.ResourceName),
|
|
m.resources,
|
|
mon.PodSecurityContext(),
|
|
)
|
|
}
|
|
|
|
func (m *Mirroring) makeMirroringDaemonContainer(daemonConfig *daemonConfig) v1.Container {
|
|
container := v1.Container{
|
|
Name: "rbd-mirror",
|
|
Command: []string{
|
|
"rbd-mirror",
|
|
},
|
|
Args: append(
|
|
controller.DaemonFlags(m.ClusterInfo, daemonConfig.DaemonID),
|
|
"--foreground",
|
|
"--name="+fullDaemonName(daemonConfig.DaemonID),
|
|
),
|
|
Image: m.cephVersion.Image,
|
|
VolumeMounts: controller.DaemonVolumeMounts(daemonConfig.DataPathMap, daemonConfig.ResourceName),
|
|
Env: controller.DaemonEnvVars(m.cephVersion.Image),
|
|
Resources: m.resources,
|
|
SecurityContext: mon.PodSecurityContext(),
|
|
// TODO:
|
|
// Not implemented at this point since the socket name is '/run/ceph/ceph-client.rbd-mirror.a.1.94362516231272.asok'
|
|
// Also the command to run will be:
|
|
// ceph --admin-daemon /run/ceph/ceph-client.rbd-mirror.a.1.94362516231272.asok rbd mirror status
|
|
// LivenessProbe: controller.GenerateLivenessProbeExecDaemon(config.RbdMirrorType, daemonConfig.DaemonID),
|
|
}
|
|
return container
|
|
}
|