|
14 | 14 | "outputs": [], |
15 | 15 | "source": [ |
16 | 16 | "# Import pieces from codeflare-sdk\n", |
17 | | - "from codeflare_sdk import Cluster, ClusterConfiguration, TokenAuthentication, RayJobClient" |
| 17 | + "from codeflare_sdk import Cluster, ClusterConfiguration, RayJobClient, set_api_client\n", |
| 18 | + "from kube_authkit import AuthConfig, get_k8s_client" |
18 | 19 | ] |
19 | 20 | }, |
20 | 21 | { |
|
23 | 24 | "metadata": {}, |
24 | 25 | "outputs": [], |
25 | 26 | "source": [ |
26 | | - "# Create authentication object for user permissions\n", |
27 | | - "# IF unused, SDK will automatically check for default kubeconfig, then in-cluster config\n", |
28 | | - "# KubeConfigFileAuthentication can also be used to specify kubeconfig path manually\n", |
29 | | - "auth_token = \"XXXXX\" # The auth_token is used later for the RayJobClient\n", |
30 | | - "auth = TokenAuthentication(\n", |
31 | | - " token = auth_token,\n", |
32 | | - " server = \"XXXXX\",\n", |
33 | | - " skip_tls=False\n", |
| 27 | + "# Authenticate to your Kubernetes/OpenShift cluster using kube-authkit\n", |
| 28 | + "\n", |
| 29 | + "# Option 1: Auto-detect credentials (kubeconfig or in-cluster service account)\n", |
| 30 | + "# NOTE: In RHOAI Workbenches the workbench service account may not have Ray RBAC\n", |
| 31 | + "# permissions. Use Option 2 (token) unless your admin has granted SA permissions\n", |
| 32 | + "# (see RHOAIENG-46748). Auto-detect works if you have a local kubeconfig.\n", |
| 33 | + "# auth_config = AuthConfig(method=\"auto\")\n", |
| 34 | + "\n", |
| 35 | + "# Option 2 (Recommended for RHOAI Workbenches): Token-based authentication\n", |
| 36 | + "# Get your token with: oc whoami -t (or from the OpenShift console → Copy login command)\n", |
| 37 | + "# Note: auth_token is also used below as the bearer token for the RayJobClient\n", |
| 38 | + "auth_token = \"sha256~XXXXX\" # oc whoami -t\n", |
| 39 | + "auth_config = AuthConfig(\n", |
| 40 | + " method=\"openshift\",\n", |
| 41 | + " k8s_api_host=\"https://api.example.com:6443\",\n", |
| 42 | + " token=auth_token,\n", |
34 | 43 | ")\n", |
35 | | - "auth.login()" |
| 44 | + "\n", |
| 45 | + "# Option 3: OIDC authentication (for BYOIDC-enabled clusters)\n", |
| 46 | + "# auth_config = AuthConfig(\n", |
| 47 | + "# method=\"oidc\",\n", |
| 48 | + "# k8s_api_host=\"https://api.example.com:6443\",\n", |
| 49 | + "# oidc_issuer=\"https://your-oidc-provider.com\",\n", |
| 50 | + "# client_id=\"your-client-id\",\n", |
| 51 | + "# use_device_flow=True,\n", |
| 52 | + "# )\n", |
| 53 | + "# auth_token = ... # Retrieve access token from your OIDC provider for RayJobClient\n", |
| 54 | + "\n", |
| 55 | + "api_client = get_k8s_client(config=auth_config)\n", |
| 56 | + "set_api_client(api_client)" |
36 | 57 | ] |
37 | 58 | }, |
38 | 59 | { |
|
273 | 294 | "metadata": {}, |
274 | 295 | "outputs": [], |
275 | 296 | "source": [ |
276 | | - "auth.logout()" |
| 297 | + "# No explicit logout needed - authentication is managed automatically by kube-authkit" |
277 | 298 | ] |
278 | 299 | } |
279 | 300 | ], |
|
0 commit comments