Files
rancher-docs/docs/api/workflows/projects.md
Billy Tat 03ea6163fb Port version-2.8 updates to latest (/docs) (#1013)
* Port version-2.8 updates to latest (/docs)

Includes changes from 1b6d9506 (2023-10-06) to 1f39a6ff (2023-11-30)

* Fix redirects
2023-12-06 14:48:27 -05:00

2.5 KiB

title
title
Projects

Creating a Project

Project resources may only be created on the management cluster. See below for creating namespaces under projects in a managed cluster.

Creating a Basic Project

kubectl create -f - <<EOF
apiVersion: management.cattle.io/v3
kind: Project
metadata:
  generateName: p-
  namespace: c-m-abcde
spec:
  clusterName: c-m-abcde
  displayName: myproject
EOF

Use metadata.generateName to ensure a unique project ID, but note that kubectl apply does not work with metadata.generateName, so kubectl create must be used instead.

Set metadata.namespace and spec.clusterName to the ID for the cluster the project belongs to.

Creating a Project With a Resource Quota

Refer to Kubernetes Resource Quota.

kubectl create -f - <<EOF
apiVersion: management.cattle.io/v3
kind: Project
metadata:
  generateName: p-
  namespace: c-m-abcde
spec:
  clusterName: c-m-abcde
  displayName: myproject
  resourceQuota:
    limit:
      limitsCpu: 1000m
  namespaceDefaultResourceQuota:
    limit:
      limitsCpu: 50m
EOF

Creating a Project With Container Limit Ranges

Refer to Kubernetes Limit Ranges.

kubectl create -f - <<EOF
apiVersion: management.cattle.io/v3
kind: Project
metadata:
  generateName: p-
  namespace: c-m-abcde
spec:
  clusterName: c-m-abcde
  displayName: myproject
  containerDefaultResourceLimit:
    limitsCpu:    100m
    limitsMemory: 100Mi
    requestsCpu:  50m
    requestsMemory: 50Mi

Creating a Namespace in a Project

The Project resource resides in the management cluster, even if the Project is for a managed cluster. The namespaces under the project reside in the managed cluster.

On the management cluster, look up the project ID for the cluster you are administrating since it generated using metadata.generateName:

kubectl --namespace c-m-abcde get projects

On the managed cluster, create a namespace with a project annotation:

kubectl apply -f - <<EOF
apiVersion: v1
kind: Namespace
metadata:
  name: mynamespace
  annotations:
    field.cattle.io/projectId: c-m-abcde:p-vwxyz
EOF

Note the format, <cluster ID>:<project ID>.

Deleting a Project

Look up the project to delete in the cluster namespace:

kubectl --namespace c-m-abcde get projects

Delete the project under the cluster namespace:

kubectl --namespace c-m-abcde delete project p-vwxyz