Merge pull request #11807 from rook/mergify/bp/release-1.11/pr-11797
ceph: add osd container ports only if mcs is enabled (backport #11797)
This commit is contained in:
1 file changed
+65
-53
@@ -583,30 +583,6 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC
|
||||
"",
|
||||
))
|
||||
|
||||
var ports []v1.ContainerPort
|
||||
if c.spec.RequireMsgr2() {
|
||||
ports = []v1.ContainerPort{
|
||||
{
|
||||
Name: "osd-port-v2",
|
||||
ContainerPort: osdPortv2,
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
ports = []v1.ContainerPort{
|
||||
{
|
||||
Name: "osd-port-v1",
|
||||
ContainerPort: osdPortv1,
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
{
|
||||
Name: "osd-port-v2",
|
||||
ContainerPort: osdPortv2,
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
podTemplateSpec := v1.PodTemplateSpec{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: AppName,
|
||||
@@ -634,7 +610,6 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC
|
||||
StartupProbe: controller.GenerateStartupProbeExecDaemon(opconfig.OsdType, osdID),
|
||||
LivenessProbe: controller.GenerateLivenessProbeExecDaemon(opconfig.OsdType, osdID),
|
||||
WorkingDir: opconfig.VarLogCephDir,
|
||||
Ports: ports,
|
||||
},
|
||||
},
|
||||
Volumes: volumes,
|
||||
@@ -642,6 +617,11 @@ func (c *Cluster) makeDeployment(osdProps osdProperties, osd OSDInfo, provisionC
|
||||
},
|
||||
}
|
||||
|
||||
// add OSD container port only if service export is enabled
|
||||
if osd.ExportService {
|
||||
podTemplateSpec.Spec.Containers[0].Ports = c.getOSDContainerPorts()
|
||||
}
|
||||
|
||||
// If the log collector is enabled we add the side-car container
|
||||
if c.spec.LogCollector.Enabled {
|
||||
// If HostPID is already enabled we don't need to activate shareProcessNamespace since all pods already see each others
|
||||
@@ -748,33 +728,6 @@ func (c *Cluster) createOSDService(osd OSDInfo, labels map[string]string) (*v1.S
|
||||
"ceph-osd-id": strconv.FormatInt(int64(osd.ID), 10),
|
||||
}
|
||||
|
||||
var ports []v1.ServicePort
|
||||
if c.spec.RequireMsgr2() {
|
||||
ports = []v1.ServicePort{
|
||||
{
|
||||
Name: "osd-port-v2",
|
||||
Port: osdPortv2,
|
||||
TargetPort: intstr.FromInt(osdPortv2),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
ports = []v1.ServicePort{
|
||||
{
|
||||
Name: "osd-port-v1",
|
||||
Port: osdPortv1,
|
||||
TargetPort: intstr.FromInt(osdPortv1),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
{
|
||||
Name: "osd-port-v2",
|
||||
Port: osdPortv2,
|
||||
TargetPort: intstr.FromInt(osdPortv2),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
svcDef := &v1.Service{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: fmt.Sprintf("rook-ceph-osd-%d", osd.ID),
|
||||
@@ -783,7 +736,7 @@ func (c *Cluster) createOSDService(osd OSDInfo, labels map[string]string) (*v1.S
|
||||
},
|
||||
Spec: v1.ServiceSpec{
|
||||
Selector: selectorLabels,
|
||||
Ports: ports,
|
||||
Ports: c.getOSDServicePorts(),
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1377,3 +1330,62 @@ func (c *Cluster) getEncryptedStatusPVCInitContainer(mountPath string, osdProps
|
||||
Resources: osdProps.resources,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cluster) getOSDContainerPorts() []v1.ContainerPort {
|
||||
var ports []v1.ContainerPort
|
||||
if c.spec.RequireMsgr2() {
|
||||
ports = []v1.ContainerPort{
|
||||
{
|
||||
Name: "osd-port-v2",
|
||||
ContainerPort: osdPortv2,
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
ports = []v1.ContainerPort{
|
||||
{
|
||||
Name: "osd-port-v1",
|
||||
ContainerPort: osdPortv1,
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
{
|
||||
Name: "osd-port-v2",
|
||||
ContainerPort: osdPortv2,
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return ports
|
||||
}
|
||||
|
||||
func (c *Cluster) getOSDServicePorts() []v1.ServicePort {
|
||||
var ports []v1.ServicePort
|
||||
if c.spec.RequireMsgr2() {
|
||||
ports = []v1.ServicePort{
|
||||
{
|
||||
Name: "osd-port-v2",
|
||||
Port: osdPortv2,
|
||||
TargetPort: intstr.FromInt(osdPortv2),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
}
|
||||
} else {
|
||||
ports = []v1.ServicePort{
|
||||
{
|
||||
Name: "osd-port-v1",
|
||||
Port: osdPortv1,
|
||||
TargetPort: intstr.FromInt(osdPortv1),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
{
|
||||
Name: "osd-port-v2",
|
||||
Port: osdPortv2,
|
||||
TargetPort: intstr.FromInt(osdPortv2),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return ports
|
||||
}
|
||||
Reference in new issue
Block a user