-
Hi, I want to close security recommendations for Kubernetes Cluster in Microsoft Defender for Cloud. One of them is "Kubernetes clusters should disable automounting API credentials" and it can be solved by added "
But when I am adding this value for the Ingress Nginx Controller, the pods give me CrashLoopBackOff status and that logs in below. How can I solve this?
|
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Hi @3rk1n, from you problem statement I understand that this is a security recommendation from Microsoft Azure Defender but Ingress Controller needs credentials to access the K8s API in order to function. So the behaviour you're seeing after setting
|
Beta Was this translation helpful? Give feedback.
-
As vepatel stated, while the Azure Defender guidelines are good and intended to cover containers from a generic sense, it does not realize that any "controller" or "operator" are special Kubernetes tools applications that require access to the Kubernetes API. As I stated, the guidance of Azure Defender is prudent from an entirely generic perspective. For example, your web server application in a container does not need access to the API. But your ingress controller running in a container does require access to the API - to enumerate configurations, backend service endpoints, write events back, and so forth. Please let us know if you need further guidance as you define the necessary exception for this application. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your replies, vepatel and brianehlert. At this point, as vepatel referred a documentation, if I can define a generic serviceaccount and set automountserviceAccountToken to false for it, and of course I'll have to authorize it as well, the system works properly? |
Beta Was this translation helpful? Give feedback.
-
Hi @3rk1n I'd still advise against the approach of having a manually managed SA token as IC needs to communicate with API at all the times. If the token expires, it may result in an outage. |
Beta Was this translation helpful? Give feedback.
-
You will know pretty quickly if it works or not. As you report, the controller process will not start without being able to access the K8s API. Like I said, 99% of the time the rule applies as it is written for general services that run in Kubernetes that do not interact with the K8s API. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your help, and detailed explanation. |
Beta Was this translation helpful? Give feedback.
Hi @3rk1n, from you problem statement I understand that this is a security recommendation from Microsoft Azure Defender but Ingress Controller needs credentials to access the K8s API in order to function.
So the behaviour you're seeing after setting
automountServiceAccountToken: false
is completely expected. Our recommendation would be either:automountServiceAccountToken: false
and then immediately manually configure the API access token.See: https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/#use-the-default-service-account-to-access-the-api-…