Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Set a default priorityClassName to Mountpoint Pods and allow customizing #392

Merged
merged 1 commit into from
Feb 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,7 @@ spec:
value: {{ .Values.image.pullPolicy }}
- name: MOUNTPOINT_NAMESPACE
value: {{ .Values.mountpointPod.namespace }}
- name: MOUNTPOINT_PRIORITY_CLASS_NAME
value: {{ .Values.mountpointPod.priorityClassName }}

{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if .Values.experimental.podMounter -}}

apiVersion: scheduling.k8s.io/v1
kind: PriorityClass
metadata:
name: mount-s3-critical
value: 1000000000
preemptionPolicy: Never
globalDefault: false
description: >-
Default priority class for Mountpoint Pods.
It has the highest possible value for non-builtin PriorityClasses to ensure Mountpoint Pods get scheduled quickly and not evicted first in case of a resource pressure.
It will not cause other Pods to be preempted.

{{- end -}}
1 change: 1 addition & 0 deletions charts/aws-mountpoint-s3-csi-driver/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ controller:

mountpointPod:
namespace: mount-s3
priorityClassName: mount-s3-critical

nameOverride: ""
fullnameOverride: ""
Expand Down
2 changes: 2 additions & 0 deletions cmd/aws-s3-csi-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

var mountpointNamespace = flag.String("mountpoint-namespace", os.Getenv("MOUNTPOINT_NAMESPACE"), "Namespace to spawn Mountpoint Pods in.")
var mountpointVersion = flag.String("mountpoint-version", os.Getenv("MOUNTPOINT_VERSION"), "Version of Mountpoint within the given Mountpoint image.")
var mountpointPriorityClassName = flag.String("mountpoint-priority-class-name", os.Getenv("MOUNTPOINT_PRIORITY_CLASS_NAME"), "Priority class name of the Mountpoint Pods.")
var mountpointImage = flag.String("mountpoint-image", os.Getenv("MOUNTPOINT_IMAGE"), "Image of Mountpoint to use in spawned Mountpoint Pods.")
var mountpointImagePullPolicy = flag.String("mountpoint-image-pull-policy", os.Getenv("MOUNTPOINT_IMAGE_PULL_POLICY"), "Pull policy of Mountpoint images.")
var mountpointContainerCommand = flag.String("mountpoint-container-command", "/bin/aws-s3-csi-mounter", "Entrypoint command of the Mountpoint Pods.")
Expand All @@ -44,6 +45,7 @@ func main() {
err = csicontroller.NewReconciler(mgr.GetClient(), mppod.Config{
Namespace: *mountpointNamespace,
MountpointVersion: *mountpointVersion,
PriorityClassName: *mountpointPriorityClassName,
Container: mppod.ContainerConfig{
Command: *mountpointContainerCommand,
Image: *mountpointImage,
Expand Down
2 changes: 2 additions & 0 deletions pkg/podmounter/mppod/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type ContainerConfig struct {
type Config struct {
Namespace string
MountpointVersion string
PriorityClassName string
Container ContainerConfig
CSIDriverVersion string
}
Expand Down Expand Up @@ -84,6 +85,7 @@ func (c *Creator) Create(pod *corev1.Pod, pvc *corev1.PersistentVolumeClaim) *co
},
},
}},
PriorityClassName: c.config.PriorityClassName,
Affinity: &corev1.Affinity{
NodeAffinity: &corev1.NodeAffinity{
// This is to making sure Mountpoint Pod gets scheduled into same node as the Workload Pod
Expand Down
3 changes: 3 additions & 0 deletions pkg/podmounter/mppod/creator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func TestCreatingMountpointPods(t *testing.T) {
image := "mp-image:latest"
imagePullPolicy := corev1.PullAlways
command := "/bin/aws-s3-csi-mounter"
priorityClassName := "mount-s3-critical"

// Test Pod values
testNode := "test-node"
Expand All @@ -29,6 +30,7 @@ func TestCreatingMountpointPods(t *testing.T) {
creator := mppod.NewCreator(mppod.Config{
Namespace: namespace,
MountpointVersion: mountpointVersion,
PriorityClassName: priorityClassName,
Container: mppod.ContainerConfig{
Image: image,
ImagePullPolicy: imagePullPolicy,
Expand Down Expand Up @@ -60,6 +62,7 @@ func TestCreatingMountpointPods(t *testing.T) {
mppod.LabelCSIDriverVersion: csiDriverVersion,
}, mpPod.Labels)

assert.Equals(t, priorityClassName, mpPod.Spec.PriorityClassName)
assert.Equals(t, corev1.RestartPolicyOnFailure, mpPod.Spec.RestartPolicy)
assert.Equals(t, []corev1.Volume{
{
Expand Down
1 change: 1 addition & 0 deletions tests/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,7 @@ func verifyMountpointPodFor(pod *testPod, vol *testVolume, mountpointPod *testPo
Operator: corev1.TolerationOpExists,
},
}))
Expect(mountpointPod.Spec.PriorityClassName).To(Equal(mountpointPriorityClassName))

Expect(mountpointPod.Spec.Containers[0].Image).To(Equal(mountpointImage))
Expect(mountpointPod.Spec.Containers[0].ImagePullPolicy).To(Equal(mountpointImagePullPolicy))
Expand Down
15 changes: 15 additions & 0 deletions tests/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
schedulingv1 "k8s.io/api/scheduling/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/rest"
"k8s.io/kubectl/pkg/scheme"
Expand All @@ -32,6 +33,7 @@ const defaultContainerImage = "public.ecr.aws/docker/library/busybox:stable-musl
// Configuration values passed for `mppod.Config` while creating a controller to use in tests.
const mountpointNamespace = "mount-s3"
const mountpointVersion = "1.10.0"
const mountpointPriorityClassName = "mount-s3-critical"
const mountpointContainerCommand = "/bin/aws-s3-csi-mounter"
const mountpointImage = "mp-image:latest"
const mountpointImagePullPolicy = corev1.PullNever
Expand Down Expand Up @@ -80,6 +82,7 @@ var _ = BeforeSuite(func() {
err = csicontroller.NewReconciler(k8sManager.GetClient(), mppod.Config{
Namespace: mountpointNamespace,
MountpointVersion: mountpointVersion,
PriorityClassName: mountpointPriorityClassName,
Container: mppod.ContainerConfig{
Command: mountpointContainerCommand,
Image: mountpointImage,
Expand All @@ -96,6 +99,7 @@ var _ = BeforeSuite(func() {
}()

createMountpointNamespace()
createMountpointPriorityClass()
})

var _ = AfterSuite(func() {
Expand All @@ -112,3 +116,14 @@ func createMountpointNamespace() {
Expect(k8sClient.Create(ctx, namespace)).To(Succeed())
waitForObject(namespace)
}

// createMountpointPriorityClass creates priority class for Mountpoint Pods.
func createMountpointPriorityClass() {
By(fmt.Sprintf("Creating priority class %q for Mountpoint Pods", mountpointPriorityClassName))
priorityClass := &schedulingv1.PriorityClass{
ObjectMeta: metav1.ObjectMeta{Name: mountpointPriorityClassName},
Value: 1000000,
}
Expect(k8sClient.Create(ctx, priorityClass)).To(Succeed())
waitForObject(priorityClass)
}
Loading