Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Continuing with respect to PR 20 and using same Apache based webpage.
Kubernetes RBAC Controller on Minikube Cluster
In this demo, we will see how to use RBAC controller for managing access to your Kubernetes resources.
Pre-requisites to implement this project:
What we are going to implement:
Steps to implement RBAC:
1) First, let's define namespaces.yaml to separate your resources. This helps in organizing and applying RBAC policies.
# namespaces.yaml apiVersion: v1 kind: Namespace metadata: name: apache-namespace
2) Apply apache deployment :
# apache-deployment.yaml apiVersion: apps/v1 kind: Deployment metadata: name: apache-deployment namespace: apache-namespace spec: replicas: 1 selector: matchLabels: app: apache template: metadata: labels: app: apache spec: containers: - name: apache image: httpd:2.4 ports: - containerPort: 80 --- apiVersion: v1 kind: Service metadata: name: apache-service namespace: apache-namespace spec: selector: app: apache ports: - protocol: TCP port: 80 targetPort: 80 type: ClusterIP
3) Apply apache-deployment & namespaces.yaml:
4) Create Roles and RoleBindings:
5) RoleBinding for Apache Manager
We'll bind the role to a user or service account.
6) Apply apache-role & rolebinding:
7) Create Users (Optional):
If you are using a Kubernetes distribution that supports user management, you can create users and assign them the respective roles. Here, we'll use basic ServiceAccounts for simplicity.
#apache-serviceaccount.yaml apiVersion: v1 kind: ServiceAccount metadata: name: apache-user namespace: apache-namespace
8) Apply the service accounts:
Verify Roles and RoleBinding
To cross-verify the RBAC setup, you can perform a series of checks and actions to ensure that the roles and permissions are applied correctly. Here’s how you can do it:
1) Check Roles:
2) Check RoleBindings:
Verify ServiceAccounts
Check ServiceAccounts:
Test Access Using Impersonation
You can use the 'kubectl auth can-i' command to verify the permissions granted by the roles.
Test Apache User Permissions:
To test denial of permissions outside the namespace:
Create Test Resources
Test Apache User Resource Creation:
Clean Up Test Resources
After verification, clean up the test resources:
Delete Test Pods:
This should provide you with a thorough verification of your RBAC setup, ensuring that the roles and permissions are correctly applied and functioning as intended.