Skip to content

Rancher

Rancher is the management plane for Roche’s CaaS (Container-as-a-Service) Kubernetes clusters. It provides the web UI and API for cluster access, project management, namespace creation, and kubeconfig provisioning. The roche-data project rdt_model is managed through Rancher.

PropertyValue
URLhttps://rancher.emea.roche.com
Clustercaasawsprod (Cloud Prod, eu-central-1)
Cluster IDc-2dhbr
Projectrdt_model (c-2dhbr:p-r4z25)
Auth methodBearer token (Rancher API key)
UserRXPMODE1 (service account)
Token nametoken-pwj8f
Token expiry2026-08-04 (89 days from creation)
NetworkRoche corporate network (VPN required)
Access taskA13 (shared with CaaS)
GitHub issue#28
VariableSourceDescription
RANCHER_BEARER_TOKENVault common/caasRancher API bearer token (token-XXXXX:secretkey)
RANCHER_URLVault common/caasRancher management plane URL
RANCHER_ACCESS_KEYVault common/caasToken ID portion (token-XXXXX)
RANCHER_SECRET_KEYVault common/caasSecret portion of the token
RANCHER_USERVault common/caasRancher user (RXPMODE1)
RANCHER_TOKEN_EXPIRESVault common/caasToken expiry date
CAAS_PROJECTVault common/caasProject name (rdt_model)
Terminal window
# CORRECT — use cluster-scoped k8s proxy path
curl -sk -H "Authorization: Bearer $RANCHER_BEARER_TOKEN" \
"https://rancher.emea.roche.com/k8s/clusters/c-2dhbr/api/v1/namespaces/rdt-model-dev"
# Returns 200 with namespace JSON = token is valid
# WRONG — returns 401 for cluster-scoped tokens even when valid
curl -sk -H "Authorization: Bearer $RANCHER_BEARER_TOKEN" \
"https://rancher.emea.roche.com/v3/clusters"
# 401 does NOT mean the token is broken!

API paths that work with cluster-scoped tokens

Section titled “API paths that work with cluster-scoped tokens”
MethodPathPurpose
GET/k8s/clusters/c-2dhbr/api/v1/namespaces/{ns}Get namespace (connectivity check)
GET/k8s/clusters/c-2dhbr/api/v1/namespaces/{ns}/podsList pods
POST/k8s/clusters/c-2dhbr/api/v1/namespaces/{ns}/secretsCreate secrets
POST/k8s/clusters/c-2dhbr/apis/apps/v1/namespaces/{ns}/deploymentsCreate deployments
GET/k8s/clusters/c-2dhbr/apis/apps/v1/namespaces/{ns}/deployments/{name}Get deployment

API paths that DO NOT work with cluster-scoped tokens (always 401)

Section titled “API paths that DO NOT work with cluster-scoped tokens (always 401)”
PathWhy it fails
/v3/clustersRequires global scope
/v3/projectsRequires global scope
/v3/clusters/c-2dhbr?action=generateKubeconfigRequires global scope

Since cluster-scoped tokens can’t call generateKubeconfig, we build kubeconfigs manually. They are stored in Vault at secret/{env}/kubeconfig.

The kubeconfig uses:

  • Server: https://rancher.emea.roche.com/k8s/clusters/c-2dhbr (Rancher k8s proxy)
  • Auth: bearer token (same RANCHER_BEARER_TOKEN)
  • TLS: insecure-skip-tls-verify: true (Rancher proxy uses its own cert, not the cluster CA)
  • Namespace: per-environment (rdt-model-dev, rdt-model-test, rdt-model-prod)
apiVersion: v1
kind: Config
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://rancher.emea.roche.com/k8s/clusters/c-2dhbr
name: caasawsprod
contexts:
- context:
cluster: caasawsprod
namespace: rdt-model-dev # or rdt-model-test / rdt-model-prod
user: rxpmode1
name: rdt-model-dev
current-context: rdt-model-dev
users:
- name: rxpmode1
user:
token: <RANCHER_BEARER_TOKEN>

Rancher tokens have a fixed expiry (89 days). To renew:

  1. Log in to https://rancher.emea.roche.com as RXPMODE1
  2. User Avatar → Account & API Keys
  3. Click Create API Key
  4. Description: MODEL
  5. Scope: select cluster c-2dhbr (caasawsprod)
  6. Expiry: 89 days (or max allowed)
  7. Copy the bearer token (token-XXXXX:secretkey)
  8. Update Vault:
    Terminal window
    export VAULT_ADDR=https://vault.service.roche.com
    export VAULT_NAMESPACE=rdt-model-prd
    vault login -method=oidc role=default
    vault kv patch secret/common/caas \
    RANCHER_ACCESS_KEY="token-XXXXX" \
    RANCHER_SECRET_KEY="<secret>" \
    RANCHER_BEARER_TOKEN="token-XXXXX:<secret>" \
    RANCHER_TOKEN_EXPIRES="<expiry-date>"
  9. Regenerate kubeconfigs and update Vault + GitHub secrets

Current token expires: 2026-08-04 — rotate before this date.

Rancher is not directly consumed by CLI modules at runtime. It is used for:

ConsumerUsage
Developer setupKubeconfig provisioning for kubectl access
GitHub Actions deploy.ymlDeploys OPA pods to CaaS via kubeconfig
check-rancher.shValidates API access (uses cluster-scoped path)
check-caas.shUses kubeconfig for namespace and RBAC checks

Script: scripts/access/check-rancher.sh

Required tools: curl, (optional) kubectl

Checks performed:

  1. Roche CA certificate installation
  2. Rancher API reachability (GET /v3 — expects 200 or 401)
  3. Authenticated access via /k8s/clusters/c-2dhbr/api/v1/namespaces/rdt-model-dev
  4. Token validity (200 = valid, 401 = expired, 403 = valid but no namespace access)