Setup

Teaching: 0 min · Exercises: 0 min · Total: 0 min

Prerequisites for NRP Training

Before attending the training session, please ensure you have completed the following setup steps.

Two ways to follow along

There are two ways to run the hands-on exercises in this training:

  1. NRP USCMS Analysis Hub (recommended). A JupyterHub-based environment with the training materials, kubectl, and kubelogin already installed — nothing to set up on your laptop ahead of time. It still needs one login step done at the start of the session (see below). This is also the only path that works for the whole training: the later CMS Data Access lesson uses hub-only tools (grid-cert-import, grid-proxy-init) with no local equivalent, so anyone on their own machine ends up switching over for that lesson anyway.
  2. Your own machine (alternative). You run kubectl locally against the Nautilus cluster. This only works if you've completed the setup steps below before the session — kubectl, kubelogin, and your kubeconfig all need to be installed and verified in advance. Useful if you prefer working in your own local environment, but see the caveats in that section below before committing to it.

Everything past this setup page — namespaces, kubectl commands, YAML manifests — is identical either way.

Jump to: NRP USCMS Analysis Hub (recommended) · Your own machine (alternative)

1. NRP Access Requirements

Institutional Account Access

Namespace Membership

Important

We are using the namespace us-cms

Ask Daniel or Martin to add you if you have not been added already

You still need the account and namespace access from NRP Access Requirements above — this method just skips installing anything on your laptop. kubectl and kubelogin are already installed on the hub image; you only need to point kubectl at the cluster and log in once per session.

Launch the workspace in JupyterHub

▶ Launch the workspace on the NRP USCMS Analysis Hub — signs you in at uscms-af.nrp-nautilus.io, pulls the tutorial workspace, and opens JupyterLab.

Get kubectl working in the hub terminal

Open a terminal in JupyterLab (File → New → Terminal) and run:

Bash
grid-kube-setup

This fetches a fresh kubeconfig from https://nrp.ai/config and installs it at ~/.kube/config (backing up anything already there). It doesn't log you in by itself — the next kubectl command you run triggers a device-code login:

Bash
kubectl get pods -n us-cms

kubelogin prints a URL and a short code. Open the URL on your laptop, enter the code, and the hub terminal picks up the token automatically — nothing more to click on the hub side.

Expected output
text
jovyan@jupyter-...:~$ grid-kube-setup
Fetching   https://nrp.ai/config
user 'oidc':
    + --grant-type=device-code
    + --skip-open-browser

Backed up  /home/jovyan/.kube/config.xxxxxxxxxxx.bak
Updated    /home/jovyan/.kube/config

Next: run any kubectl command to trigger the login, e.g.

  kubectl get pods

kubelogin will print a URL and a code. Open the URL on your laptop, enter the
code, and this terminal will pick up the token.

jovyan@jupyter-...:~$ kubectl get pods -n us-cms
Please visit the following URL in your browser: https://authentik.nrp-nautilus.io/device?code=XXXXXXXXX
NAME                      READY   STATUS    RESTARTS   AGE
mlflow-667f8c984c-thzsr   2/2     Running   0          2d22h
mlflow-postgres-0         1/1     Running   0          10d

The login lasts for the rest of your hub session — you don't need to repeat this for every new terminal, only after grid-kube-setup re-installs the kubeconfig or your token expires.

Kubernetes Basics, the first hands-on lesson, starts with a one-time callout covering the rest of the hub setup (grid certificate, proxy, username) — do that once and the rest of the training just works.

Method 2: Your own machine (alternative)

Complete these steps before the session — they can't be done live.

Important

You'll still need the Analysis Hub for the last lesson. CMS Data Access on NRP uses grid-cert-import and grid-proxy-init, tools built into the Analysis Hub's image with no local install path. If you use your own machine for the rest of the training, plan to switch to the Analysis Hub for that lesson.

Also watch out for ~: it means a different directory in each place. On your own machine it's your local home directory; in the Analysis Hub's JupyterLab terminal it's /home/jovyan. A command like cd ~/cms-hats/workspace lands somewhere different depending on which terminal you're actually typing it into — don't copy a command you ran in one context straight into the other without checking where it actually points.

tl;dr

Get an NRP account and namespace access → install kubectl → install kubelogin → download your kubeconfig from nrp.ai/config → verify with kubectl get nodes. The sections below walk through each step in detail.

1. Install kubectl

The Kubernetes command-line tool, kubectl, is required for the training exercises.

Linux

Download and install:

Bash
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

macOS

Using Homebrew:

Bash
brew install kubectl

Or download directly:

Bash
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/

Windows

Download from: https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/

2. Install kubelogin Plugin
[Required]

You must install the kubelogin plugin, or your kubeconfig file will not work.

macOS

Bash
brew install kubelogin

Linux/Windows

Download from: https://github.com/int128/kubelogin?tab=readme-ov-file#setup

3. Download Kubernetes Config File
  1. Download the config file from: https://nrp.ai/config
  2. Save it as config (without any extension) in your ~/.kube folder
  3. If the folder doesn't exist, create it:
Bash
mkdir ~/.kube
  1. The final path should be: ~/.kube/config
4. Cross-Platform kubelogin Fixes

If you run into authentication issues with kubelogin, try these fixes:

Keyring errors (e.g., /run/user/1000/bus not found):

  • Add --token-cache-storage=disk to store tokens on disk instead of Linux keyring

Browser issues (won't launch or opens incorrectly):

  • Add --browser-command="/mnt/c/Program Files/Google/Chrome/Application/chrome.exe" (Windows WSL: points to Windows Chrome)

Port binding errors (port 8000 already in use):

  • Add --listen-port=18000 (change to any unused port)

No local browser available (remote console):

  • Add --grant-type=device-code --skip-open-browser

Example config snippet:

YAML
args:
  - oidc-login
  - get-token
  - --browser-command="/mnt/c/Program Files/Google/Chrome/Application/chrome.exe"
  - --listen-port=18000
  - --token-cache-storage=disk
5. Verify Installation
  1. Check kubectl context:
Bash
kubectl config get-contexts

You should see nautilus in the list. If you have multiple contexts, set it:

Bash
kubectl config use-context nautilus
  1. Test authentication:
Bash
kubectl get nodes

This will open a browser window for authentication via CiLogon.

  1. Verify namespace access:
Bash
kubectl get pods -n <YOUR_NAMESPACE>

If you see "No resources found", that's okay - it means you have access but there are no pods yet.

  1. Set default namespace (optional):
Bash
kubectl config set-context nautilus --namespace <YOUR_NAMESPACE>
6. Clone the training materials

Clone the branch containing the files for this training:

Bash
git clone --branch materials/cms-hats --single-branch https://github.com/nrp-nautilus/nrp-training.git ~/cms-hats
cd ~/cms-hats/workspace

If you already cloned the training materials, update your local copy instead:

Bash
cd ~/cms-hats
git pull
cd workspace

CLI Tools

Below are two tools which reduce the amount of kubernetes commands you need to type out.

These are not required. All parts of the tutorial and using Kubernetes in general can be done via the command line, however these tools make things easier. If you wish to use these PLEASE INSTALL PRIOR TO THE EXERCISE.

Getting Help

If you encounter issues during setup:

Additional Resources