Usability and Security enhancements for NDB Kubernetes Operator #185
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.
What this PR does / why we need it:
Problem Statement: The current system faces several security and operational challenges that need urgent attention:
Enhancements to Secrets Management:
We have implemented a solution using RBAC policies at the Kubernetes cluster level to create new users, and restrict their secrets only to their context, such that no two users in the same K8 cluster can access each other's secrets.
As per the above diagram, there are two main contexts namely the administrator context (Usually known as “minikube” or any other name depending on the K8 cluster), and the user contexts. The administrator has the role of creating users and assigning their NDB secrets, while the users have the role to view their secrets and also depending on the access they have been granted, they can perform certain NDB operations as well.
In addition to the contexts, there are three namespaces namely the administrator namespace, the user namespaces and the ndb-operator-namespace.
Steps for recreation of the implementation:
openssl genpkey -algorithm RSA -out user1-key.pem
openssl req -new -key user1-key.pem -out user1.csr -subj “/CN=user1”
Next, approve the certificate signing requests:
openssl x509 -req -in user1.csr -CA /path_to_cluster_ca_crt/ca.crt
-CAkey /path_to_cluster_ca_crt/ca.key -CAcreateserial -out user1.crt
kubectl config set-credentials user1 –client-certificate=user1.crt –client-key=user1.pem
kubectl create namespace user1-namespace
kubectl config set-context user1-context –cluster= –namespace=user1-namespace –user=user1
With these roles created, save the YAML files and apply the same using the commands
kubectl apply -f user-namespace-role.yaml
kubectl apply -f user-namespace-rolebinding.yaml
Apply the cluster role using the command
kubectl apply -f user1-ndb-rolebinding.yaml
Save this file as user1-secret and apply the same using the command - kubectl apply -f user1-secret.yaml
Similarly create the database secret using the YAML file
Save this as user1-db.yaml and apply using kubectl.
Save and apply the same using kubectl apply.
Thus with the aid of the above steps, we can now create a secret and secure the same using RBAC. Moreover, a particular user can only apply the secrets that they have been granted access to using an appropriate manifest and not any other secret that belongs to another user.
Now we can resolve the clusterID using the clusterName internally.
How Has This Been Tested?:
To test the chosen secrets management and access control system, various users will need to be set up and configured. Those users will be given different access permissions to various fake secrets that will be created to make sure access is restricted. Below are more specific tests that will be created to test access to secrets.
Ensure the Secret Management System is Installed: This test will ensure that the chosen secret management system has been successfully installed on the system. It will call various functions of the management system to ensure that it is present.
Verify Configuration: This test’s main purpose is to ensure that the configuration of the system is correct. It will check the desired authentication methods and policies by using various users using those authentication methods.
Verify Secret Creation: Fake secrets will be created and will be tested to ensure that only verified users can access them. This test will also ensure that unauthorized users cannot create secrets.
Verify Retrieval of Secrets: The fake secrets will be retrieved both inside the system’s storage through its database as well as through an interface. This test will also ensure that users cannot retrieve secrets they are not supposed to.
Verify System Retrieval of Secrets: This test will ensure that authorized workloads within the system are able to access secrets that they are required to access. This test will also ensure that unauthorized workloads are unable to access certain secrets.
Verify encryption at all Levels: Tests will be created to ensure that secrets that are being transferred from one component to another are encrypted and are inaccessible without the proper authorization.
Verify Proper Access Control: Tests will be created to ensure that unauthorized users cannot access resources they shouldn’t. Fake resources and fake users will be created with different authorization to ensure this. It will also ensure that authorized users can access what they should be able to.