Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WireGuard support for Calico CNI #10037

Merged
merged 5 commits into from
Oct 11, 2020
Merged

Conversation

h3poteto
Copy link
Contributor

@h3poteto h3poteto commented Oct 10, 2020

Refs: #9753

I add new option to enable WireGuard on Calico.

Sample Configuration

  networking:
    calico:
      wireguardEnabled: true

Result of this configuration

$ calicoctl get node -o yaml
apiVersion: projectcalico.org/v3
items:
- apiVersion: projectcalico.org/v3
  kind: Node
  metadata:
    annotations:
      projectcalico.org/kube-labels: '{"beta.kubernetes.io/arch":"amd64","beta.kubernetes.io/instance-type":"t2.medium","beta.kubernetes.io/os":"linux","failure-domain.beta.kubernetes.io/region":"ap-northeast-1","failure-domain.beta.kubernetes.io/zone":"ap-northeast-1a","kops.k8s.io/instancegroup":"master-ap-northeast-1a","kops.k8s.io/kops-controller-pki":"","kubernetes.io/arch":"amd64","kubernetes.io/hostname":"ip-172-16-1-104.ap-northeast-1.compute.internal","kubernetes.io/os":"linux","kubernetes.io/role":"master","node-role.kubernetes.io/master":"","node.kubernetes.io/instance-type":"t2.medium","topology.kubernetes.io/region":"ap-northeast-1","topology.kubernetes.io/zone":"ap-northeast-1a"}'
    creationTimestamp: "2020-10-10T04:51:21Z"
    labels:
      beta.kubernetes.io/arch: amd64
      beta.kubernetes.io/instance-type: t2.medium
      beta.kubernetes.io/os: linux
      failure-domain.beta.kubernetes.io/region: ap-northeast-1
      failure-domain.beta.kubernetes.io/zone: ap-northeast-1a
      kops.k8s.io/instancegroup: master-ap-northeast-1a
      kops.k8s.io/kops-controller-pki: ""
      kubernetes.io/arch: amd64
      kubernetes.io/hostname: ip-172-16-1-104.ap-northeast-1.compute.internal
      kubernetes.io/os: linux
      kubernetes.io/role: master
      node-role.kubernetes.io/master: ""
      node.kubernetes.io/instance-type: t2.medium
      topology.kubernetes.io/region: ap-northeast-1
      topology.kubernetes.io/zone: ap-northeast-1a
    name: ip-172-16-1-104.ap-northeast-1.compute.internal
    resourceVersion: "26468"
    uid: 93998838-f69d-4e3c-8be0-7ac7cba5f22f
  spec:
    bgp:
      ipv4Address: 172.16.1.104/20
      ipv4IPIPTunnelAddr: 100.118.28.192
    orchRefs:
    - nodeName: ip-172-16-1-104.ap-northeast-1.compute.internal
      orchestrator: k8s
    wireguard:
      interfaceIPv4Address: 100.118.28.194
  status:
    podCIDRs:
    - ""
    - 100.96.0.0/24
    wireguardPublicKey: BBa9VazbVUCB1VeHHABK9iznixnnvsJrlPAMO9Gc5y0=
- apiVersion: projectcalico.org/v3
  kind: Node
  metadata:
    annotations:
      projectcalico.org/kube-labels: '{"beta.kubernetes.io/arch":"amd64","beta.kubernetes.io/instance-type":"t2.medium","beta.kubernetes.io/os":"linux","failure-domain.beta.kubernetes.io/region":"ap-northeast-1","failure-domain.beta.kubernetes.io/zone":"ap-northeast-1a","kops.k8s.io/instancegroup":"nodes-ap-northeast-1a","kubernetes.io/arch":"amd64","kubernetes.io/hostname":"ip-172-16-10-49.ap-northeast-1.compute.internal","kubernetes.io/os":"linux","kubernetes.io/role":"node","node-role.kubernetes.io/node":"","node.kubernetes.io/instance-type":"t2.medium","topology.kubernetes.io/region":"ap-northeast-1","topology.kubernetes.io/zone":"ap-northeast-1a"}'
    creationTimestamp: "2020-10-10T04:56:12Z"
    labels:
      beta.kubernetes.io/arch: amd64
      beta.kubernetes.io/instance-type: t2.medium
      beta.kubernetes.io/os: linux
      failure-domain.beta.kubernetes.io/region: ap-northeast-1
      failure-domain.beta.kubernetes.io/zone: ap-northeast-1a
      kops.k8s.io/instancegroup: nodes-ap-northeast-1a
      kubernetes.io/arch: amd64
      kubernetes.io/hostname: ip-172-16-10-49.ap-northeast-1.compute.internal
      kubernetes.io/os: linux
      kubernetes.io/role: node
      node-role.kubernetes.io/node: ""
      node.kubernetes.io/instance-type: t2.medium
      topology.kubernetes.io/region: ap-northeast-1
      topology.kubernetes.io/zone: ap-northeast-1a
    name: ip-172-16-10-49.ap-northeast-1.compute.internal
    resourceVersion: "26464"
    uid: 1cf3c2d9-288b-40bf-8718-0e60b5ccdd04
  spec:
    bgp:
      ipv4Address: 172.16.10.49/20
      ipv4IPIPTunnelAddr: 100.126.81.0
    orchRefs:
    - nodeName: ip-172-16-10-49.ap-northeast-1.compute.internal
      orchestrator: k8s
    wireguard:
      interfaceIPv4Address: 100.126.81.4
  status:
    podCIDRs:
    - ""
    - 100.96.1.0/24
    wireguardPublicKey: OBV1rEMKdG3rsUoj25dLUbGi5EpPj9C6Z627Eyc2pxQ=
kind: NodeList
metadata: {}

Each node contain a field with a WireGuard public key, so it is succeeded.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 10, 2020
@k8s-ci-robot
Copy link
Contributor

Welcome @h3poteto!

It looks like this is your first PR to kubernetes/kops 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/kops has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @h3poteto. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Oct 10, 2020
@k8s-ci-robot k8s-ci-robot added area/addons size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/api area/nodeup labels Oct 10, 2020
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 10, 2020
Copy link
Member

@hakman hakman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this @h3poteto. Looking forward to see how this works in production.
Besides the suggestions, please also do the following:

  1. add a mention in docs about this
  2. rebase and bump the manifest version to 3.16.3-kops.2 in:
    "k8s-1.16": "3.16.3-kops.1",

nodeup/pkg/model/networking/calico.go Outdated Show resolved Hide resolved
pkg/apis/kops/validation/validation.go Outdated Show resolved Hide resolved
pkg/apis/kops/validation/validation_test.go Outdated Show resolved Hide resolved
pkg/apis/kops/networking.go Outdated Show resolved Hide resolved
pkg/apis/kops/v1alpha2/networking.go Outdated Show resolved Hide resolved
@hakman
Copy link
Member

hakman commented Oct 11, 2020

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Oct 11, 2020
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Oct 11, 2020
@hakman hakman changed the title Enable WireGuard on Calico CNI Add WireGuard support for Calico CNI Oct 11, 2020
@hakman
Copy link
Member

hakman commented Oct 11, 2020

Looks great @h3poteto!
By any chance did you check what happens when WireGuard is not installed on the nodes but the option is active, of there's a mix of nodes with and without WireGuard installed?

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 11, 2020
@hakman hakman added hacktoberfest-accepted Accepted contribution for Hacktoberfest and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Oct 11, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: h3poteto, hakman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/documentation and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Oct 11, 2020
@hakman
Copy link
Member

hakman commented Oct 11, 2020

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 11, 2020
@h3poteto
Copy link
Contributor Author

h3poteto commented Oct 11, 2020

By any chance did you check what happens when WireGuard is not installed on the nodes but the option is active, of there's a mix of nodes with and without WireGuard installed?

No, I will check it, so please wait a moment.

Copy link
Member

@hakman hakman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few nits in the doc.

docs/networking/calico.md Show resolved Hide resolved
docs/networking/calico.md Outdated Show resolved Hide resolved
@hakman
Copy link
Member

hakman commented Oct 11, 2020

@h3poteto Could you add the docs changes I proposed. I would like to merge this and release a new 1.19 alpha after that.
We can discuss separately what happens when there's a mix of nodes with and without WireGuard installed.

@h3poteto
Copy link
Contributor Author

@hakman I'm sorry to late. I merged it.

@hakman
Copy link
Member

hakman commented Oct 11, 2020

Thanks @h3poteto!
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 11, 2020
@hakman
Copy link
Member

hakman commented Oct 11, 2020

/retest

@hakman
Copy link
Member

hakman commented Oct 11, 2020

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 11, 2020
@k8s-ci-robot k8s-ci-robot merged commit 6f85cd9 into kubernetes:master Oct 11, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.19 milestone Oct 11, 2020
@h3poteto h3poteto deleted the iss-9753 branch October 11, 2020 13:12
k8s-ci-robot added a commit that referenced this pull request Oct 12, 2020
…-upstream-release-1.18

Automated cherry pick of #10037: Add WireGuard support for Calico CNI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/addons area/api area/documentation area/nodeup cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. hacktoberfest-accepted Accepted contribution for Hacktoberfest lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants