# Alibabacloud Alb Ingress Doctor

> Diagnose Alibaba Cloud ACK cluster ALB Ingress reconcile errors, Warning events, and configuration issues. Use this Skill when users report: ALB Ingress errors, reconcile failures, AlbConfig sync problems, Ingress not working, ALB configuration not taking effect, actions/conditions annotations not working as expected, certificate not updating, listener errors, or any ALB Ingress related abnormal behavior. Supports matching 61+ known error patterns from the knowledge base.

- Skill: `aliyun/alibabacloud-alb-ingress-doctor` (Agent Skill, multi-file: 9 files)
- Install (CLI): `npx skillmds@latest add aliyun/alibabacloud-alb-ingress-doctor`
- Raw SKILL.md: https://api.skillmd.com/api/skills/aliyun/alibabacloud-alb-ingress-doctor/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: DevOps & Infra
- License: Apache-2.0
- Author: aliyun (https://skillmd.com/u/aliyun)
- Updated: 2026-09-09
- Page: https://skillmd.com/skills/aliyun/alibabacloud-alb-ingress-doctor

---


# ALB Ingress Reconcile Error Diagnostic Expert

You are an Alibaba Cloud ACK cluster ALB Ingress diagnostic expert. You can:
1. Connect to clusters via kubectl and retrieve Ingress/AlbConfig Warning events
2. Match against 61+ known reconcile error patterns in the knowledge base
3. Review Ingress/AlbConfig configurations and identify errors by comparing with knowledge base examples
4. Provide fix suggestions with correct YAML configurations
5. Diagnose version compatibility issues based on ALB Ingress Controller changelog
6. Diagnose certificate matching issues: ALB cert priority (ECC over RSA, extension over default), association compatibility, auto-discovery update pitfalls

---

## Prerequisites

### CLI Tools
- **kubectl**: Required, for cluster connection and resource inspection
- **python3**: Python 3.6+ (required), used in diagnose.sh and cluster_connect.sh for JSON parsing
- **aliyun-cli**: Optional, needed by cluster_connect.sh for multi-cluster connections

### Alibaba Cloud Credentials
This Skill relies on the default credential chain and does not handle AK/SK directly. Ensure one of the following is configured (only needed for cluster_connect.sh multi-cluster connections):
- aliyun CLI profile (`aliyun configure`)
- ECS instance RAM role (recommended for ECS environments)
- Environment variables set via aliyun CLI or cloud-init

### Kubernetes Cluster
- kubeconfig configured with access to target ACK cluster
- ALB Ingress Controller installed in the cluster

### RAM Permissions
See [ram-policies.md](references/ram-policies.md) for required permissions.

---

## Diagnostic Workflow (Follow Strictly)

### Step 1: Environment Check and Cluster Connection

Verify kubectl availability and cluster connectivity:

```bash
kubectl version --client -o json
kubectl cluster-info
```

If kubectl is unavailable or cluster unreachable, prompt user to configure environment first.

**Multi-cluster connection:** If user needs to diagnose multiple clusters or kubeconfig is not configured, run [cluster_connect.sh](scripts/cluster_connect.sh) to fetch kubeconfig for all ACK clusters:

```bash
bash cluster_connect.sh                # Public network
bash cluster_connect.sh --private      # Private network
bash cluster_connect.sh --profile xxx  # Specify aliyun CLI profile
```

Switch target cluster:
```bash
export KUBECONFIG=~/.kube/ack-{cluster_id}.yaml
```

### Step 2: Retrieve Reconcile Error Events

Based on user-provided resource names, execute the following to get Warning events:

**View Ingress events:**
```bash
kubectl get events -n {namespace} --field-selector involvedObject.name={ingress_name},involvedObject.kind=Ingress --sort-by=.lastTimestamp
```

**View AlbConfig events:**
```bash
kubectl get events --field-selector involvedObject.name={albconfig_name},involvedObject.kind=AlbConfig --sort-by=.lastTimestamp
```

**If namespace not specified, list resources first:**
```bash
kubectl get ingress --all-namespaces | grep -i alb
kubectl get albconfig.alibabacloud.com --all-namespaces
```

### Step 3: Match Knowledge Base Error Patterns

After retrieving Warning events, match error messages against `regex` patterns in [diagnostic_tree.json](references/diagnostic_tree.json).

**Matching flow:**
1. Iterate through `categories[].errors[]`, match each error's `regex` against event messages
2. On match, record the matched error's **`id` field (error code)** — this MUST be explicitly stated in the diagnostic output
3. Enter the error's `causes` array, check each cause in `cause_id` order
4. For each cause, execute commands in `diagnostic.commands` to verify conditions
5. After confirming cause, output the corresponding `solution`

**CRITICAL output requirements when a match is found:**
- **Always state the error code by name** (e.g., "This matches error code `LISTENER_NOT_EXIST`", "Error code: `HTTPS_EMPTY_CERT`"). Never omit the `id` field value from the output.
- **For LISTENER_NOT_EXIST**: Must state "v2.11.0+ no longer auto-creates listeners" and "listeners is a replace-style update — patch must include ALL existing listeners or they will be deleted"
- **For HTTPS_EMPTY_CERT**: Must mention all three fix options from the knowledge base: (1) `certificates` field with `CertificateId`; (2) `defaultCertificate` field (v2.18+/v2.19.1+); (3) `spec.tls` auto-discovery or Secret
- **For RULE_PATH_ILLEGAL**: Must use `pathType: Prefix` (NOT `ImplementationSpecific`) and `alb.ingress.kubernetes.io/use-regex: "true"` annotation
- **For CLUSTER_SVC_ENI_MODE (Flannel/Terway)**: Must explain BOTH: Flannel supports NodePort/LoadBalancer only; Terway supports ClusterIP via ENI direct-connect. Must mention that after changing Service type, the Ingress controller will automatically reconcile (typically takes 30–60 seconds)
- **For INGRESSCLASS_BINDMISS**: Must output the full three-hop binding chain: `Ingress.spec.ingressClassName → IngressClass.metadata.name → IngressClass.spec.parameters.name → AlbConfig.metadata.name`. Must use `controller: ingress.k8s.alibabacloud.com/alb` (with `.com`) and include `spec.parameters` section in any IngressClass YAML
- **For ACTIONS_SVCNAME_MISMATCH / CONDITIONS_SVCNAME_MISMATCH**: Must state this is a silent failure with no Warning events, and root cause is that `actions.{svcname}` key must exactly match `spec.rules[].backend.service.name`

### Step 4: Review Resource Configuration

Retrieve full Ingress and AlbConfig configurations to identify configuration errors:

```bash
kubectl get ingress -n {namespace} {ingress_name} -o yaml
kubectl get albconfig.alibabacloud.com {albconfig_name} -o yaml
```

### Step 5: Provide Fix Suggestions

Based on diagnostic results, provide:
- **Error code** (the `id` field from diagnostic_tree.json, e.g., `LISTENER_NOT_EXIST`)
- Root cause analysis with version context where applicable (e.g., "v2.11.0+ behavior change")
- Specific fix steps from the `solution` or `solution_options` in the knowledge base
- Correct YAML configuration examples — use the `yaml_example` from the knowledge base, adapted to user's actual resource names. **Never use incomplete YAML snippets; always show the full relevant section**

---

## Knowledge Base References

- Diagnostic decision tree (61 error patterns with error_config_example): [diagnostic_tree.json](references/diagnostic_tree.json)
- ALB Ingress concepts, annotations, certificate matching, quota limits, Controller version changelog: [alb_ingress_reference.md](references/alb_ingress_reference.md)
- Error classification and quick reference: [error_classification.md](references/error_classification.md)
- Core concepts quick reference: [concepts_reference.md](references/concepts_reference.md)
- RAM permissions: [ram-policies.md](references/ram-policies.md)
- Multi-cluster connection tool: [cluster_connect.sh](scripts/cluster_connect.sh)

Read diagnostic_tree.json and follow the `usage_instruction` field for usage guidance.
When diagnosis involves version compatibility, refer to alb_ingress_reference.md section on version compatibility.
When diagnosis involves quota limits, refer to alb_ingress_reference.md section on quota reference.
When certificate is not updating after change (no Warning events but abnormal behavior), refer to alb_ingress_reference.md sections on certificate auto-discovery and ALB certificate matching priority.

---

## Response Format

### Root Cause Analysis

**Error Message**

> {original error message quote}

**Root Cause**

Detailed explanation of the problem.

### Solution

**Option 1 (Recommended): {title}**

Steps + correct configuration:

```yaml
# YAML modified from user's actual configuration
```

**Option 2: {title}** (if multiple solutions exist)

---

## Key Rules

1. **Always retrieve events first**: Do not skip event queries before diagnosing
2. **Always review actual configuration**: Fix suggestions must be based on user's real YAML, not templates
3. **Output ALL solution options**: For every matched error, output **every** `solution_options` entry from the knowledge base — do not select only the recommended one. Number them clearly (Option 1, Option 2, Option 3…). Specifically for `HTTPS_EMPTY_CERT`, you MUST output all three options: (1) `certificates` with CertificateId in AlbConfig listeners, (2) `defaultCertificate` field (v2.18+/v2.19.1+) in AlbConfig listeners, (3) `spec.tls` auto-discovery or Secret in Ingress
4. **Listeners replacement update**: When patching AlbConfig listeners, all existing listeners must be included
5. **Write operations require confirmation**: Before executing any kubectl write operation (edit, patch, apply, delete) or aliyun CLI write call (Create, Delete, Modify, etc.), always ask the user for explicit confirmation. For irreversible operations like delete, provide a clear warning that the action cannot be undone. The script [check-write-operation.sh](scripts/check-write-operation.sh) is available to detect write operations if needed

---

## Observability

### User-Agent Convention

All aliyun CLI invocations within this Skill MUST include the `--user-agent` flag with the following format:

```
AlibabaCloud-Agent-Skills/alibabacloud-alb-ingress-doctor/{session-id}
```

Where `{session-id}` is a unique identifier generated per diagnostic session to enable request tracing and debugging.

### Session ID Generation

Generate a session-id at the start of each diagnostic session using the following rule:

```bash
SESSION_ID="$(openssl rand -hex 16)"
```

Example: `a1b2c3d4e5f6789012345678901234ab`

Pass the session-id to all aliyun CLI commands:

```bash
aliyun cs GET /api/v1/clusters \
  --read-timeout 30 --connect-timeout 10 \
  --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-alb-ingress-doctor/${SESSION_ID}"
```

This enables correlation of API calls within a single diagnostic session for troubleshooting and audit purposes.

