以编程方式使用文档

默认情况下,LangSmith 会配置一个 LoadBalancer 服务用于 langsmith-frontend。根据您的云服务商,这可能会为服务分配一个公网 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 服务。

  • * *Hostname(可选)*:您希望用于 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 添加以下注解来为 Ingress 附加 ACM 证书:

  annotations:
    alb.ingress.kubernetes.io/certificate-arn: "<your-certificate-arn>"
  
  • * *Labels(可选)*:要添加到 Ingress 的其他标签。
  • * *TLS(可选)*:如果您想通过 HTTPS 提供 LangSmith,可以在此处添加 TLS 配置(许多 Ingress 控制器可能有其他控制 TLS 的方式,因此通常不需要此配置)。这应该是 TLS 配置的数组。每个 TLS 配置应包含以下字段:
  • * hosts: An array of hosts that the certificate should be valid for. E.g \["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 文件来做到这一点。

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 的状态:

kubectl get ingress

您应该在输出中看到类似的内容:

NAME                         CLASS   HOSTS    ADDRESS          PORTS     AGE
langsmith-ingress            nginx   <host>   35.227.243.203   80, 443   95d

选项 2:Gateway API

如果您的集群使用 Kubernetes Gateway API,您可以配置 LangSmith 来配置 HTTPRoute 资源。这将为 LangSmith 创建一个 HTTPRoute,并为每个 代理部署.

参数

  • * *name(必填)*:要引用的 Gateway 资源的名称
  • * *namespace(必填)*:Gateway 资源所在的命名空间
  • * *hostname(可选)*:您希望用于 LangSmith 安装的主机名。例如 "langsmith.example.com"
  • * *basePath(可选)*: If you would like to serve LangSmith under a base path, you can specify it here. E.g "example.com/langsmith"
  • * *sectionName(可选)*:Gateway 中要使用的特定监听器部分的名称
  • * *annotations(可选)*:要添加到 HTTPRoute 资源的其他注解
  • * *labels(可选)*:要添加到 HTTPRoute 资源的其他标签

配置

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

配置完成后,您可以检查 HTTPRoutes 的状态:

kubectl get httproute

选项 3:Istio Gateway

如果您的集群使用 Istio,您可以配置 LangSmith 来配置 VirtualService 资源。这将为 LangSmith 创建一个 VirtualService,并为每个 代理部署.

参数

  • * *name(可选)*:要引用的 Istio Gateway 资源的名称。默认为 "istio-gateway"
  • * *namespace(可选)*:Istio Gateway 资源所在的命名空间。默认为 "istio-system"
  • * *hostname(可选)*:您希望用于 LangSmith 安装的主机名。例如 "langsmith.example.com"
  • * *basePath(可选)*: If you would like to serve LangSmith under a base path, you can specify it here. E.g "example.com/langsmith"
  • * *annotations(可选)*:要添加到 VirtualService 资源的其他注解
  • * *labels(可选)*:要添加到 VirtualService 资源的其他标签

配置

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

配置完成后,您可以检查 VirtualServices 的状态:

kubectl get virtualservice