@@ -68,7 +68,7 @@ func (b *Builder) BuildWorkerPodTemplate(nodeset *slinkyv1beta1.NodeSet, control
6868 InitContainers : []corev1.Container {
6969 b .logfileContainer (spec .LogFile , slurmdLogFilePath ),
7070 },
71- Volumes : nodesetVolumes (controller ),
71+ Volumes : nodesetVolumes (nodeset , controller ),
7272 Tolerations : []corev1.Toleration {
7373 slurmtaints .TolerationWorkerNode ,
7474 },
@@ -79,7 +79,7 @@ func (b *Builder) BuildWorkerPodTemplate(nodeset *slinkyv1beta1.NodeSet, control
7979 return b .buildPodTemplate (opts )
8080}
8181
82- func nodesetVolumes (controller * slinkyv1beta1.Controller ) []corev1.Volume {
82+ func nodesetVolumes (nodeset * slinkyv1beta1. NodeSet , controller * slinkyv1beta1.Controller ) []corev1.Volume {
8383 out := []corev1.Volume {
8484 {
8585 Name : slurmEtcVolume ,
@@ -103,28 +103,83 @@ func nodesetVolumes(controller *slinkyv1beta1.Controller) []corev1.Volume {
103103 },
104104 logFileVolume (),
105105 }
106+
107+ // Add SSH host keys volume if SSH is enabled
108+ if nodeset .Spec .Ssh .Enabled {
109+ out = append (out , corev1.Volume {
110+ Name : sshHostKeysVolume ,
111+ VolumeSource : corev1.VolumeSource {
112+ Projected : & corev1.ProjectedVolumeSource {
113+ DefaultMode : ptr.To [int32 ](0o600 ),
114+ Sources : []corev1.VolumeProjection {
115+ {
116+ Secret : & corev1.SecretProjection {
117+ LocalObjectReference : corev1.LocalObjectReference {
118+ Name : nodeset .SshHostKeys ().Name ,
119+ },
120+ Items : []corev1.KeyToPath {
121+ {Key : sshHostRsaKeyFile , Path : sshHostRsaKeyFile , Mode : ptr.To [int32 ](0o600 )},
122+ {Key : sshHostRsaPubKeyFile , Path : sshHostRsaPubKeyFile , Mode : ptr.To [int32 ](0o644 )},
123+ {Key : sshHostEd25519KeyFile , Path : sshHostEd25519KeyFile , Mode : ptr.To [int32 ](0o600 )},
124+ {Key : sshHostEd25519PubKeyFile , Path : sshHostEd25519PubKeyFile , Mode : ptr.To [int32 ](0o644 )},
125+ {Key : sshHostEcdsaKeyFile , Path : sshHostEcdsaKeyFile , Mode : ptr.To [int32 ](0o600 )},
126+ {Key : sshHostEcdsaPubKeyFile , Path : sshHostEcdsaPubKeyFile , Mode : ptr.To [int32 ](0o644 )},
127+ },
128+ },
129+ },
130+ },
131+ },
132+ },
133+ })
134+ }
135+
106136 return out
107137}
108138
109139func (b * Builder ) slurmdContainer (nodeset * slinkyv1beta1.NodeSet , controller * slinkyv1beta1.Controller ) corev1.Container {
110140 merge := nodeset .Spec .Slurmd .Container
111141
142+ // Base ports always include slurmd
143+ ports := []corev1.ContainerPort {
144+ {
145+ Name : labels .WorkerApp ,
146+ ContainerPort : SlurmdPort ,
147+ Protocol : corev1 .ProtocolTCP ,
148+ },
149+ }
150+
151+ // Add SSH port if enabled
152+ if nodeset .Spec .Ssh .Enabled {
153+ ports = append (ports , corev1.ContainerPort {
154+ Name : "ssh" ,
155+ ContainerPort : SshPort ,
156+ Protocol : corev1 .ProtocolTCP ,
157+ })
158+ }
159+
160+ // Base volume mounts
161+ volumeMounts := []corev1.VolumeMount {
162+ {Name : slurmEtcVolume , MountPath : slurmEtcDir , ReadOnly : true },
163+ {Name : slurmLogFileVolume , MountPath : slurmLogFileDir },
164+ }
165+
166+ // Add SSH host key mounts if enabled
167+ if nodeset .Spec .Ssh .Enabled {
168+ volumeMounts = append (volumeMounts ,
169+ corev1.VolumeMount {Name : sshHostKeysVolume , MountPath : sshHostRsaKeyFilePath , SubPath : sshHostRsaKeyFile , ReadOnly : true },
170+ corev1.VolumeMount {Name : sshHostKeysVolume , MountPath : sshHostRsaKeyPubFilePath , SubPath : sshHostRsaPubKeyFile , ReadOnly : true },
171+ corev1.VolumeMount {Name : sshHostKeysVolume , MountPath : sshHostEd25519KeyFilePath , SubPath : sshHostEd25519KeyFile , ReadOnly : true },
172+ corev1.VolumeMount {Name : sshHostKeysVolume , MountPath : sshHostEd25519PubKeyFilePath , SubPath : sshHostEd25519PubKeyFile , ReadOnly : true },
173+ corev1.VolumeMount {Name : sshHostKeysVolume , MountPath : sshHostEcdsaKeyFilePath , SubPath : sshHostEcdsaKeyFile , ReadOnly : true },
174+ corev1.VolumeMount {Name : sshHostKeysVolume , MountPath : sshHostEcdsaPubKeyFilePath , SubPath : sshHostEcdsaPubKeyFile , ReadOnly : true },
175+ )
176+ }
177+
112178 opts := ContainerOpts {
113179 base : corev1.Container {
114- Name : labels .WorkerApp ,
115- Args : slurmdArgs (nodeset , controller ),
116- Ports : []corev1.ContainerPort {
117- {
118- Name : labels .WorkerApp ,
119- ContainerPort : SlurmdPort ,
120- Protocol : corev1 .ProtocolTCP ,
121- },
122- {
123- Name : "ssh" ,
124- ContainerPort : SshPort ,
125- Protocol : corev1 .ProtocolTCP ,
126- },
127- },
180+ Name : labels .WorkerApp ,
181+ Args : slurmdArgs (nodeset , controller ),
182+ Ports : ports ,
128183 StartupProbe : & corev1.Probe {
129184 ProbeHandler : corev1.ProbeHandler {
130185 HTTPGet : & corev1.HTTPGetAction {
@@ -175,10 +230,7 @@ func (b *Builder) slurmdContainer(nodeset *slinkyv1beta1.NodeSet, controller *sl
175230 },
176231 },
177232 },
178- VolumeMounts : []corev1.VolumeMount {
179- {Name : slurmEtcVolume , MountPath : slurmEtcDir , ReadOnly : true },
180- {Name : slurmLogFileVolume , MountPath : slurmLogFileDir },
181- },
233+ VolumeMounts : volumeMounts ,
182234 },
183235 merge : merge ,
184236 }
0 commit comments