-
Notifications
You must be signed in to change notification settings - Fork 813
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EKS Auto Mode seems to have a bug in its EBS CSI storage provisioner "ebs.csi.eks.amazonaws.com" in how it handles "ReadWriteOnce” #2331
Comments
Hi @setheliot, you are correct that multiple pods on the node should be able to access that "ReadWriteOnce" PV. We appreciate your detailed description of the problem! Thank you for submitting an issue, but this kubernetes-sigs AWS EBS CSI Driver project solely serves issues related to the kubernetes-sigs AWS EBS CSI Driver. This looks like an issue specific to EKS auto mode and the Could you please file an AWS customer support ticket with this issue? Meanwhile I will ensure EKS Auto is aware of this issue. Thank you. |
This is the answer from AWS Support. To me, this does not quite add up. What do you think? ========== I understand you reached out regarding an EKS Auto Mode issue where the EBS CSI storage provisioner "ebs.csi.eks.amazonaws.com" is not handling the "ReadWriteOnce" access mode as expected. When using EKS with Auto Mode enabled, only one pod can access the EBS Persistent Volume (PV) even though all pods are on the same node, while the same setup works correctly without Auto Mode. Please clarify if I have correctly understood the situation or if there are any additional details you would like to provide. Based on my analysis of the information you've provided and the reproduction steps in your GitHub repository, I can confirm this is a known behavior difference between the traditional EBS CSI driver and the Auto Mode implementation. Let me explain the situation and provide some solutions. Root Cause: The key difference lies in how ReadWriteOnce (RWO) access mode is implemented: Traditional EBS CSI driver (ebs.csi.aws.com) implements RWO at the node level [1] This explains why you're seeing access denied errors for additional pods even though they're on the same node. ++Immediate Solutions: Use StatefulSets instead of Deployments: This is the recommended approach as it ensures each pod gets its own PVC:
Switch to EFS: If you need true shared storage, consider using Amazon EFS which natively supports ReadWriteMany access mode [3]. Here's a sample StorageClass:
Revert to Manual Mode: If neither of the above solutions work for your use case, you can disable Auto Mode and use the traditional EBS CSI driver. Questions you might have: Q: Will switching to StatefulSets require application changes? Q: Is there a performance impact using EFS instead of EBS? References: |
Thank you for reaching out to support.
As you likely already know, "implementing RWO at the pod level" doesn't sound Kubernetes conformant. As the Kubernetes access modes documentation explains:
I agree with you, EKS should take another look at this implementation decision. This may take some time. Thank you for your patience. |
EKS Auto Mode Nodes have an enhanced level of Pod isolation, there are some more details here and here. To allow multiple Pods to share this volume, you can configure those Pods to share the same SELinux categories. Here the triple apiVersion: apps/v1
kind: Deployment
metadata:
name: sample-deployment
labels:
app: sample
spec:
replicas: 3
selector:
matchLabels:
app: sample
template:
metadata:
labels:
app: sample
spec:
securityContext:
seLinuxOptions:
level: "s0:c123,c124,c125"
... Alternatively, you can allow your Pods access to all categories, but this has side effects of removing all of the Pod level isolation instead of creating a set of specific Pods for which you want to remove the isolation: securityContext:
seLinuxOptions:
level: "s0:c0.c1023" |
Many thanks @tzneal for pointing out that SELinux is at play here. @setheliot looks like you would see similar behavior with the |
@tzneal called it... here is my latest response from AWS Support: Q1. Why would Auto Mode CSI driver be designed to operate this way? There already is an access mode called ReadWriteOncePod which would allow access by only one Pod. With ReadWriteOnce there should be access by ALL pods on the same node. You're absolutely correct in your understanding of how ReadWriteOnce should work. The behavior you're seeing isn't actually a design choice of the Auto Mode CSI driver. Instead, it's related to SELinux policies in Bottlerocket (the default AMI for EKS Auto Mode). This enhanced isolation between pods is a security feature of SELinux-enforcing operating systems, including Bottlerocket and RHEL when SELinux is enabled. Q2. Could you please provide me with any AWS documentation or artifact that supports that this is the intended behavior with "ReadWriteOnce" in Auto Mode? You're right to ask for documentation. Currently, our documentation doesn't adequately explain this SELinux-related behavior. We're in the process of reviewing and updating our documentation to better reflect this behavior and the required configuration. I apologize for the confusion this has caused. |
Guess I am going to have to learn how to use |
The docs are now updated to cover this scenario at https://docs.aws.amazon.com/eks/latest/userguide/auto-troubleshoot.html#auto-troubleshoot-share-pod-volumes |
Hello, even after applying
Solution
Manifest sample: apiVersion: apps/v1
kind: StatefulSet
metadata:
name: ebs-app
spec:
serviceName: "ebs-app"
replicas: 40
selector:
matchLabels:
app: ebs-app
template:
metadata:
labels:
app: ebs-app
spec:
nodeSelector:
topology.ebs.csi.eks.amazonaws.com/zone: "<availability-zone>"
kubernetes.io/hostname: "<node-hostname>"
containers:
- name: app
image: centos
command: ["/bin/sh"]
args:
[
"-c",
"while true; do echo $(date -u) >> /data/out.txt; sleep 2; done",
]
volumeMounts:
- name: persistent-storage
mountPath: /data
securityContext:
seLinuxOptions:
level: "s0:c123,c456,c789"
volumes:
- name: persistent-storage
persistentVolumeClaim:
claimName: ebs-claim |
/kind bug
EKS Auto Mode seems to have a bug in its EBS CSI storage provisioner "ebs.csi.eks.amazonaws.com" in how it handles "ReadWriteOnce”
In summary, when using EKS with Auto Mode enabled and I create an EBS PV with access mode "ReadWriteOnce”…
In more detail:
To illustrate this problem, I will compare two clusters
Cluster 1 is an EKS cluster WITHOUT Auto Mode (using "ebs.csi.aws.com”)
Cluster 2 is an EKS cluster with Auto Mode ENABLED (using "ebs.csi.eks.amazonaws.com”)
In both clusters:
The difference is
Observations on Cluster 2
Repro:
This repo reliably reproduces the issue:
https://github.com/setheliot/eks_auto_mode
Environment
kubectl version
): Server Version: v1.32.0-eks-5ca49cbThe text was updated successfully, but these errors were encountered: