Skip to content

Implement Private Networking #83

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

Merged
merged 29 commits into from
Mar 8, 2023

Conversation

RobotSail
Copy link
Collaborator

@RobotSail RobotSail commented Oct 18, 2022

Fixes MAN-11
This PR implements private networking through the following mechanisms:

  • A new field is added: .spec.networking.networkMode which can be in one of two modes: public or private.
  • If a field of private is set, the IPFS operator generates a swarm key and sets it as the IPFS_SWARM_KEY environment variable for each of the IPFS containers, including configure-ipfs.
  • A list of bootstrap nodes are created which embed the first node's peer ID by creating a p2p circuit via the created circuit relays
  • The configure IPFS script embeds the list of bootstrap nodes in the IPFS config and all nodes are peered to the first (including the first).

@RobotSail RobotSail changed the title Sanity Check Implement Private Networking Oct 24, 2022
}

// IpfsClusterSpec defines the desired state of the IpfsCluster.
type IpfsClusterSpec struct {
// url defines the URL to be using as an ingress controller.
// +kubebuilder:validation:Optional
URL string `json:"url"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

URL is deleted from spec because I did not see it used anywhere in the operator and I don't want to confuse users. Feel free to let me know if this needs to stay

// networkMode is a switch which defines whether this IPFSCluster will use
// the global IPFS network or create its own.
// +kubebuilder:validation:Enum={public,private}
NetworkMode NetworkMode `json:"networkMode,omitempty"`
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe this could just be the Public boolean flag from the spec instead of an enum

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

Copy link
Collaborator

@hsanjuan hsanjuan left a comment

Choose a reason for hiding this comment

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

I had a very quick look

Comment on lines +242 to +190
for _, circuitAddr := range peer.Addrs {
bootstrapAddr := fmt.Sprintf("%s/p2p/%s/p2p-circuit/p2p/%s", circuitAddr.String(), circuitID.String(), initPeerID)
bootstrapPeers = append(bootstrapPeers, bootstrapAddr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems off... peers in a private network would not need to use relays to contact each other as they can dial each other directly over their LAN IPs...

There's also a question of what are relays for in private networks. The relays cannot communicate to ipfs nodes at all if those nodes are configured with a PNET key. The relays would need support for private networks too.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Added PSK support within the relay daemon within the release of go-libp2p-relay-daemon v0.4.0.

Signed-off-by: Oleg S <[email protected]>
@RobotSail RobotSail requested a review from hsanjuan February 8, 2023 15:44
@RobotSail
Copy link
Collaborator Author

@hsanjuan I've updated the PR with the new PSK support merged in go-libp2p-relay-daemon release v0.4.0. Could you please take a quick look again when you have a minute and let me know if there's anything I should change?

@cooktheryan
Copy link
Collaborator

No major concerns from my end. A question and a single nit but great job cleaning up some hardcoded values that may have caused us pain down the line

Signed-off-by: Oleg S <[email protected]>
@cooktheryan
Copy link
Collaborator

/LGTM

@cooktheryan cooktheryan self-requested a review February 15, 2023 21:17
@RobotSail RobotSail merged commit a3c6dbb into ipfs-cluster:main Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants