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

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

经典基础架构 Virtual Private Cloud

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

  • 请注意,此功能仅对同一集群上的工作程序节点之间的流量进行加密,而不对同一工作程序节点上的不同 pod 之间的流量进行加密。
  • 在具有运行 Ubuntu 20 或更高版本 的工作程序的 Kubernetes Service 集群上,支持使用 WireGuard 进行工作程序到工作程序加密。
  • 在具有用户安装的加密模块的工作程序上不支持 WireGuard。
  • WireGuard 不符合 FIPS 或 FedRamp。
  • 在启用 WireGuard 配置后,无法对其进行变更。 但是,您可以将其禁用。

有关此配置设置的更多信息,请参阅 Calico 文档中的 Enable WireGuard for a cluster

启用 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