Skip to content

Commit

Permalink
change ssh key mode, mount key by subpath.
Browse files Browse the repository at this point in the history
  • Loading branch information
lingdie committed Nov 11, 2024
1 parent a927563 commit 04e31e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ func (r *DevboxReconciler) generateDevboxPod(devbox *devboxv1alpha1.Devbox, runt
volumes = append(volumes, devbox.Spec.ExtraVolumes...)

volumeMounts := runtime.Spec.Config.VolumeMounts
volumeMounts = append(volumeMounts, helper.GenerateSSHVolumeMounts())
volumeMounts = append(volumeMounts, helper.GenerateSSHVolumeMounts()...)
volumeMounts = append(volumeMounts, devbox.Spec.ExtraVolumeMounts...)

containers := []corev1.Container{
Expand Down
27 changes: 21 additions & 6 deletions controllers/devbox/internal/controller/helper/devbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,26 @@ func GetLastSuccessCommitImageName(devbox *devboxv1alpha1.Devbox, runtime *devbo
return commit.Image
}

func GenerateSSHVolumeMounts() corev1.VolumeMount {
return corev1.VolumeMount{
Name: "devbox-ssh-keys",
MountPath: "/usr/start/.ssh",
ReadOnly: true,
func GenerateSSHVolumeMounts() []corev1.VolumeMount {
return []corev1.VolumeMount{
{
Name: "devbox-ssh-keys",
MountPath: "/usr/start/.ssh/authorized_keys",
SubPath: "authorized_keys",
ReadOnly: true,
},
{
Name: "devbox-ssh-keys",
MountPath: "/usr/start/.ssh/id",
SubPath: "id",
ReadOnly: true,
},
{
Name: "devbox-ssh-keys",
MountPath: "/usr/start/.ssh/id.pub",
SubPath: "id.pub",
ReadOnly: true,
},
}
}

Expand All @@ -377,7 +392,7 @@ func GenerateSSHVolume(devbox *devboxv1alpha1.Devbox) corev1.Volume {
Path: "authorized_keys",
},
},
DefaultMode: ptr.To(int32(0644)),
DefaultMode: ptr.To(int32(420)),
},
},
}
Expand Down

0 comments on commit 04e31e0

Please sign in to comment.