|
1 |
| -# sandbox-operator |
| 1 | +# Plex Sandbox Operator |
| 2 | + |
| 3 | +[](https://goreportcard.com/report/github.com/plexsystems/sandbox-operator) |
| 4 | +[](https://github.com/plexsystems/sandbox-operator/releases) |
2 | 5 |
|
3 | 6 | 
|
4 | 7 |
|
5 | 8 | ## Introduction
|
6 | 9 |
|
7 |
| -This is a sandbox operator that creates segregated namespaces and sets up RBAC for authenticated users specified in the CRD. |
| 10 | +The Plex Sandbox Operator is an operator for [Kubernetes](https://kubernetes.io/) that enables authenticated users to a cluster to create their own isolated environments leveraging namespaces. |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +The [deploy](deploy) folder contains the necessary Kubernetes manifests to install the operator. |
| 15 | + |
| 16 | +## Configuration |
| 17 | + |
| 18 | +The sandbox operator can leverage different clients, depending upon how authenitcation is configured for your cluster. |
| 19 | + |
| 20 | +### Azure |
| 21 | + |
| 22 | +If Azure credentials are provided to the deployment, the operator will perform a lookup of the user in the owners field to fetch that users ObjectID inside of Azure. |
| 23 | + |
| 24 | +This enables users of the operator to provide a user friendly name, such as their email address, and have the operator itself handle the creation of the bindings within Kubernetes. |
| 25 | + |
| 26 | +To use the Azure client, include the following environment variables: |
| 27 | + |
| 28 | +- `AZURE_CLIENT_ID` |
| 29 | +- `AZURE_TENANT_ID` |
| 30 | +- `AZURE_CLIENT_SECRET` |
| 31 | + |
| 32 | +### Default |
| 33 | + |
| 34 | +If no credentials are provided, the operator will create the bindings using the values listed in the owners field. |
| 35 | + |
| 36 | +## Usage |
| 37 | + |
| 38 | +To use the operator, create and apply a Sandbox CRD to the target cluster. |
| 39 | + |
| 40 | +The following manifest will create a sandbox called `test` (the resulting namespace being `sandbox-test`), and assign the RBAC roles to user `[email protected]` |
| 41 | + |
| 42 | +```yaml |
| 43 | +apiVersion: operators.plex.dev/v1alpha1 |
| 44 | +kind: Sandbox |
| 45 | +metadata: |
| 46 | + name: test |
| 47 | +spec: |
| 48 | + owners: |
| 49 | + |
| 50 | +``` |
| 51 | +
|
| 52 | +### Created Resources |
| 53 | +
|
| 54 | +For each sandbox that is created the following resources will be created: |
| 55 | +
|
| 56 | +- `Namespace`: Name of the sandbox, prefixed with `sandbox-`. |
| 57 | + |
| 58 | +- `ClusterRole`: Only the permission to delete and view the created sandbox. |
| 59 | + |
| 60 | +- `ClusterRoleBinding`: Given to each user listed in the `owners` field of the Sandbox CRD. |
| 61 | + |
| 62 | +- `Role`: Permissions to manage the contents of the sandbox, but no permission to view secrets. |
| 63 | + |
| 64 | +- `RoleBinding`: Given to each user listed in the `owners` field of the Sandbox CRD. |
| 65 | + |
| 66 | +- `ResourceQuota`: Defined quotas for the Sandbox. |
| 67 | + |
| 68 | +## Development |
| 69 | + |
| 70 | +### Testing |
| 71 | + |
| 72 | +### Unit tests |
| 73 | + |
| 74 | +Run the `make test-unit` command. This will use an in-memory kubernetes client to validate and test your changes. |
| 75 | + |
| 76 | +### Integration tests |
8 | 77 |
|
9 |
| -## Local Testing |
| 78 | +Run the `make test-integration` command. This will create a Kubernetes cluster for you, using [Kind](https://github.com/kubernetes-sigs/kind), and deploy the operator to it. Afterwards, the integration tests will be ran against the newly created cluster and operator. |
10 | 79 |
|
11 |
| -Run `make test-unit` to run the operator unit tests |
| 80 | +**NOTE:** To test the operator with different versions of Kubernetes, you can use the `KUBERNETES_VERSION` variable to when calling `make`. For example, to test on Kubernetes v1.16.3, run the following command: |
12 | 81 |
|
13 |
| -Run `make test-integration` to deploy the operator to a Kind cluster and verify the operator pod enters a running state. |
| 82 | +`make test-integration KUBERNETES_VERSION=v1.16.3` |
14 | 83 |
|
15 |
| -Iterative deployments can be made with `make deploy`. This will rebuild the operator and deploy to it to an existing cluster. |
| 84 | +## Contributing |
16 | 85 |
|
17 |
| -To test with a different version of Kubernetes, pass in `KUBERNETES_VERSION` to the `make` command (e.g. `make test-integration KUBERNETES_VERSION=v1.17.0`) |
| 86 | +We :heart: pull requests. If you have a question, feedback, or would like to contribute — please feel free to create an issue or open a pull request! |
0 commit comments