Replies: 1 comment
-
This recommendation doesn't make any sense for this operator. This Operator needs to communicate with Kubernetes API, in order to deploy and manage RabbitMQ automagically for you. In order to communicate with the Kubernetes API, this Operator uses a dedicated Service Account, and it mounts its token to use as credentials. The error you observe is the logical consequence of removing this token i.e. unable to load token -> unable to communicate with Kubernetes API. You can safely disregard this "warning" and leave auto-mount as true.
You do exactly what the suggestion says 🙂 Add the security context to the cluster operator deployment spec. In case you are looking for inspiration, your cluster-operator-deployment.yaml---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/component: rabbitmq-operator
app.kubernetes.io/name: rabbitmq-cluster-operator
app.kubernetes.io/part-of: rabbitmq
name: rabbitmq-cluster-operator
namespace: rabbitmq-system
spec:
replicas: 1
selector:
matchLabels:
app.kubernetes.io/name: rabbitmq-cluster-operator
template:
metadata:
labels:
app.kubernetes.io/component: rabbitmq-operator
app.kubernetes.io/name: rabbitmq-cluster-operator
app.kubernetes.io/part-of: rabbitmq
spec:
securityContext:
runAsNonRoot: true
runAsGroup: 1001
runAsUser: 1001
containers:
- command:
- /manager
env:
- name: OPERATOR_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: rabbitmqoperator/cluster-operator:2.3.0
name: operator
securityContext:
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false
privileged: false
runAsNonRoot: true
runAsGroup: 1001
runAsUser: 1001
capabilities:
drop:
- ALL
ports:
- containerPort: 9782
name: metrics
protocol: TCP
resources:
limits:
cpu: 200m
memory: 500Mi
requests:
cpu: 200m
memory: 500Mi
serviceAccountName: rabbitmq-cluster-operator
terminationGracePeriodSeconds: 10 The group ID and user ID do not need to exist at all. If you are new to this concept, I'd recommend reading this: https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ |
Beta Was this translation helpful? Give feedback.
-
Hi,
I want to close two 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 "
automountServiceAccountToken: false
" for POD security "spec --> template --> spec"But when I am adding this values the pods give me CrashLoopBackOff status and that logs in below, and I can not see that spec in Pod level.
How can I solve this?
The second is "Running containers as root user should be avoided" and it can be solved by added "
securityContext
"How can I add this spec with correct values for
runAsGroup: <Group-ID>
andrunAsUser: <User-ID>
?Should I add any values for Dockerfile and how can I add?
Beta Was this translation helpful? Give feedback.
All reactions