![]() |
|
AKS Namespace Access Control – minesec (RBAC Implementation) - Printable Version +- DevOps Discussion Forum (https://forums.geekssolutions.io) +-- Forum: Cloud Computing (https://forums.geekssolutions.io/forumdisplay.php?fid=10) +--- Forum: DevOps (https://forums.geekssolutions.io/forumdisplay.php?fid=14) +--- Thread: AKS Namespace Access Control – minesec (RBAC Implementation) (/showthread.php?tid=18) |
AKS Namespace Access Control – minesec (RBAC Implementation) - rana - 04-07-2026 AKS Namespace-Restricted Access (minesec) — Production Implementation Guide Objective Provide a secure, production-ready method to grant a Linux user access strictly limited to the minesec namespace in an AKS cluster using Kubernetes RBAC and kubeconfig. This approach ensures:
Architecture Overview Code: Linux User (minesecuser)Key Principle: Access is not tied to Linux user directly — it is mapped via ServiceAccount + Token. Step 1: Create Linux User Code: sudo useradd -m minesecuserWhy this matters: Separates OS-level identity from cluster-level permissions. Step 2: Create ServiceAccount Code: apiVersion: v1Code: kubectl apply -f serviceaccount.yamlImportant: Never reuse ServiceAccounts across users. One identity = one ServiceAccount. Step 3: Create Role (Namespace Scoped) Code: apiVersion: rbac.authorization.k8s.io/v1Code: kubectl apply -f role.yamlProduction Warning: This gives full access inside the namespace. In real environments, restrict it like: Code: resources: ["pods","deployments","services"]Step 4: Create RoleBinding Code: apiVersion: rbac.authorization.k8s.io/v1Code: kubectl apply -f rolebinding.yamlWhat this does: This is the enforcement layer — without RoleBinding, access = zero. Step 5: Generate Token Code: kubectl -n minesec create token minesecuser --duration=8760h > /root/minesecuser.tokenCritical Insight: This token is effectively a password to your cluster. Treat it as a secret. Step 6: Extract Cluster Details Code: kubectl config view --minify -o jsonpath='{.clusters[0].cluster.server}'Code: kubectl config view --minify --raw -o jsonpath='{.clusters[0].cluster.certificate-authority-data}'Step 7: Create kubeconfig file Configure Linux User Code: mkdir -p /home/minesecuser/.kubeContents Code: apiVersion: v1Key Design Point: Namespace is hardcoded → prevents accidental cross-namespace access. Step 8: Validation Code: su - minesecuserNegative Testing (Important): Code: kubectl get pods -n defaultExpected: All above should return Forbidden Security Best Practices
Production Risks (Do Not Ignore)
Recommended Enterprise Upgrade Path
Summary
|