主题
为安装创建 Ingress(Kubernetes)
默认情况下,LangSmith 会为 langsmith-frontend 配置一个 LoadBalancer 服务。根据你的云提供程序,这可能会为该服务分配一个公共 IP 地址。如果你希望使用自定义域名,或更精细地控制到 LangSmith 安装的流量路由,可以配置 Ingress、Gateway API 或 Istio Gateway。
要求
- 一个现有的 Kubernetes 集群
- 在你的 Kubernetes 集群中安装以下之一:
- Ingress Controller(用于标准 Ingress)
- Gateway API CRD 和 Gateway 资源(用于 Gateway API)
- Istio(用于 Istio Gateway)
参数
你可能需要向 LangSmith 安装提供某些参数以配置 Ingress。此外,我们还需要将 langsmith-frontend 服务转换为 ClusterIP 服务。
主机名(可选):你希望用于 LangSmith 安装的主机名。例如
"langsmith.example.com"。如果留空,Ingress 会将所有流量提供给 LangSmith 安装。BasePath(可选):如果你希望在 URL basePath 下提供 LangSmith,可以在此指定。例如,添加
"langsmith"将在"example.hostname.com/langsmith"提供应用程序。这适用于 UI 路径以及 API 端点。IngressClassName(可选):你希望使用的 Ingress 类名称。如果未设置,将使用默认 Ingress 类。
Annotations(可选):要添加到 Ingress 的其他注解。某些提供程序(如 AWS)可能会使用注解来控制 TLS 终止等事项。
例如,你可以使用 AWS ALB Ingress Controller 添加以下注解,将 ACM 证书附加到 Ingress:
yamlannotations: alb.ingress.kubernetes.io/certificate-arn: "<your-certificate-arn>"Labels(可选):要添加到 Ingress 的其他标签。
TLS(可选):如果你希望通过 HTTPS 提供 LangSmith,可以在此添加 TLS 配置(许多 Ingress Controller 可能还有其他控制 TLS 的方式,因此通常不需要)。这应该是一个 TLS 配置数组。每个 TLS 配置应包含以下字段:
hosts:证书应有效的主机数组。例如 ["langsmith.example.com"]
secretName:包含证书和私钥的 Kubernetes secret 名称。此 secret 应包含以下键:
- tls.crt:证书
- tls.key:私钥
有关更多信息,请参阅创建 TLS secret。
配置
你可以将 LangSmith 实例配置为使用三种路由选项之一:标准 Ingress、Gateway API 或 Istio Gateway。请选择最适合你基础设施的选项。
选项 1:标准 Ingress
准备好这些参数后,你可以将 LangSmith 实例配置为使用 Ingress。为此,请修改 LangSmith Helm Chart 安装的 config.yaml 文件。
yaml
config:
hostname: "" # Main domain for LangSmith
basePath: "" # If you want to serve langsmith under a URL base path (e.g., /langsmith)
ingress:
enabled: true
hostname: "" # Deprecated: Use config.hostname instead after v0.12.0
subdomain: "" # Deprecated: Use config.hostname instead after v0.12.0
ingressClassName: "" # If not set, the default ingress class will be used
annotations: {} # Add annotations here if needed
labels: {} # Add labels here if needed
tls: [] # Add TLS configuration here if needed
frontend:
service:
type: ClusterIP配置完成后,你需要更新 LangSmith 安装。如果一切配置正确,你的 LangSmith 实例现在应该可以通过 Ingress 访问。你可以运行以下命令检查 Ingress 状态:
bash
kubectl get ingress你应该会在输出中看到类似以下内容:
NAME CLASS HOSTS ADDRESS PORTS AGE
langsmith-ingress nginx <host> 35.227.243.203 80, 443 95dWARNING
如果你没有自动 DNS 设置,需要手动将 IP 地址添加到 DNS 提供程序。
选项 2:Gateway API
NOTE
Gateway API 支持从 LangSmith v0.12.0 开始可用
如果你的集群使用 Kubernetes Gateway API,你可以将 LangSmith 配置为配置 HTTPRoute 资源。这将为 LangSmith 创建一个 HTTPRoute,并为每个 agent 部署创建一个 HTTPRoute。
参数
- name(必填):要引用的 Gateway 资源名称
- namespace(必填):Gateway 资源所在的命名空间
- hostname(可选):你希望用于 LangSmith 安装的主机名。例如
"langsmith.example.com" - basePath(可选):如果你希望在 base path 下提供 LangSmith,可以在此指定。例如 "example.com/langsmith"
- sectionName(可选):要使用的 Gateway 中特定监听器部分的名称
- annotations(可选):要添加到 HTTPRoute 资源的其他注解
- labels(可选):要添加到 HTTPRoute 资源的其他标签
配置
yaml
config:
hostname: "" # Main domain for LangSmith
basePath: "" # If you want to serve langsmith under a base path. E.g "example.com/langsmith"
gateway:
enabled: true
name: "my-gateway" # Name of your Gateway resource
namespace: "gateway-system" # Namespace of your Gateway resource
sectionName: "" # Optional: specific listener section name
annotations: {} # Add annotations here if needed
labels: {} # Add labels here if needed
frontend:
service:
type: ClusterIP配置完成后,你可以检查 HTTPRoute 的状态:
bash
kubectl get httproute选项 3:Istio Gateway
NOTE
Istio Gateway 支持从 LangSmith v0.12.0 开始可用
如果你的集群使用 Istio,你可以将 LangSmith 配置为配置 VirtualService 资源。这将为 LangSmith 创建一个 VirtualService,并为每个 agent 部署创建一个 VirtualService。
参数
- name(可选):要引用的 Istio Gateway 资源名称。默认为
"istio-gateway" - namespace(可选):Istio Gateway 资源所在的命名空间。默认为
"istio-system" - hostname(可选):你希望用于 LangSmith 安装的主机名。例如
"langsmith.example.com" - basePath(可选):如果你希望在 base path 下提供 LangSmith,可以在此指定。例如 "example.com/langsmith"
- annotations(可选):要添加到 VirtualService 资源的其他注解
- labels(可选):要添加到 VirtualService 资源的其他标签
配置
yaml
config:
hostname: "" # Main domain for LangSmith
basePath: "" # If you want to serve langsmith on a separate basePath. E.g "example.com/langsmith"
istioGateway:
enabled: true
name: "istio-gateway" # Name of your Istio Gateway resource
namespace: "istio-system" # Namespace of your Istio Gateway resource
annotations: {} # Add annotations here if needed
labels: {} # Add labels here if needed
frontend:
service:
type: ClusterIP配置完成后,你可以检查 VirtualService 的状态:
bash
kubectl get virtualservice