This document outlines security best practices for deploying and using K8sToolbox in your Kubernetes environment.
K8sToolbox is a powerful utility for Kubernetes management and troubleshooting. With great power comes great responsibility - many of the capabilities that make it useful for debugging can also create security risks if not properly managed.
K8sToolbox includes two RBAC configurations:
Best Practice: Always use restricted permissions by setting security.useRestrictedPermissions=true
in Helm values.
security:
useRestrictedPermissions: true
The security context defines privilege and access controls for the container.
Best Practice: Configure the security context with the following settings:
security:
podSecurityContext:
fsGroup: 10001
runAsUser: 10001
runAsGroup: 10001
runAsNonRoot: true
containerSecurityContext:
privileged: false
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
add:
- NET_ADMIN # Only if needed for network diagnostics
- NET_RAW # Only if needed for network diagnostics
Note: Some network diagnostic tools may require NET_ADMIN
and NET_RAW
capabilities. If these aren’t needed, don’t add them.
K8sToolbox can be configured to access the host filesystem.
Best Practice: Avoid mounting the host filesystem unless absolutely necessary.
volumes:
mountHostRoot: false
If host access is required, consider:
K8sToolbox provides scripts that can modify cluster resources.
Best Practices:
--dry-run
first to preview changesSome K8sToolbox scripts provide network diagnostic capabilities that can potentially be used for unintended purposes.
Best Practices:
Example Network Policy:
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: k8stoolbox-network-policy
spec:
podSelector:
matchLabels:
app: k8stoolbox
policyTypes:
- Egress
egress:
- to:
- namespaceSelector:
matchLabels:
purpose: production
When using the K8sToolbox web interface (if enabled), proper authentication is essential.
Best Practices:
auth:
enabled: true
generatePassword: true
For production environments, follow these additional guidelines:
Use this checklist before deploying K8sToolbox:
By following these security best practices, you can ensure that K8sToolbox enhances your Kubernetes management capabilities without introducing unnecessary risk to your environment.