Configure kubectl access to Kubernetes clusters with OIDC authentication (Dex, Azure AD, Keycloak). Validates environment, generates kubeconfigs, and tests connectivity. Trigger with /kubeconfig-setup
I help you configure kubectl access to Kubernetes clusters using OIDC authentication. I validate your environment, generate kubeconfig files with proper OIDC token configuration, and test connectivity. I'm the prerequisite for all cluster-dependent skills.
Supported OIDC Providers:
/kubeconfig-setupRuns environment validation and provides setup guidance:
Usage: Type /kubeconfig-setup and I will validate your environment.
Execute validation:
bash .github/skills/oidc-kubeconfig-setup/scripts/validate.sh
/kubeconfig-configureRuns cluster discovery and kubeconfig generation:
Execute setup:
bash .github/skills/oidc-kubeconfig-setup/scripts/setup-kubeconfig.sh
/kubeconfig-setup (validation)/kubeconfig-configure (setup)Checks all prerequisites before attempting configuration:
# Prerequisites
- kubectl (1.28+)
- jq (JSON processor)
- yq (YAML processor)
- kubelogin (for Azure AD) OR oidc-login (for Dex/generic OIDC)
Installation:
# macOS
brew install kubectl jq yq
# For Azure Entra ID
brew install Azure/kubelogin/kubelogin
# For Dex/generic OIDC (kubelogin kubectl plugin)
kubectl krew install oidc-login
OIDC decouples identity from Kubernetes, enabling centralized authentication through your identity provider.
Dex is an identity service that uses OpenID Connect to drive authentication. It acts as a portal to other identity providers (GitHub, GitLab, LDAP, etc.).
Reference Documentation:
GitHub Organization Groups:
# Dex connector configuration
connectors:
- type: github
id: github
name: GitHub
config:
clientID: $GITHUB_CLIENT_ID
clientSecret: $GITHUB_CLIENT_SECRET
redirectURI: https://dex.example.com/callback
orgs:
- name: your-org
teams:
- platform-team
- developers
Control Plane OIDC Configuration: For configuring your Kubernetes API server to accept Dex tokens, see:
This pattern works with kubeadm, vcluster, k3s, and other distributions.
For organizations using Microsoft identity:
# Kubeconfig user configuration
users:
- name: oidc-user
user:
exec:
apiVersion: client.authentication.k8s.io/v1beta1
command: kubelogin
args:
- get-token
- --server-id
- $OIDC_SERVER_ID
- --client-id
- $OIDC_CLIENT_ID
- --tenant-id
- $OIDC_TENANT_ID
interactiveMode: IfAvailable
Amazon EKS has first-class support for OIDC identity providers and access policy associations.
Reference:
EKS AccessEntry and AccessPolicyAssociation resources allow you to map OIDC identities to Kubernetes RBAC:
# Crossplane-style AccessEntry (conceptual)
apiVersion: eks.aws.upbound.io/v1beta1
kind: AccessEntry
spec:
forProvider:
clusterName: my-cluster
principalArn: arn:aws:iam::ACCOUNT:role/my-oidc-role
type: STANDARD
The setup script generates kubeconfigs with OIDC authentication configured.
Configuration via Environment Variables:
# Required for OIDC
export OIDC_ISSUER_URL="https://dex.example.com"
export OIDC_CLIENT_ID="my-client-id"
export OIDC_CLIENT_SECRET="my-client-secret" # Optional for some flows
# Optional
export OIDC_TENANT_ID="..." # For Azure AD
export OIDC_SERVER_ID="..." # For Azure AD (often same as client ID)
Naming Convention:
./kubeconfigs/kubeconfig-{context-name}
OIDC groups map to Kubernetes RBAC. The Weave GitOps pattern recommends:
# ClusterRoleBinding for admin group
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: platform-admins
subjects:
- kind: Group
name: platform-team # Matches OIDC group claim
apiGroup: rbac.authorization.k8s.io
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
Kubeconfigs use descriptive context names:
# Switch between contexts
kubectl config use-context my-cluster
# View available contexts
kubectl config get-contexts
# Use specific kubeconfig
export KUBECONFIG=$(pwd)/kubeconfigs/kubeconfig-my-cluster
kubectl cluster-info
# 1. Deploy Dex to your cluster (see Weave GitOps docs)
# 2. Create GitHub OAuth application
# 3. Configure Dex with GitHub connector
# 4. Configure API server with OIDC flags
# 5. Generate kubeconfig with OIDC
export OIDC_ISSUER_URL="https://dex.example.com"
export OIDC_CLIENT_ID="kubernetes"
bash .github/skills/oidc-kubeconfig-setup/scripts/setup-kubeconfig.sh
# 6. Test authentication
kubectl get nodes
# Browser opens for GitHub authentication
# 1. Configure Azure AD application registration
# 2. Set environment variables
export OIDC_CLIENT_ID="your-client-id"
export OIDC_TENANT_ID="your-tenant-id"
# 3. Run setup
bash .github/skills/oidc-kubeconfig-setup/scripts/setup-kubeconfig.sh
# 4. Authenticate
kubectl get nodes
# Browser opens for Microsoft authentication
error: You must be logged in to the server (Unauthorized)
Solution: Re-authenticate through your OIDC provider. Delete cached tokens if needed:
rm -rf ~/.kube/cache/oidc-login/
Error from server (Forbidden): pods is forbidden
Check:
kubectl auth whoami (K8s 1.28+) to see your identityerror: unable to get token: oidc: issuer did not match
Cause: Issuer URL mismatch between kubeconfig and Dex configuration.
Solution: Ensure OIDC_ISSUER_URL exactly matches Dex's issuer configuration.
# Verify tools installed
kubectl version --client
jq --version
yq --version
# Check for OIDC plugins
kubelogin --version # Azure AD
kubectl oidc-login --version # Generic OIDC
# Generic OIDC (Dex, Keycloak, etc.)
export OIDC_ISSUER_URL="https://dex.example.com"
export OIDC_CLIENT_ID="kubernetes"
export OIDC_CLIENT_SECRET="" # Often empty for public clients
# Azure AD specific
export OIDC_TENANT_ID="your-tenant-id"
export OIDC_SERVER_ID="your-server-id" # Often same as client ID
bash .github/skills/oidc-kubeconfig-setup/scripts/setup-kubeconfig.sh
export KUBECONFIG=$(pwd)/kubeconfigs/kubeconfig-my-cluster
kubectl cluster-info
kubectl get nodes
You know this skill worked when:
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer