项目作者: vmware-tanzu

项目描述 :
Provides a `Project` CRD and controller for k8s to help with organising resources
高级语言: Go
项目地址: git://github.com/vmware-tanzu/projects-operator.git
创建时间: 2019-07-31T19:41:47Z
项目社区:https://github.com/vmware-tanzu/projects-operator

开源协议:Other

下载


Projects

About

projects-operator extends kubernetes with a Project CRD and corresponding
controller. Projects are intended to provide isolation of kubernetes
resources on a single kubernetes cluster. A Project is essentially a
kubernetes namespace along with a corresponding set of RBAC rules.

Contributing

To begin contributing, please read the contributing doc.

Installation and Usage

projects-operator is currently deployed using k14s.

You must first create a ClusterRole that contains the RBAC
rules you wish to be applied to each created Project. For example:

  1. apiVersion: rbac.authorization.k8s.io/v1
  2. kind: ClusterRole
  3. metadata:
  4. name: my-clusterrole-with-rbac-for-each-project
  5. rules:
  6. - apiGroups:
  7. - example.k8s.io
  8. resources:
  9. - mycustomresource
  10. verbs:
  11. - "*"

Install

Then you will need to build and push the projects-operator image to a registry.

  1. $ docker build -t <REGISTRY_HOSTNAME>/<REGISTRY_PROJECT>/projects-operator .
  2. $ docker push <REGISTRY_HOSTNAME>/<REGISTRY_PROJECT>/projects-operator
  3. # For example, docker build -t gcr.io/team-a/projects-operator .

Then finally you can run the /scripts/kapp-deploy script
to deploy projects-operator.

  1. export INSTANCE=<UNIQUE STRING TO IDENTIFY THIS DEPLOYMENT>
  2. export REGISTRY_HOSTNAME=<REGISTRY_HOSTNAME> # e.g. "gcr.io", "my.private.harbor.com", etc.
  3. export REGISTRY_PROJECT=<REGISTRY_PROJECT> # e.g. "team-a", "dev", etc.
  4. export REGISTRY_USERNAME=<REGISTRY_PASSWORD>
  5. export REGISTRY_PASSWORD=<REGISTRY_PASSWORD>
  6. export CLUSTER_ROLE_REF=my-clusterrole-with-rbac-for-each-project
  7. $ ./scripts/kapp-deploy

Creating a Project

Apply projects yaml with a project name and a list of users/groups/serviceaccounts who have access, for example:

  1. apiVersion: projects.vmware.com/v1alpha1
  2. kind: Project
  3. metadata:
  4. name: project-sample
  5. spec:
  6. access:
  7. - kind: User
  8. name: alice
  9. - kind: ServiceAccount
  10. name: some-robot
  11. namespace: some-namespace
  12. - kind: Group
  13. name: ldap-experts

Uninstall

  1. kapp -n <NAMESPACE> delete -a projects-operator

Webhooks

projects-operator makes use of three webhooks to provide further functionality, as follows:

  1. A ValidatingWebhook (invoked on Project CREATE) - ensures that Projects cannot be created if they have the same name as an existing namespace.
  2. A MutatingWebhook (invoked on ProjectAccess CREATE, UPDATE) - returns a modified ProjectAccess containing the list of Projects the user has access to.
  3. A MutatingWebhook (invoked on Project CREATE) - adds the user from the request as a member of the project if a project is created with no entries in access.