使用 WireGuard 对工作程序到工作程序的流量进行加密

传统基础设施 虚拟私有云

您可以使用 WireGuard 对群集中工作者节点之间流动的数据进行加密。

  • 该功能只对同一群集中的工作节点之间的流量进行加密。 它不会加密同一工作节点上不同 pod 之间的流量。
  • 在具有运行 Ubuntu 20 或更高版本 的工作程序的 Kubernetes Service 集群上,支持使用 WireGuard 进行工作程序到工作程序加密。
  • WireGuard 不支持已安装用户加密模块的工作站。
  • WireGuard 不符合 FIPS 或 FedRAMP 标准。
  • 启用 WireGuard 配置后就不能再更改了。 但是,您可以将其禁用。

有关此配置设置的更多信息,请参阅 Calico 文档中的 为群集启用 WireGuard

启用 WireGuard 加密

  1. 运行以下命令以对工作程序到工作程序的流量启用 WireGuard。

    kubectl patch felixconfiguration default --type='merge' -p '{"spec":{"wireguardEnabled":true}}'
    

    示例输出

    felixconfiguration.crd.projectcalico.org/default patched
    
  2. 通过查看 felixconfiguration 来验证设置。 在输出中,找到 WireGuard 部分并验证 wireguardEnabled: true

    kubectl get felixconfiguration default -o yaml
    

    示例输出

    apiVersion: crd.projectcalico.org/v1
    kind: FelixConfiguration
    metadata:
      annotations:
        created-by: IBMCloudKubernetesService
        projectcalico.org/metadata: '{"uid":"8a21b69b-9ffb-451d-9619-0dd1605810dc","creationTimestamp":"2023-09-13T14:00:15Z"}'
      creationTimestamp: "2023-09-13T14:00:15Z"
      generation: 2
      name: default
      resourceVersion: "24839234"
      uid: ff0c79f3-5548-4db4-a22f-2f367282631d
    spec:
      bpfLogLevel: ""
      floatingIPs: Disabled
      logSeverityScreen: Info
      natPortRange: 32768:65535
      reportingInterval: 0s
      wireguardEnabled: true
    

禁用 WireGuard 加密

如果集群中不再需要工作程序到工作程序加密,那么可以禁用 WireGuard。

  1. 运行以下命令禁用 WireGuard。

    kubectl patch felixconfiguration default --type='merge' -p '{"spec":{"wireguardEnabled":false}}'
    

    示例输出

    felixconfiguration.crd.projectcalico.org/default patched
    
  2. 验证 WireGuard 是否已禁用。

    kubectl get felixconfiguration default -o yaml
    

    示例输出

    apiVersion: crd.projectcalico.org/v1
    kind: FelixConfiguration
    metadata:
      annotations:
        created-by: IBMCloudKubernetesService
        projectcalico.org/metadata: '{"uid":"8a21b69b-9ffb-451d-9619-0dd1605810dc","creationTimestamp":"2023-09-13T14:00:15Z"}'
      creationTimestamp: "2023-09-13T14:00:15Z"
      generation: 3
      name: default
      resourceVersion: "24839453"
      uid: ff0c79f3-5548-4db4-a22f-2f367282631d
    spec:
      bpfLogLevel: ""
      floatingIPs: Disabled
      logSeverityScreen: Info
      natPortRange: 32768:65535
      reportingInterval: 0s
      wireguardEnabled: false