- Login to rancher2.spin.nersc.gov;
- Click the cluster name (as of May 12, 2024, either "development" or "production");
- Click "Project/Namespaces" on the sidebar, click "Create Namespace" beside your chosen project.
First we need the Rancher project ID corresponding to the NERSC project with which you would like to associate your namespace. The easiest way to get this is to already have another namespace (e.g. by following the instructions above), and running:
kubectl get namespace <namespace name> -o json | jq '.metadata.annotations["field.cattle.io/projectId"]'
you should see something like: c-frj56:p-gg9pb -- split that into two parts:
<part 1>:<part 2> and add those to racher_pid_1 and rancher_pid_2 below.
- Make a copy of
settings_example.tomland call itsettings.toml; - Fill in
settings.toml, you should have something like:
[constant]
rancher_pid_1 = "c-frj56"
rancher_pid_2 = "p-gg9pb"
[zip]
name = "my-namespace"(assuming your rancher project ID was c-frj56:p-gg9pb). Note: you can generate
the specs for many templates at once by specifying a vector of names, for
example:
... constant fields
[zip]
name = ["my-namespace-1", "my-namespace-2", "my-namespace-3"]- Run
../entrypoint.sh namespace/render.sh(or just./render.shif in interactive mode). You should now see a folder calledrenderedcontaining a .yaml spec for each of your namespaces - For each .yaml file in
renderedrun:kubectl apply -f <namespace name>.yaml
Nushell provides a powerful way to parse formatted
output. For example, instead of using the jq command above, you can get the
rancher project ID using Nushell's native yaml (and json) support:
kubectl get namespace <namespace name> -o json | from json | get metadata.annotations.'field.cattle.io/projectId'