> For the complete documentation index, see [llms.txt](https://tccli-agent.gitbook.io/tccli/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tccli-agent.gitbook.io/tccli/v2/tke-rong-qi-fu-wu/index-2/overview/traffic-access.md).

# 流量接入

> 官方文档：[节点概述](https://cloud.tencent.com/document/product/457/32201) · [注册节点价格和配额说明](https://cloud.tencent.com/document/product/457/79747)
>
> 配额：CLB 配额、LB 带宽限制。[配额说明](https://cloud.tencent.com/document/product/457/9087)
>
> ⚠️ **高危操作**：NodePort 暴露需安全组限制来源 IP；公网 LB 产生带宽费用；非健康后端致流量黑洞。[常见高危操作](https://cloud.tencent.com/document/product/457/39539)

## 流量接入

> 将注册节点的容器通过腾讯云负载均衡 CLB 对外暴露服务（四层 / 七层）。 控制台: [容器服务 - 节点池 - 注册节点](https://console.cloud.tencent.com/tke2/nodepool)

注册节点的容器对外暴露基于腾讯云 CLB，提供四层（Service 类型 LoadBalancer）与七层（Ingress）接入方案。

> 当前仅\*\*注册节点（专线版）\*\*支持接入 CLB；**公网版**暂时不支持 CLB。详见[创建注册节点（公网版）](/tccli/v2/tke-rong-qi-fu-wu/index-2/overview/public-network.md)。

### 触发条件

* 你已通过[专线版](/tccli/v2/tke-rong-qi-fu-wu/index-2/overview/dedicated-line.md)接入注册节点（CLB 仅专线版支持）。
* 你要把注册节点上运行的 Service / Ingress 通过 CLB 暴露到集群外。

### 四层接入（Service LoadBalancer）

为注册节点上的工作负载创建 `LoadBalancer` 类型 Service，集群自动为其创建 CLB 实例并绑定注册节点。

```yaml
apiVersion: v1
kind: Service
metadata:
  name: registered-nodeport-svc
spec:
  type: LoadBalancer
  selector:
    app: registered-workload
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8080
```

将清单保存为 `registered-nodeport-svc.yaml`，再创建并等待 CLB 地址：

> kubectl（K8s 原生命令，非 tccli；TCCLI 不提供 Kubernetes Service 创建能力）

```bash
kubectl apply -f registered-nodeport-svc.yaml
# expected: service/registered-nodeport-svc created（或 configured）

kubectl get svc registered-nodeport-svc --watch
# expected: service 创建成功，EXTERNAL-IP 从 <pending> 变为 CLB VIP；取得 VIP 后结束 watch

kubectl get endpointslice -l kubernetes.io/service-name=registered-nodeport-svc -o wide
# expected: 至少一个就绪端点，且对应注册节点上的 Pod
```

> 注册节点的 Pod 需调度到注册节点池，CLB 后端才会包含对应节点。通过节点池 Labels / 工作负载 `nodeSelector` 约束调度目标。

### 七层接入（Ingress）

通过 Ingress 资源暴露 HTTP/HTTPS 路由，后端指向注册节点上的 Service。Ingress 控制器所用 CLB 同样仅专线版注册节点支持。

```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: registered-ingress
spec:
  rules:
    - host: "registered.example.com"
      http:
        paths:
          - path: /
            pathType: Prefix
            backend:
              service:
                name: registered-nodeport-svc
                port:
                  number: 80
```

将清单保存为 `registered-ingress.yaml`，再创建并等待七层入口就绪：

> kubectl（K8s 原生命令，非 tccli；TCCLI 不提供 Kubernetes Ingress 创建能力）

```bash
kubectl apply -f registered-ingress.yaml
# expected: ingress.networking.k8s.io/registered-ingress created（或 configured）

kubectl get ingress registered-ingress --watch
# expected: ingress 创建成功，ADDRESS 出现入口地址；取得地址后结束 watch

kubectl describe ingress registered-ingress
# expected: Ingress 后端指向 registered-nodeport-svc:80

kubectl get endpointslice -l kubernetes.io/service-name=registered-nodeport-svc -o wide
# expected: Service 至少有一个就绪端点
```

### 准备工作

* 已创建 TKE 标准集群（见[创建集群](/tccli/v2/tke-rong-qi-fu-wu/index-1/create.md)）。
* 已配置 tccli 凭证（见[配置凭证](/tccli/v2/zhun-bei-gong-zuo/credentials.md)）。
* 已通过[专线版](/tccli/v2/tke-rong-qi-fu-wu/index-2/overview/dedicated-line.md)接入注册节点且节点在线（CLB 仅专线版支持，公网版不支持）。
* 已获取集群 kubeconfig 并可执行 `kubectl`（见[集群认证](/tccli/v2/tke-rong-qi-fu-wu/index-4/auth.md)），本文操作步骤通过 `kubectl` 下发 Service / Ingress。
* 已确认流量接入层：四层（Service `LoadBalancer`）转发 TCP，七层（Ingress）转发 HTTP/HTTPS，按后端协议选择。

#### 注册节点在线（TCCLI 前置）

下发 Service / Ingress 前，用 TCCLI 确认注册节点已在线（CLB 后端依赖注册节点 Ready）：

```bash
tccli tke DescribeExternalNode \
  --ClusterId "<CLUSTER_ID>" \
  --region ap-guangzhou \
  --filter "Nodes[?Status=='Running'].{name:Name,ip:IP,status:Status}" \
  --output text
# expected: 至少一行 name/ip/status=Running；空输出 → 先完成专线版接入
```

### 验证

> kubectl（K8s 原生命令，非 tccli；TCCLI 管 TKE 抽象层不提供 K8s 资源操作能力）

```bash
kubectl get svc registered-nodeport-svc -o jsonpath='{.status.loadBalancer.ingress[0].ip}'
# expected: 返回 CLB VIP，外部可访问
```

### 清理

> kubectl（K8s 原生命令，非 tccli；TCCLI 不提供 Kubernetes Service/Ingress 删除能力）

```bash
kubectl delete -f registered-ingress.yaml
# expected: ingress.networking.k8s.io "registered-ingress" deleted

kubectl delete -f registered-nodeport-svc.yaml
# expected: service "registered-nodeport-svc" deleted；确认关联 CLB 已按产品回收流程释放后再结束
```

### 故障恢复

| 现象          | 根因            | 修复                            |
| ----------- | ------------- | ----------------------------- |
| CLB 未绑定注册节点 | Pod 未调度到注册节点池 | 检查 `nodeSelector` 与节点池 Labels |
| 公网版无法使用 CLB | 公网版不支持 CLB    | 改用专线版接入                       |

### 收尾确认

> kubectl（K8s 原生命令，非 tccli；TCCLI 管 TKE 抽象层不提供 K8s 资源操作能力）

```bash
kubectl get svc registered-nodeport-svc -o wide
# expected: EXTERNAL-IP 为 CLB VIP，端点包含注册节点上的 Pod
```

### 下一步

* 专线版接入：[创建注册节点（专线版）](/tccli/v2/tke-rong-qi-fu-wu/index-2/overview/dedicated-line.md)
* 常见问题：[注册节点常见问题](/tccli/v2/tke-rong-qi-fu-wu/index-2/overview/faq.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://tccli-agent.gitbook.io/tccli/v2/tke-rong-qi-fu-wu/index-2/overview/traffic-access.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
