跳到正文
cccskills
免费在 GitHub 公开

kubesphere-gateway

Install, upgrade, and remove the ingress-nginx-based KubeSphere Gateway extension, which manages external access to applications. Inspect gateways across cluster, workspace, and project scopes, and investigate stalled operations, Helm installation failures, or pod problems.

中文简介正在准备中。当前显示英语简介。

原文查看原文说明

KubeSphere Gateway extension management Skill (ingress-nginx based, uses Kubernetes Ingress API + Gateway CRD gateway.kubesphere.io/v2alpha2). For the newer Kubernetes Gateway API (Traefik + GatewayProxy CRD), see the kubesphere-gateway-api skill instead. Covers installation, uninstallation, status checks, gateway status inspection, and troubleshooting (gateway stuck states, Helm failures, pod issues).

集成工具Kubernetes
查看安装方法

适用场景

  • Installing or upgrading the Gateway extension
  • Checking gateways by cluster, workspace, or project
  • Investigating stalled gateway operations and pod failures
  • Removing the extension from selected clusters

包含的文件(5)

  • SKILL.md11.4 KB
  • references/extension-values.md3.6 KB
  • scripts/check-status.sh2.4 KB
  • scripts/generate-installplan.sh1.3 KB
  • scripts/verify-uninstall.sh981 B

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

KubeSphere Gateway

Overview

Provides external access management (ingress) for KubeSphere using ingress-nginx. Supports three-tier gateway management:

| Tier | Scope | Name Pattern | Namespace | Label | |---|---|---|---| | Cluster | Entire cluster | kubesphere-router-cluster | kubesphere-controls-system | kubesphere.io/gateway-type=cluster | | Workspace | Single workspace | kubesphere-router-workspace-{workspace} | kubesphere-controls-system | kubesphere.io/gateway-type=workspace | | Project | Single project/namespace | kubesphere-router-{namespace} | kubesphere-controls-system | kubesphere.io/gateway-type=project |

Each gateway is a standalone Helm release of ingress-nginx. The gateway-controller-manager manages the lifecycle (install/upgrade/uninstall) via Helm.

Core CRDs

  • Gateway (gateway.kubesphere.io/v2alpha2) — represents a single ingress-nginx deployment. Key fields:

    • spec.appVersion — the Helm chart version (e.g. kubesphere-nginx-ingress-<version>)
    • spec.values — Helm values for ingress-nginx (controller config, service type, resources, etc.)
    • status.state — Creating, Updating, Running, Faulted, Stopped
    • status.conditions[].type=GatewayReady — True when fully operational
    • status.loadBalancer — LB ingress IPs/hostnames
    • status.service — Service type, ports, external IPs
  • UpgradePlan (gateway.kubesphere.io/v2alpha2) — batch gateway upgrade job. Key fields:

    • spec.gatewayReferences — list of {name, namespace} to upgrade
    • spec.targetAppVersion — target version
    • status.state — Pending, Running, Succeeded, Failed

Monitoring Integration

Gateway exposes NGINX metrics (requests, 4xx/5xx, latency P50/P90/P99) via Prometheus. Requires the whizard-monitoring extension (optional dependency).


Before You Start

Check if Gateway extension is already installed:

kubectl get installplans.kubesphere.io gateway --ignore-not-found

If found, upgrading is supported — just select a newer version in Step 1.


Installation

Step 1: Detect and Select Version

ALL_VERSIONS=$(kubectl get extensionversions.kubesphere.io \
  -l kubesphere.io/extension-ref=gateway \
  -o jsonpath='{range .items[*]}{.spec.version}{"\n"}{end}' | sort -V)

LATEST_STABLE=$(echo "$ALL_VERSIONS" | grep -v -E 'alpha|beta|rc' | tail -1)
if [ -z "$LATEST_STABLE" ]; then
  LATEST_STABLE=$(echo "$ALL_VERSIONS" | tail -1)
fi

echo "Available versions:"
echo "$ALL_VERSIONS"
echo ""
echo "Latest stable: $LATEST_STABLE"

This sets ALL_VERSIONS and LATEST_STABLE. Use SELECTED_VERSION for the version chosen.

Use the question tool:

  • $LATEST_STABLE (Recommended) — accept the auto-detected version
  • (custom) — type a specific version; validate it against the printed list

Step 2: Detect and Select Clusters

CLUSTER_DATA=$(kubectl get clusters.cluster.kubesphere.io \
  -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.conditions[?(@.type=="Ready")].status}{"\n"}{end}')

READY_CLUSTERS=$(echo "$CLUSTER_DATA" | awk -F'\t' '$2 == "True" {print $1}')
CLUSTER_COUNT=$(echo "$READY_CLUSTERS" | wc -l)

HOST_CLUSTER=$(kubectl get clusters.cluster.kubesphere.io \
  -l 'cluster-role.kubesphere.io/host' \
  -o jsonpath='{.items[0].metadata.name}' || echo "")

echo "Ready clusters:"
echo "$READY_CLUSTERS"
echo ""
echo "Cluster count: $CLUSTER_COUNT"
echo "Host cluster: $HOST_CLUSTER"

This sets READY_CLUSTERS, CLUSTER_COUNT, HOST_CLUSTER.

  • 1 cluster → skip selection, auto-use it. Set TARGET_CLUSTERS="$HOST_CLUSTER"
  • Multiple clusters → use question with multiple: true:
    • All clusters → TARGET_CLUSTERS="$READY_CLUSTERS"
    • Host cluster only → TARGET_CLUSTERS="$HOST_CLUSTER"
    • (custom) — validate each name against $READY_CLUSTERS

Step 3: Generate and Apply InstallPlan

./scripts/generate-installplan.sh "$SELECTED_VERSION" "$TARGET_CLUSTERS"

This generates the YAML to /tmp/gateway-installplan.yaml, runs --dry-run=server, then prints the apply command.

For configurable extension values (ingress-nginx default settings, image registry, upgrade tool config, etc.), see references/extension-values.md.

Apply it:

kubectl apply -f /tmp/gateway-installplan.yaml

Tell the user "Installing". Then ask if they want to check status. If yes:

./scripts/check-status.sh poll

Status Checking

PurposeCommand
Single snapshot./scripts/check-status.sh quick
Wait until complete (5min timeout)./scripts/check-status.sh poll

Logic:

  • All Installed → ✓ success
  • Any Failed → ✗ prints full status
  • Timeout (300s) → ⚠ prints current status
  • In progress → prints every 10s

Uninstallation

⚠ Always confirm with the user before proceeding.

Uninstall from all clusters

if ! kubectl get installplans.kubesphere.io gateway &>/dev/null; then
  echo "Gateway is not installed."
  exit 0
fi

Confirm with the user, then delete:

kubectl delete installplans.kubesphere.io gateway --ignore-not-found

Verify cleanup:

./scripts/verify-uninstall.sh

Success criteria:

  1. InstallPlan is deleted
  2. No active pods remain in extension-gateway namespace

Uninstall from specific clusters

WARNING: Do NOT delete the InstallPlan. Only remove target clusters from the placement list.

Confirm which clusters to remove, compute remaining clusters, then patch:

kubectl patch installplans.kubesphere.io gateway --type='json' \
  -p='[{"op": "replace", "path": "/spec/clusterScheduling/placement/clusters", "value": ["<REMAINING_CLUSTER_1>", "<REMAINING_CLUSTER_2>"]}]'

Success: patch returns OK + removed clusters no longer in .status.clusterSchedulingStatuses.


Gateway Operations

List Gateways

Gateways are organized by tier (see Overview), with each tier identified by the label kubesphere.io/gateway-type. List them grouped by tier:

echo "=== Cluster Gateway ==="
kubectl get gateways.gateway.kubesphere.io -n kubesphere-controls-system \
  -l kubesphere.io/gateway-type=cluster

echo -e "\n=== Workspace Gateways ==="
kubectl get gateways.gateway.kubesphere.io -n kubesphere-controls-system \
  -l kubesphere.io/gateway-type=workspace

echo -e "\n=== Project Gateways ==="
kubectl get gateways.gateway.kubesphere.io -n kubesphere-controls-system \
  -l kubesphere.io/gateway-type=project

Check Gateway Status

Pick a gateway name from the List Gateways output and run:

GW_NS="kubesphere-controls-system"
GW_NAME="<gateway-name-from-list>"

# app.kubernetes.io/instance uses the Helm release name if available, otherwise the Gateway name
GW_INSTANCE=$(kubectl get gateways.gateway.kubesphere.io -n $GW_NS $GW_NAME -o jsonpath='{.status.helmRelease.name}' 2>/dev/null)
if [ -z "$GW_INSTANCE" ]; then
  GW_INSTANCE="$GW_NAME"
fi

kubectl get gateways.gateway.kubesphere.io -n $GW_NS $GW_NAME -o wide
kubectl describe gateways.gateway.kubesphere.io -n $GW_NS $GW_NAME
kubectl get gateways.gateway.kubesphere.io -n $GW_NS $GW_NAME -o yaml
kubectl get pods -n $GW_NS -l "app.kubernetes.io/instance=$GW_INSTANCE"

Gateway states:

StateMeaning
CreatingFirst-time Helm install in progress
UpdatingHelm upgrade in progress (spec changed)
RunningFully operational (all replicas available)
FaultedDeployment missing, stopped unexpectedly, or health probe timeout
StoppedScaled to zero replicas intentionally

Troubleshooting

Set $GW_NAME according to the gateway tier being troubleshot (see naming rules in Overview):

  • Cluster → GW_NAME=kubesphere-router-cluster
  • Workspace → GW_NAME=kubesphere-router-workspace-${WORKSPACE}
  • Project → GW_NAME=kubesphere-router-${NAMESPACE}

Common namespace: GW_NS=kubesphere-controls-system

$GW_INSTANCE is auto-resolved from status.helmRelease.name (falls back to $GW_NAME). If not yet set, run:

GW_INSTANCE=$(kubectl get gateways.gateway.kubesphere.io -n $GW_NS $GW_NAME -o jsonpath='{.status.helmRelease.name}' 2>/dev/null)
if [ -z "$GW_INSTANCE" ]; then
  GW_INSTANCE="$GW_NAME"
fi

Gateway stuck in Creating or Updating state

kubectl describe gateways.gateway.kubesphere.io -n $GW_NS $GW_NAME

kubectl logs -n extension-gateway -l app=gateway-controller-manager --tail=200 | grep -iE "(error|helm|install|upgrade|reconcile)"

kubectl get deployment -n $GW_NS -l "app.kubernetes.io/instance=$GW_INSTANCE,app.kubernetes.io/component=controller"

kubectl get configmap -n $GW_NS $GW_NAME -o yaml

Common causes: Chart ConfigMap missing/corrupted, Helm wrapper timeout, invalid spec.values.

Gateway shows Faulted state

kubectl get deployment -n $GW_NS $GW_NAME -o wide
kubectl describe deployment -n $GW_NS $GW_NAME
kubectl get pods -n $GW_NS -l "app.kubernetes.io/instance=$GW_INSTANCE" -o wide

POD_NAME=$(kubectl get pods -n $GW_NS -l "app.kubernetes.io/instance=$GW_INSTANCE" -o jsonpath='{.items[0].metadata.name}')
kubectl describe pod -n $GW_NS $POD_NAME
kubectl logs -n $GW_NS $POD_NAME --tail=100

Common causes: Image pull failure, resource constraints, port conflicts, missing ConfigMap/Secret.

Gateway pod crash-looping / CrashLoopBackOff

kubectl logs -n $GW_NS -l "app.kubernetes.io/instance=$GW_INSTANCE" --tail=100 --previous
kubectl get events -n $GW_NS --sort-by='.lastTimestamp' | tail -20
kubectl exec -n $GW_NS -l "app.kubernetes.io/instance=$GW_INSTANCE" -- cat /etc/nginx/nginx.conf 2>/dev/null | head -50
kubectl get configmap -n $GW_NS -l "app.kubernetes.io/instance=$GW_INSTANCE" -o yaml

Common causes: Misconfigured nginx config, port conflicts, resource limits (OOMKilled), missing dependencies (ConfigMap/Secret).

Log search not working

Gateway log search proxies to whizard-telemetry-apiserver:

kubectl get configmap -n extension-gateway gateway-agent-backend-config -o yaml
kubectl get pods -n extension-whizard-telemetry
kubectl get svc -n extension-whizard-telemetry whizard-telemetry-apiserver
kubectl logs -n extension-gateway -l app=gateway-apiserver --tail=100 | grep -iE "(log|search|whizard|proxy)"

Common causes: Whizard-telemetry not installed or not running, misconfigured gateway-agent-backend-config, network policy blocking cross-namespace traffic.

Gateway controller not reconciling

kubectl get pods -n extension-gateway -l app=gateway-controller-manager
kubectl logs -n extension-gateway -l app=gateway-controller-manager --tail=200
kubectl get validatingwebhookconfiguration -l "app.kubernetes.io/managed-by=Helm,kubesphere.io/extension-ref=gateway"
kubectl get deployment -n extension-gateway -l app=gateway-controller-manager -o yaml

Common causes: Controller pod not running, webhook configuration blocking updates, Helm release state mismatch, RBAC permission issues.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Manage FrontendExtension resources in frontend-forge, from creation and package generation to downloading, publishing, and unpublishing. Inspect generated files, Kubernetes jobs, and status information to diagnose packaging or publishing failures.

中文简介正在准备中。当前显示英语简介。

  • Create or update a FrontendExtension
  • Rebuild and download an extension package
  • Publish, unpublish, or remove an extension
kubesphere/kubesphere1.7万2026年7月15日 更新

Operate FrontendIntegration resources from existing YAML definitions using kubectl, the Kubernetes command-line tool. Manage updates and enabled state, inspect build output, troubleshoot failures, and install or manage the frontend-forge extension.

中文简介正在准备中。当前显示英语简介。

  • Create a FrontendIntegration from existing YAML
  • Update, enable, or disable a FrontendIntegration
  • Inspect build output and troubleshoot failures
kubesphere/kubesphere1.7万2026年7月15日 更新

Generate FrontendIntegration YAML for frontend-forge from a simplified configuration containing one menu and one or more pages. Define resource tables or embedded iframe pages, with the bundled generator expanding menu placements into the required YAML structure.

中文简介正在准备中。当前显示英语简介。

  • Generating integration YAML for a CRD resource table
  • Defining an embedded iframe page
  • Converting a single-menu configuration into canonical YAML
kubesphere/kubesphere1.7万2026年7月15日 更新

kubeeye

免费

Set up KubeEye in KubeSphere to inspect Kubernetes clusters. Define checks for configurations, nodes, and services, schedule recurring or one-time inspections, and retrieve findings as HTML or spreadsheet reports.

中文简介正在准备中。当前显示英语简介。

  • Install KubeEye for cluster inspections
  • Create checks for node health and configuration
  • Schedule recurring cluster inspections
kubesphere/kubesphere1.7万2026年7月15日 更新

Inspect KubeSphere clusters with read-only commands. List clusters, view detailed configuration, identify host and member roles, and review connection types, readiness indicators, and KubeSphere and Kubernetes versions without changing cluster resources.

中文简介正在准备中。当前显示英语简介。

  • List clusters registered in KubeSphere
  • Check cluster readiness
  • Review KubeSphere and Kubernetes versions
kubesphere/kubesphere1.7万2026年7月15日 更新

Understand KubeSphere architecture and call its APIs with a script that handles authentication. This skill also directs cluster, user, workspace, and extension management requests to the relevant specialist skills.

中文简介正在准备中。当前显示英语简介。

  • Understand KubeSphere core components
  • Choose API paths for Kubernetes and KubeSphere operations
  • Send API requests to a specific member cluster
kubesphere/kubesphere1.7万2026年7月15日 更新

查看 kubesphere 的全部技能

报告此技能的问题