Created
December 1, 2021 17:39
-
-
Save nyrahul/09fea09baed701c8c5db025246844781 to your computer and use it in GitHub Desktop.
Enable Kubearmor visibility across k8s deployments/pods (except kube-system namespace)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
annotate() | |
{ | |
ns_ignore_list=("kube-system" "explorer" "cilium" "kubearmor") | |
while read line; do | |
depnm=${line/ */} | |
depns=${line/* /} | |
[[ " ${ns_ignore_list[*]} " =~ " ${depns} " ]] && continue | |
echo "Applying KubeArmor visibility annotation for namespace=[$depns], $1=[$depnm]" | |
kubectl annotate $1 -n $depns $depnm "kubearmor-visibility"="process,file,network" --overwrite | |
done < <(kubectl get $1 -A -o=custom-columns=':metadata.name,:metadata.namespace' --no-headers) | |
} | |
applyKubearmorVisibility() | |
{ | |
annotate deployments.apps | |
annotate pod | |
} | |
applyKubearmorVisibility |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment