From da105f9511bbffa10f9a9a7d3e8df0a30f46fe80 Mon Sep 17 00:00:00 2001 From: Aryanbhargava18 Date: Wed, 25 Nov 2026 05:48:23 +0530 Subject: [PATCH] feat(skills): add openyurt-raven, raven-topology, and yurthub-autonomy skills Signed-off-by: Aryanbhargava18 --- .claude/skills/README.md | 5 +- .claude/skills/openyurt-raven/SKILL.md | 78 ++++++ .../references/openyurt-raven-flow.md | 236 ++++++++++++++++++ .../openyurt-raven-troubleshooting.md | 109 ++++++++ .claude/skills/raven-topology/SKILL.md | 66 +++++ .claude/skills/yurthub-autonomy/SKILL.md | 73 ++++++ 6 files changed, 566 insertions(+), 1 deletion(-) create mode 100644 .claude/skills/openyurt-raven/SKILL.md create mode 100644 .claude/skills/openyurt-raven/references/openyurt-raven-flow.md create mode 100644 .claude/skills/openyurt-raven/references/openyurt-raven-troubleshooting.md create mode 100644 .claude/skills/raven-topology/SKILL.md create mode 100644 .claude/skills/yurthub-autonomy/SKILL.md diff --git a/.claude/skills/README.md b/.claude/skills/README.md index 7386594820f..ec53d0bd56c 100644 --- a/.claude/skills/README.md +++ b/.claude/skills/README.md @@ -6,8 +6,11 @@ picks them up automatically when it is started inside this repository. | Skill | Invoke | Scope | |---|---|---| | [openyurt-deploy](openyurt-deploy/SKILL.md) | `/openyurt-deploy [node ...]` | Install yurt-manager v1.7.0 on an existing kubeadm cluster, convert/revert worker nodes with the label-driven `YurtNodeConversionController`, enable autonomy, recover failed conversions, uninstall | +| [openyurt-raven](openyurt-raven/SKILL.md) | `/openyurt-raven [gateway ...]` | Deploy `raven-agent` and configure cross-NodePool L3 tunnel and L7 proxy networking via `Gateway` (`raven.openyurt.io/v1beta1`) CRs | +| [raven-topology](raven-topology/SKILL.md) | `/raven-topology` | Diagnose Raven gateway election, `raven-agent-ds` L3 VPN tunnels, and L7 proxy endpoints (`yurt-manager` controllers) | +| [yurthub-autonomy](yurthub-autonomy/SKILL.md) | `/yurthub-autonomy [node]` | Verify edge node autonomy (`node.openyurt.io/autonomy-duration`), pod eviction tolerations, and YurtHub offline cache state | -Planned, not included yet: `openyurt-raven` (cross-pool networking), `yurtadm join` +Planned, not included yet: `yurtadm join` flows, versioned references for releases after v1.7.0. ## Using `/openyurt-deploy` diff --git a/.claude/skills/openyurt-raven/SKILL.md b/.claude/skills/openyurt-raven/SKILL.md new file mode 100644 index 00000000000..39e7dbb5ae6 --- /dev/null +++ b/.claude/skills/openyurt-raven/SKILL.md @@ -0,0 +1,78 @@ +--- +name: openyurt-raven +description: Configure Raven cross-NodePool networking in OpenYurt by deploying raven-agent, creating Gateway (raven.openyurt.io/v1beta1) CRs with L3 tunnel and L7 proxy support, and verifying cross-pool connectivity. +when_to_use: Use when the user wants to configure Raven VPN tunnels, cross-NodePool networking, L3/L7 proxy gateways, or troubleshoot cross-region connectivity between edge NodePools. +argument-hint: "[gateway ...]" +disable-model-invocation: true +allowed-tools: Read Grep Bash(helm version) Bash(kubectl --context * get *) Bash(kubectl --context * logs *) +--- + +# OpenYurt Raven Skill + +Configures Raven for cross-NodePool L3 VPN tunneling and L7 proxying in +OpenYurt. Gateway control-plane reconciliation runs inside `yurt-manager` +(`pkg/yurtmanager/controller/raven/`), and the node data-plane DaemonSet +(`raven-agent-ds`) is installed from `openyurtio/raven`. + +## Prerequisites + +- OpenYurt (`yurt-manager` in `kube-system`) must already be deployed; otherwise run + `/openyurt-deploy` first. +- Requirements on the operator workstation: `kubectl`, `helm` (v3 or v4), `openssl`. +- Everything is executed through the Kubernetes API and Helm; no SSH. + +## Rules + +**Target cluster.** Before any cluster command, show `kubectl config get-contexts` +and ask the user to confirm the target context ``. Pass `--context ` to +every `kubectl` command and `--kube-context --namespace kube-system` to +every `helm` command. + +**Confirmation.** Before every change to the cluster (`helm upgrade --install`, +`kubectl apply/create/delete/label`, ephemeral check Jobs or test DaemonSets), +show a change card and wait for an explicit "yes": + +```text +Context: +Target: +Action: +Impact: +Rollback: +``` + +**PSK hygiene.** Always generate the VPN PSK with `openssl rand -hex 64` and +never echo or print the raw PSK value to terminal output or logs. + +## Key Facts (OpenYurt source & `openyurtio/raven`) + +- **Gateway CR (`raven.openyurt.io/v1beta1`, shortName `gw`):** Defined in + `pkg/apis/raven/v1beta1/gateway_types.go`. + - `spec.nodeSelector` uses `metav1.LabelSelector` (`matchLabels` / `matchExpressions`). + The `SetDefaultsGateway` mutating webhook (`pkg/apis/raven/v1beta1/default.go`) + merges `raven.openyurt.io/gateway: ` into + `spec.nodeSelector.matchLabels` without overwriting other `matchLabels`, and + defaults unset endpoint ports to `10262` (`proxy`) or `4500` (`tunnel`). + - `spec.exposeType` must be `PublicIP` or `LoadBalancer` when set, and exposed + gateways require `endpoints[*].underNAT: false` + (`pkg/yurtmanager/webhook/gateway/v1beta1/gateway_validation.go`). + - `spec.tunnelConfig.Replicas` cannot exceed `1`, and `spec.proxyConfig.Replicas` + cannot exceed the count of `type: proxy` endpoints (typically `1`). Note the + capital `R` in JSON/YAML (`Replicas`). +- **Global enablement (`kube-system/raven-cfg`):** The Raven controllers read the + `raven-cfg` ConfigMap in `kube-system` for `enable-l3-tunnel` and + `enable-l7-proxy` (`pkg/yurtmanager/controller/raven/util/constants.go` and + `util.go`). These keys are rendered by the `raven-agent` Helm chart from + `controller.enableTunnel` and `controller.enableProxy`. +- **Raven Agent chart resources (`openyurtio/raven/charts/raven-agent`):** + Deploys `DaemonSet/raven-agent-ds` (pods labeled `app=raven-agent`), + `ConfigMap/raven-cfg`, `ConfigMap/raven-agent-config`, and + `Secret/raven-agent-secret` (key `vpn-connection-psk`, populated via + `vpn.psk`) in `kube-system`. Notice the DaemonSet runs privileged hostNetwork + pods across Linux nodes; always confirm with the user before installing. + +## Reference Documents + +| Document | Purpose | +|---|---| +| `references/openyurt-raven-flow.md` | Step-by-step Raven deployment, Gateway creation, and L3 verification | +| `references/openyurt-raven-troubleshooting.md` | Decision tree for `raven-agent-ds`, `Gateway` election, PSK, and L3/L7 routing | diff --git a/.claude/skills/openyurt-raven/references/openyurt-raven-flow.md b/.claude/skills/openyurt-raven/references/openyurt-raven-flow.md new file mode 100644 index 00000000000..122073056b3 --- /dev/null +++ b/.claude/skills/openyurt-raven/references/openyurt-raven-flow.md @@ -0,0 +1,236 @@ +# OpenYurt Raven Configuration Flow + +Execute these steps in order. `` is the kube context confirmed in Step 0. +Every cluster change requires a change card and explicit "yes" (see `SKILL.md`). + +--- + +## Step 0: Lock Target Cluster and Prerequisites + +1. Show `kubectl config get-contexts` and ask the user to confirm the target + context ``. +2. Verify OpenYurt (`yurt-manager`) and `NodePool`s exist: + +```bash +kubectl --context get deployment yurt-manager -n kube-system +kubectl --context get nodepools.apps.openyurt.io +helm version +``` + +If `yurt-manager` is missing, stop and ask the user to run `/openyurt-deploy` +first. + +--- + +## Step 1: Collect Cluster Parameters + +Ask the user for: + +- **Target NodePools / Gateways:** At least two NodePools are normally used for + cross-pool networking (e.g., cloud pool + edge pool, or two edge pools). +- **L3 tunnel enabled:** `true` or `false` (`controller.enableTunnel`). +- **L7 proxy enabled:** `true` or `false` (`controller.enableProxy`). +- **VPN driver (when L3 is enabled):** `libreswan` (default, IPsec UDP `4500` / + ESP) or `wireguard` (requires WireGuard kernel module on gateway nodes). +- **Gateway `exposeType`:** `PublicIP` or `LoadBalancer`. + +If the cluster uses **Calico**, note that `FelixConfiguration` must set +`iptablesMangleAllowAction: Return` so Raven's `PREROUTING` rules take effect. + +--- + +## Step 2: Install `raven-agent` via Helm + +Show a change card explaining that `raven-agent-ds` runs privileged +`hostNetwork: true` pods on Linux nodes, then install in `kube-system`: + +```bash +helm repo add openyurt https://openyurtio.github.io/openyurt-helm +helm repo update +``` + +Generate a fresh PSK and pass it directly without printing it to stdout: + +```bash +PSK=$(openssl rand -hex 64) +helm upgrade --install raven-agent openyurt/raven-agent \ + --kube-context \ + --namespace kube-system \ + --set vpn.psk="$PSK" \ + --set vpn.driver="" \ + --set controller.enableTunnel="" \ + --set controller.enableProxy="" +unset PSK +``` + +*(If installing from a source checkout of `github.com/openyurtio/raven` instead +of the Helm repo, point to `./charts/raven-agent`.)* + +Verify rollout and ConfigMap state: + +```bash +kubectl --context -n kube-system rollout status daemonset/raven-agent-ds --timeout=120s +kubectl --context -n kube-system get configmap raven-cfg -o yaml +``` + +### Optional Pre-Check for `libreswan` IPsec Binary + +If `vpn.driver=libreswan` and L3 tunneling is enabled, you can verify `ipsec` +on gateway candidate nodes through a short-lived Job (with change card confirmation): + +```bash +NODE_NAME="" +cat < apply -f - +apiVersion: batch/v1 +kind: Job +metadata: + name: check-ipsec-$NODE_NAME + namespace: kube-system +spec: + template: + spec: + nodeName: $NODE_NAME + hostNetwork: true + tolerations: + - operator: Exists + containers: + - name: check + image: busybox:1.36.1 + command: ["/bin/sh", "-c"] + args: ["if [ ! -x /host/usr/sbin/ipsec ] && [ ! -x /host/usr/libexec/ipsec/whack ] && [ ! -x /host/usr/local/sbin/ipsec ]; then echo 'IPsec binary not found'; else echo 'IPsec verified'; fi"] + volumeMounts: + - name: host-root + mountPath: /host + readOnly: true + volumes: + - name: host-root + hostPath: + path: / + restartPolicy: Never +EOF +kubectl --context -n kube-system wait --for=condition=complete job/check-ipsec-$NODE_NAME --timeout=30s || true +kubectl --context -n kube-system logs job/check-ipsec-$NODE_NAME 2>/dev/null +kubectl --context -n kube-system delete job check-ipsec-$NODE_NAME 2>/dev/null +``` + +--- + +## Step 3: Label Nodes and Create `Gateway` CRs + +For each NodePool participating in Raven: + +### 3.1 Label nodes for Gateway selection + +Label the nodes **before** creating the `Gateway` CR so the `gatewaypickup` +controller discovers them immediately: + +```bash +kubectl --context label node -l apps.openyurt.io/nodepool= \ + raven.openyurt.io/gateway=-gw +``` + +> **Note:** `SetDefaultsGateway` (`pkg/apis/raven/v1beta1/default.go`) merges +> `raven.openyurt.io/gateway: ` into +> `spec.nodeSelector.matchLabels`. Keep `matchLabels` aligned with the label +> applied to your nodes. + +### 3.2 Create the `Gateway` CR (`raven.openyurt.io/v1beta1`) + +Adjust `endpoints` to match the gateway-eligible nodes in that pool. Note that +when `exposeType` is set (`PublicIP` or `LoadBalancer`), `gateway_validation.go` +requires `underNAT: false` on exposed endpoints; edge gateways behind NAT omit +`exposeType` and set `underNAT: true`: + +```yaml +apiVersion: raven.openyurt.io/v1beta1 +kind: Gateway +metadata: + name: -gw + # Optional extra CIDRs routed through this gateway: + # annotations: + # raven.openyurt.io/extra-allowed-source-cidrs: "192.168.100.0/24" +spec: + nodeSelector: + matchLabels: + raven.openyurt.io/gateway: -gw + exposeType: PublicIP # Omit when endpoints are underNAT: true + endpoints: + - nodeName: + type: tunnel + underNAT: false + - nodeName: + type: proxy + underNAT: false + tunnelConfig: + Replicas: 1 + proxyConfig: + Replicas: 1 +``` + +Apply with a change card confirmation: + +```bash +kubectl --context apply -f gateway.yaml +``` + +### 3.3 Verify active endpoint election + +```bash +kubectl --context get gateways.raven.openyurt.io +kubectl --context get gateway -gw -o jsonpath='{.status.activeEndpoints}{"\n"}' +``` + +If `activeEndpoints` is empty, inspect `references/openyurt-raven-troubleshooting.md`. + +--- + +## Step 4: Verify Cross-Node Connectivity + +With user confirmation, deploy a short-lived test `DaemonSet`, verify pod-to-pod +reachability across distinct nodes/pools without writing temporary files to +disk, and clean up afterwards: + +```bash +cat < apply -f - +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: raven-test + namespace: default +spec: + selector: + matchLabels: + app: raven-test + template: + metadata: + labels: + app: raven-test + spec: + tolerations: + - operator: Exists + containers: + - name: test + image: busybox:1.36.1 + command: ["sleep", "3600"] +EOF + +kubectl --context -n default wait --for=condition=Ready pod -l app=raven-test --timeout=120s + +PODS=$(kubectl --context -n default get pods -l app=raven-test -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.status.podIP}{"\t"}{.spec.nodeName}{"\n"}{end}') +printf '%s\n' "$PODS" + +POD1=$(printf '%s\n' "$PODS" | awk 'NR==1 {print $1}') +NODE1=$(printf '%s\n' "$PODS" | awk 'NR==1 {print $3}') +POD2_LINE=$(printf '%s\n' "$PODS" | awk -v n="$NODE1" '$3!=n {print $1 "\t" $2 "\t" $3; exit}') + +if [ -z "$POD2_LINE" ]; then + echo "Need test pods on at least 2 nodes across pools to test Raven." +else + POD2_IP=$(printf '%s\n' "$POD2_LINE" | awk '{print $2}') + NODE2=$(printf '%s\n' "$POD2_LINE" | awk '{print $3}') + echo "Testing $POD1 ($NODE1) -> $POD2_IP ($NODE2)" + kubectl --context -n default exec "$POD1" -- ping -c 3 -W 5 "$POD2_IP" +fi + +kubectl --context -n default delete daemonset raven-test --ignore-not-found +``` diff --git a/.claude/skills/openyurt-raven/references/openyurt-raven-troubleshooting.md b/.claude/skills/openyurt-raven/references/openyurt-raven-troubleshooting.md new file mode 100644 index 00000000000..349a39a369e --- /dev/null +++ b/.claude/skills/openyurt-raven/references/openyurt-raven-troubleshooting.md @@ -0,0 +1,109 @@ +# Raven Troubleshooting + +Decision tree for diagnosing Raven L3 tunnel and L7 proxy failures. Pass +`--context ` on every `kubectl` command. + +--- + +## 1. `raven-agent-ds` Not Running + +```bash +kubectl --context -n kube-system get daemonset raven-agent-ds +kubectl --context -n kube-system get pods -l app=raven-agent -o wide +``` + +- **DaemonSet missing:** Install the `raven-agent` Helm chart in `kube-system`. +- **Pods not Ready:** Inspect logs: + ```bash + kubectl --context -n kube-system logs -l app=raven-agent --tail=50 + ``` + - **IPsec / `libreswan` errors:** Ensure `libreswan` is installed on nodes when + `vpn.driver=libreswan` (run the read-only `check-ipsec` Job from + `openyurt-raven-flow.md`), or switch `vpn.driver` to `wireguard` where kernel + support is available. + +--- + +## 2. `Gateway` CR Not Electing Active Endpoints + +```bash +kubectl --context get gateway -o yaml +``` + +Check `status.activeEndpoints` and `status.nodes`. The `gatewaypickup` +controller inside `yurt-manager` manages election +(`pkg/yurtmanager/controller/raven/gatewaypickup/gateway_pickup_controller.go`): + +- **Global enablement disabled in `kube-system/raven-cfg`:** + `util.CheckServer` skips election for `proxy` / `tunnel` when + `enable-l7-proxy` / `enable-l3-tunnel` are not `"true"`: + ```bash + kubectl --context -n kube-system get configmap raven-cfg -o yaml + ``` +- **Nodes not matched:** Confirm nodes carry `raven.openyurt.io/gateway=` + and match `spec.nodeSelector`, and are `Ready` (`NodeReady=True`): + ```bash + kubectl --context get nodes -l raven.openyurt.io/gateway= + ``` +- **Missing or invalid `spec.endpoints`:** + `electEndpoints` only selects from `Ready` nodes listed in `spec.endpoints` + whose `type` (`tunnel` or `proxy`) matches an enabled feature. + Check `yurt-manager` logs for webhook or reconciliation errors: + ```bash + kubectl --context -n kube-system logs -l app.kubernetes.io/name=yurt-manager --tail=100 + ``` +- **Webhook validation rejections (`gateway_validation.go`):** + - `exposeType` is set (`PublicIP` or `LoadBalancer`) while an endpoint has + `underNAT: true` (must be `false`). + - `spec.tunnelConfig.Replicas > 1`. + - `spec.proxyConfig.Replicas` exceeds the count of `type: proxy` endpoints. + +--- + +## 3. VPN PSK Mismatch + +`raven-agent-ds` reads `VPN_CONNECTION_PSK` from `Secret/raven-agent-secret` key +`vpn-connection-psk` in `kube-system`. Do not print raw secret contents; compare +checksums if needed: + +```bash +kubectl --context -n kube-system get secret raven-agent-secret \ + -o jsonpath='{.data.vpn-connection-psk}' | base64 -d | sha256sum +``` + +If rotated or reconfigured via Helm `--set vpn.psk=...`, restart +`daemonset/raven-agent-ds` (requires user confirmation): + +```bash +kubectl --context -n kube-system rollout restart daemonset/raven-agent-ds +``` + +--- + +## 4. Cross-NodePool L3 Traffic Drops + +- **Ports & protocols:** IPsec requires UDP `4500` (and `500` / ESP protocol `50` + depending on encapsulation) open on gateway public IPs; WireGuard uses UDP `4500`. +- **Calico CNI conflict:** On Calico clusters, verify `FelixConfiguration` sets + `iptablesMangleAllowAction: Return`. +- **Additional CIDRs:** If non-pod node or extra CIDR routing is needed, check + `spec` / `raven.openyurt.io/extra-allowed-source-cidrs` on the `Gateway` CR. + +--- + +## 5. L7 Proxy (`enable-l7-proxy`) Not Routing Control-Plane / Service Calls + +The `yurt-manager` Raven controllers manage `kube-system/x-raven-proxy-internal-svc` +and the DNS ConfigMap `kube-system/edge-tunnel-nodes` (`tunnel-nodes` key, used +by `raven-proxy-dns` CoreDNS): + +```bash +kubectl --context -n kube-system get svc -l app.kubernetes.io/managed-by=raven-gateway-internal-service-controller || \ +kubectl --context -n kube-system get svc x-raven-proxy-internal-svc +kubectl --context -n kube-system get endpoints x-raven-proxy-internal-svc +kubectl --context -n kube-system get configmap edge-tunnel-nodes -o yaml +``` + +If `x-raven-proxy-internal-svc` has no endpoints, verify `enable-l7-proxy: "true"` +in `kube-system/raven-cfg` and confirm at least one active endpoint has +`type: proxy`. diff --git a/.claude/skills/raven-topology/SKILL.md b/.claude/skills/raven-topology/SKILL.md new file mode 100644 index 00000000000..74762e818a3 --- /dev/null +++ b/.claude/skills/raven-topology/SKILL.md @@ -0,0 +1,66 @@ +--- +name: raven-topology +description: Diagnose OpenYurt Raven L3 VPN tunnels, L7 proxy endpoints, and Gateway CR election across cloud and edge NodePools. +when_to_use: Use when diagnosing cross-region pod connectivity, Gateway election failures, or Raven L7 proxy routing issues. +disable-model-invocation: true +allowed-tools: Read Grep Bash(kubectl --context * get *) Bash(kubectl --context * describe *) Bash(kubectl --context * logs *) +--- + +# Raven Topology Troubleshooting Skill + +Guides autonomous read-only inspection of OpenYurt Raven control-plane and +data-plane state across NodePools. Ask the user to confirm the target kube +context `` before running commands, and pass `--context ` to every +`kubectl` call. + +## Troubleshooting Steps + +1. **Check Global Raven Configuration (`kube-system/raven-cfg`)** + ```bash + kubectl --context -n kube-system get configmap raven-cfg -o yaml + ``` + Confirm whether `enable-l3-tunnel` and `enable-l7-proxy` are `"true"` as + intended (`pkg/yurtmanager/controller/raven/util/constants.go`). + +2. **Inspect `Gateway` CRs and Elected Active Endpoints** + ```bash + kubectl --context get gateways.raven.openyurt.io -o yaml + kubectl --context get nodes --show-labels | grep raven.openyurt.io/gateway + ``` + Every participating NodePool should have a `Gateway` (`raven.openyurt.io/v1beta1`) + with populated `status.activeEndpoints` (`tunnel` / `proxy`). If `activeEndpoints` + is empty, inspect `yurt-manager` controller logs in `kube-system` (`gatewaypickup` + controller runs inside `yurt-manager`, not a separate controller Deployment): + ```bash + kubectl --context -n kube-system logs -l app.kubernetes.io/name=yurt-manager --tail=100 + ``` + +3. **Verify `raven-agent-ds` Pods and Tunnel Logs** + ```bash + kubectl --context -n kube-system get daemonset raven-agent-ds + kubectl --context -n kube-system get pods -l app=raven-agent -o wide + kubectl --context -n kube-system logs -l app=raven-agent --tail=50 + ``` + Verify pods are `Running`/`Ready` on all cloud and edge gateway nodes and check + logs for IPsec (`libreswan`) or WireGuard establishment errors or PSK issues + (`Secret/raven-agent-secret`). + +4. **Verify L7 Proxy Services and DNS Mapping** + When `enable-l7-proxy: "true"` is enabled, check the internal proxy service, + exposed proxy/tunnel services, and DNS ConfigMap managed by `yurt-manager`: + ```bash + kubectl --context -n kube-system get svc,endpoints x-raven-proxy-internal-svc + kubectl --context -n kube-system get svc -A | grep x-raven- + kubectl --context -n kube-system get configmap edge-tunnel-nodes -o yaml + ``` + +## Common Pitfalls to Avoid + +- Do NOT look for `raven-controller-manager`; Gateway reconciliation controllers + (`gatewaypickup`, `gatewayinternalservice`, `gatewaypublicservice`, + `gatewaydns`) are built into `yurt-manager`. +- Do NOT suggest checking `yurt-tunnel`; Raven replaces `yurt-tunnel` in modern + OpenYurt deployments. +- Do NOT query `raven-agent` pods with `-l app=raven-agent-ds`; the DaemonSet is + named `raven-agent-ds`, while pod labels use `app=raven-agent`. +- Do NOT rely on `kubectl port-forward` to test cross-pool Raven L3/L7 data paths. diff --git a/.claude/skills/yurthub-autonomy/SKILL.md b/.claude/skills/yurthub-autonomy/SKILL.md new file mode 100644 index 00000000000..65827b7d00d --- /dev/null +++ b/.claude/skills/yurthub-autonomy/SKILL.md @@ -0,0 +1,73 @@ +--- +name: yurthub-autonomy +description: Diagnose OpenYurt edge node autonomy annotations, PodBindingController tolerations, and YurtHub offline cache state during cloud-edge disconnections. +when_to_use: Use when diagnosing unexpected pod evictions on disconnected edge nodes, autonomy-duration settings, or YurtHub local cache behavior. +disable-model-invocation: true +allowed-tools: Read Grep Bash(kubectl --context * get *) Bash(kubectl --context * describe *) Bash(kubectl --context * logs *) +--- + +# YurtHub Edge Autonomy Troubleshooting Skill + +Guides autonomous read-only inspection of OpenYurt edge node autonomy settings +and pod eviction behavior during cloud-edge network partitions. Ask the user to +confirm the target kube context `` before running commands, and pass +`--context ` to every `kubectl` call. + +## Source Contracts + +- `pkg/yurtmanager/controller/yurtcoordinator/podbinding/pod_binding_controller.go`: + `resolveNodeAutonomySetting` reads: + - `node.openyurt.io/autonomy-duration` (recommended, Go duration e.g. `"10m"`, + or `"0"` / `"0s"` for infinite autonomy; sets `tolerationSeconds` on pods for + `node.kubernetes.io/not-ready` and `node.kubernetes.io/unreachable`, preserving + original values in `apps.openyurt.io/original-*-toleration-duration`). + - `node.beta.openyurt.io/autonomy: "true"` and `apps.openyurt.io/binding: "true"` + (deprecated legacy annotations; still honored at higher precedence when `"true"`). +- `pkg/yurthub/proxy/autonomy/autonomy.go`: + The `Autonomy` node condition only reflects the deprecated + `node.beta.openyurt.io/autonomy` annotation; do NOT expect `Autonomy=True` + when only `node.openyurt.io/autonomy-duration` is set. +- `pkg/yurthub/storage/disk/storage.go` & `pkg/yurtadm/constants/constants.go`: + YurtHub stores cached objects on disk under `/etc/kubernetes/cache/` and its + working/error-key state under `/var/lib/yurthub`. + +## Troubleshooting Steps + +1. **Verify Edge Status and Autonomy Annotations** + ```bash + kubectl --context get node -o jsonpath='{.metadata.labels.openyurt\.io/is-edge-worker}{"\n"}{.metadata.annotations}{"\n"}' + ``` + Note: `PodBindingController` skips nodes that are not edge nodes. Verify + `node.openyurt.io/autonomy-duration` is a valid Go duration (e.g. `10m` or `0s`). + +2. **Inspect Pod Eviction Tolerations on the Edge Node** + ```bash + kubectl --context get pods -A --field-selector spec.nodeName= \ + -o jsonpath='{range .items[*]}{.metadata.namespace}/{.metadata.name}{" not-ready="}{.spec.tolerations[?(@.key=="node.kubernetes.io/not-ready")].tolerationSeconds}{" unreachable="}{.spec.tolerations[?(@.key=="node.kubernetes.io/unreachable")].tolerationSeconds}{"\n"}{end}' + ``` + If `tolerationSeconds` was not updated or pods are still being evicted, inspect + `yurt-manager` logs for `PodBindingController` duration parsing or webhook + errors (requires PodBinding feature gate / controller enabled in `yurt-manager`): + ```bash + kubectl --context -n kube-system logs -l app.kubernetes.io/name=yurt-manager --tail=100 | grep -i -E "autonomy|podbinding" + ``` + +3. **Check Edge-Node YurtHub Health and Events** + Check `NodeLease` updates, `NodeReady` status transitions, and YurtHub + configuration in `kube-system`: + ```bash + kubectl --context get lease -n kube-node-lease -o yaml + kubectl --context -n kube-system get configmap yurt-hub-cfg -o yaml + ``` + +## Common Pitfalls to Avoid + +- Do NOT look for `yurt-controller-manager`; `PodBindingController` runs inside + `yurt-manager`. +- Do NOT use the legacy `node.beta.alibabacloud.com/autonomy` prefix or advise + tweaking `kube-controller-manager`'s `--pod-eviction-timeout` as the fix. +- Do NOT treat `Autonomy=False` node condition as a failure when using + `node.openyurt.io/autonomy-duration`; verify pod `tolerationSeconds` instead. +- Do NOT interpret `NotReady` alone during a cloud-edge partition as workload + failure; workloads keep running autonomously on the edge node while YurtHub + serves cached API state.