> ## Documentation Index
> Fetch the complete documentation index at: https://orphelix.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Cluster Connection

> Connect Orphelix to your Kubernetes clusters using kubeconfig contexts

## Overview

Orphelix connects to Kubernetes clusters using your local kubeconfig file. Switch between multiple clusters and contexts seamlessly from the dashboard.

![Cluster Connection](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/cluster-connection.png)

## How Cluster Connection Works

Orphelix uses the standard Kubernetes authentication method:

**1. Read Kubeconfig**

Loads `~/.kube/config` on server startup

Location can be overridden with `KUBECONFIG` env var

**2. List Contexts**

Extracts all available contexts from kubeconfig

Each context represents a cluster + user + namespace combination

**3. Select Context**

User selects context from dropdown in header

**4. Authenticate**

Uses credentials from selected context:

* Client certificates
* Bearer tokens
* Cloud provider auth (AWS, GCP, Azure)
* Service account tokens

**5. Connect to API Server**

Establishes connection to Kubernetes API server

All resource queries use this connection

## Kubeconfig File

Standard Kubernetes configuration file:

### Location

> [tab] Default
>
> **Path:** `~/.kube/config`
>
> ```bash theme={null}
> # Check if exists
> ls -la ~/.kube/config
> ```

> [tab] Custom
>
> **Environment variable:** `KUBECONFIG`
>
> ```bash theme={null}
> export KUBECONFIG=/path/to/custom-config
> npm run orphelix start
> ```

> [tab] Multiple Files
>
> **Merged configs:**
>
> ```bash theme={null}
> export KUBECONFIG=~/.kube/config:~/.kube/cluster2.yaml
> npm run orphelix start
> ```
>
> Orphelix merges all files

### Structure

```yaml theme={null}
apiVersion: v1
kind: Config
clusters:
- name: production-cluster
  cluster:
    server: https://prod-k8s.example.com
    certificate-authority-data: LS0tLS...

- name: staging-cluster
  cluster:
    server: https://staging-k8s.example.com
    certificate-authority-data: LS0tLS...

users:
- name: admin-user
  user:
    client-certificate-data: LS0tLS...
    client-key-data: LS0tLS...

- name: developer-user
  user:
    token: eyJhbGci...

contexts:
- name: prod
  context:
    cluster: production-cluster
    user: admin-user
    namespace: default

- name: staging
  context:
    cluster: staging-cluster
    user: developer-user
    namespace: staging

current-context: prod
```

### Key Components

> [accordion] Clusters
>
> Kubernetes API server endpoints
>
> **Required fields:**
>
> * `server`: API server URL
> * `certificate-authority-data`: CA certificate (or path)
>
> **Optional:**
>
> * `insecure-skip-tls-verify`: Skip TLS verification (not recommended)
> * `tls-server-name`: Server name for TLS

> [accordion] Users
>
> Authentication credentials
>
> **Methods:**
>
> * Client certificates (cert + key)
> * Bearer tokens
> * Username + password (deprecated)
> * Cloud provider auth plugins
> * Exec plugins (custom auth)
>
> **Examples:**
>
> ```yaml theme={null}
> # Certificate auth
> user:
>   client-certificate-data: LS0tLS...
>   client-key-data: LS0tLS...
>
> # Token auth
> user:
>   token: eyJhbGci...
>
> # AWS EKS
> user:
>   exec:
>     apiVersion: client.authentication.k8s.io/v1beta1
>     command: aws
>     args:
>       - eks
>       - get-token
>       - --cluster-name
>       - my-cluster
> ```

> [accordion] Contexts
>
> Cluster + User + Namespace combination
>
> **Fields:**
>
> * `cluster`: Which cluster to connect to
> * `user`: Which credentials to use
> * `namespace`: Default namespace (optional)
>
> **Purpose:** Quick switching between environments

## Context Selector

Switch contexts from the Orphelix header:

![Context Selector](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/context-selector.png)

### Features

> [card] Quick Switch
>
> Click dropdown to change contexts instantly

> [card] Search
>
> Filter contexts by name

> [card] Connection Status
>
> Visual indicator shows connection health

> [card] Test Connection
>
> Verify connectivity before switching

### Context Display

Each context shows:

* **Name**: Context identifier
* **Cluster**: Cluster name
* **Server**: API server URL (truncated)
* **Namespace**: Default namespace
* **Status**: Connection indicator

**Connection Status Icons:**

* 🟢 **Connected**: Active, healthy connection
* 🟡 **Connecting**: Establishing connection
* 🔴 **Disconnected**: Cannot connect
* ⚪ **Unknown**: Not yet tested

### Switching Contexts

**1. Click Context Dropdown**

In the top header, click current context name

**2. Select New Context**

Click desired context from list

**3. Wait for Connection**

Orphelix connects to new cluster (1-2 seconds)

**4. Page Refreshes**

Data reloads for new cluster

* Deployments list updates
* Pods list updates
* Dashboard shows new cluster stats

> [!NOTE]
>
> Context selection persists across browser sessions (stored in cookies)

## Testing Connection

Verify cluster connectivity before using:

![Test Connection](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/test-connection.png)

### Test Connection Dialog

**1. Open Dialog**

Click context dropdown → **"Test Connection"** button

**2. Select Context**

Choose context to test

**3. Run Tests**

Orphelix performs checks:

1. **DNS Resolution**: Can resolve API server hostname?
2. **TCP Connection**: Can reach API server port?
3. **TLS Handshake**: Valid certificates?
4. **Authentication**: Valid credentials?
5. **Authorization**: Can list namespaces?
6. **API Version**: Compatible Kubernetes version?

**4. View Results**

Each test shows:

* ✅ Pass: Test succeeded
* ❌ Fail: Test failed (with error message)
* ⏭️ Skipped: Test not applicable

### Test Results

> [tab] All Pass
>
> **Indicator:** Green checkmark
>
> ```
> ✅ DNS Resolution: success
> ✅ TCP Connection: success (123ms)
> ✅ TLS Handshake: success
> ✅ Authentication: success (admin user)
> ✅ Authorization: can list namespaces
> ✅ API Version: v1.28.3
>
> Connection is healthy!
> ```

> [tab] Some Failures
>
> **Indicator:** Yellow warning
>
> ```
> ✅ DNS Resolution: success
> ✅ TCP Connection: success
> ❌ TLS Handshake: certificate verify failed
>    Error: x509: certificate signed by unknown authority
>
> Connection has issues - check certificates
> ```

> [tab] Complete Failure
>
> **Indicator:** Red error
>
> ```
> ✅ DNS Resolution: success
> ❌ TCP Connection: timeout
>    Error: dial tcp 10.0.0.1:6443: i/o timeout
>
> Cannot connect to cluster - check network/firewall
> ```

## Cluster Aliases

Give clusters friendly names:

![Cluster Aliases](https://mintlify.s3.us-west-1.amazonaws.com/orphelix/images/cluster-aliases.png)

### Creating Aliases

**1. Open Settings**

Navigate to Settings → Cluster Configuration tab

**2. Add Alias**

Click **"Add Alias"** button

**3. Configure Alias**

* **Context Name**: Select from dropdown
* **Friendly Name**: Enter display name
* **Icon**: Choose emoji/icon (optional)
* **Description**: Add notes (optional)

Example:

```
Context: arn:aws:eks:us-east-1:123456:cluster/prod
Friendly Name: 🚀 Production (US East)
Description: Main production cluster
```

**4. Save**

Click **"Save"** - alias appears in context selector

### Alias Benefits

> [accordion] Readability
>
> Replace long, cryptic context names with readable labels
>
> **Before:** `gke_my-project_us-central1-a_cluster-1`
>
> **After:** `🌎 GKE Production`

> [accordion] Safety
>
> Prevent accidental operations on wrong cluster
>
> Clear visual distinction between prod/staging/dev

> [accordion] Team Consistency
>
> Everyone sees same cluster names
>
> Shared aliases configuration via settings file

## Multi-Cluster Management

Manage multiple clusters simultaneously:

### Common Scenarios

> [tab] Multi-Environment
>
> **Setup:** Dev, Staging, Production
>
> ```yaml theme={null}
> contexts:
> - name: dev
>   context:
>     cluster: dev-cluster
>     namespace: default
>
> - name: staging
>   context:
>     cluster: staging-cluster
>     namespace: default
>
> - name: prod
>   context:
>     cluster: prod-cluster
>     namespace: default
> ```
>
> **Workflow:**
>
> 1. Test changes in dev
> 2. Promote to staging
> 3. Deploy to production

> [tab] Multi-Region
>
> **Setup:** Different geographic regions
>
> ```yaml theme={null}
> contexts:
> - name: us-east
>   context:
>     cluster: eks-us-east-1
>     namespace: default
>
> - name: eu-west
>   context:
>     cluster: eks-eu-west-1
>     namespace: default
>
> - name: ap-south
>   context:
>     cluster: eks-ap-south-1
>     namespace: default
> ```
>
> **Use case:** Monitor global infrastructure

> [tab] Multi-Tenant
>
> **Setup:** Different customer clusters
>
> ```yaml theme={null}
> contexts:
> - name: customer-a
>   context:
>     cluster: cluster-customer-a
>     namespace: default
>
> - name: customer-b
>   context:
>     cluster: cluster-customer-b
>     namespace: default
> ```
>
> **Use case:** Managed Kubernetes service

### Switching Best Practices

> [accordion] Verify Before Actions
>
> Always check current context before:
>
> * Restarting deployments
> * Editing YAML
> * Scaling resources
>
> Context shown in header - confirm it's correct

> [accordion] Use Clear Naming
>
> Context names should indicate:
>
> * Environment (dev/staging/prod)
> * Region (if multi-region)
> * Purpose (monitoring/management)
>
> Example: `prod-us-east-1-monitoring`

> [accordion] Limit Production Access
>
> Separate kubeconfig files for production:
>
> ```bash theme={null}
> # Development clusters
> export KUBECONFIG=~/.kube/dev-config
>
> # Production clusters (separate terminal)
> export KUBECONFIG=~/.kube/prod-config
> ```
>
> Prevents accidental production changes

## Authentication Methods

Orphelix supports all standard Kubernetes authentication:

### Client Certificates

Most common method:

```yaml theme={null}
users:
- name: admin
  user:
    client-certificate-data: LS0tLS1CRUd...
    client-key-data: LS0tLS1CRUdJT...
```

**Pros:**

* Widely supported
* No token expiration
* Offline authentication

**Cons:**

* Certificate rotation needed
* Key must be kept secure

### Bearer Tokens

Service account or OAuth tokens:

```yaml theme={null}
users:
- name: sa-user
  user:
    token: eyJhbGciOiJSUzI1NiIsImtpZCI6Ik...
```

**Pros:**

* Easy to distribute
* Can have expiration
* Revocable

**Cons:**

* May expire
* Must be refreshed

### Cloud Provider Auth

AWS, GCP, Azure authentication:

> [tab] AWS EKS
>
> ```yaml theme={null}
> users:
> - name: aws-user
>   user:
>     exec:
>       apiVersion: client.authentication.k8s.io/v1beta1
>       command: aws
>       args:
>         - eks
>         - get-token
>         - --cluster-name
>         - my-cluster
>         - --region
>         - us-east-1
> ```
>
> **Requirements:**
>
> * AWS CLI installed
> * AWS credentials configured
> * IAM permissions for EKS

> [tab] GCP GKE
>
> ```yaml theme={null}
> users:
> - name: gcp-user
>   user:
>     exec:
>       apiVersion: client.authentication.k8s.io/v1beta1
>       command: gke-gcloud-auth-plugin
>       installHint: Install gke-gcloud-auth-plugin
>       provideClusterInfo: true
> ```
>
> **Requirements:**
>
> * gcloud CLI installed
> * Authenticated with gcloud
> * GKE cluster access

> [tab] Azure AKS
>
> ```yaml theme={null}
> users:
> - name: azure-user
>   user:
>     exec:
>       apiVersion: client.authentication.k8s.io/v1beta1
>       command: kubelogin
>       args:
>         - get-token
>         - --environment
>         - AzurePublicCloud
>         - --server-id
>         - <client-id>
>         - --tenant-id
>         - <tenant-id>
> ```
>
> **Requirements:**
>
> * Azure CLI installed
> * kubelogin installed
> * Azure AD authentication

## Troubleshooting

### Cannot List Contexts

**Symptom:** Context dropdown is empty

**Causes:**

1. **Kubeconfig Not Found**
   ```bash theme={null}
   ls ~/.kube/config
   # If missing, create one
   ```

2. **Invalid Kubeconfig**
   ```bash theme={null}
   kubectl config view
   # Check for syntax errors
   ```

3. **Wrong KUBECONFIG Path**
   ```bash theme={null}
   echo $KUBECONFIG
   # Verify path is correct
   ```

**Solutions:**

* Create valid kubeconfig file
* Fix YAML syntax errors
* Set correct KUBECONFIG environment variable

### Connection Failed

**Symptom:** "Failed to connect to cluster"

**Diagnostic Steps:**

**1. Test with kubectl**

```bash theme={null}
kubectl cluster-info
kubectl get nodes
```

If kubectl fails, issue is with cluster/credentials, not Orphelix

**2. Check Network**

```bash theme={null}
# Test API server connectivity
curl -k https://api-server-url:6443
```

Should return error (expected), but confirms connectivity

**3. Verify Credentials**

```bash theme={null}
kubectl config view --minify
# Check current context credentials
```

**4. Check Certificates**

```bash theme={null}
# Verify certificates are valid
openssl x509 -in cert.pem -text -noout
```

### Authentication Failed

**Symptom:** "Unauthorized" or "Forbidden" errors

**Common Issues:**

> [accordion] Expired Tokens
>
> Token-based auth expired
>
> **Solution:** Refresh token:
>
> ```bash theme={null}
> # For cloud providers
> aws eks update-kubeconfig --name cluster-name
> gcloud container clusters get-credentials cluster-name
> az aks get-credentials --name cluster-name --resource-group rg
> ```

> [accordion] Insufficient Permissions
>
> User lacks RBAC permissions
>
> **Solution:** Grant necessary permissions:
>
> ```bash theme={null}
> kubectl create clusterrolebinding orphelix-admin \
>   --clusterrole=cluster-admin \
>   --user=myuser
> ```

> [accordion] Wrong User
>
> Context using incorrect user
>
> **Solution:** Update context:
>
> ```bash theme={null}
> kubectl config set-context <context> --user=<correct-user>
> ```

### Certificate Errors

**Symptom:** TLS handshake failures

**Solutions:**

1. **Untrusted CA**
   ```bash theme={null}
   # Option 1: Add CA to system trust store
   # Option 2: Skip verification (not recommended)
   kubectl config set-cluster <cluster> --insecure-skip-tls-verify=true
   ```

2. **Certificate Name Mismatch**
   ```bash theme={null}
   # Set correct TLS server name
   kubectl config set-cluster <cluster> --tls-server-name=kubernetes.example.com
   ```

3. **Expired Certificate**
   * Renew cluster certificates
   * Update kubeconfig with new certificates

## Next Steps

> [card] [Namespaces](https://orphelix.mintlify.site/user/configuration/namespaces.md)
>
> Configure namespace filtering

> [card] [Demo Mode](https://orphelix.mintlify.site/user/configuration/demo-mode.md)
>
> Try demo mode without cluster

> [card] [Settings](https://orphelix.mintlify.site/user/configuration/settings.md)
>
> Configure Orphelix settings

> [card] [Dashboard](https://orphelix.mintlify.site/user/dashboard.md)
>
> View cluster resources


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.