From 4345ab1ea5278d8da9b2f3af394ac775a92b34b2 Mon Sep 17 00:00:00 2001 From: alecsavvy <16739903+alecsavvy@users.noreply.github.com> Date: Wed, 14 Aug 2024 06:39:55 -0600 Subject: [PATCH] expose core ports (#117) * expose core ports * fix devnet test --- configs/templates/devnet.yaml | 4 ++++ pkg/conf/model.go | 15 ++++++++++----- pkg/orchestration/docker.go | 19 +++++++++++++++---- 3 files changed, 29 insertions(+), 9 deletions(-) diff --git a/configs/templates/devnet.yaml b/configs/templates/devnet.yaml index 17e3721..cb7c000 100644 --- a/configs/templates/devnet.yaml +++ b/configs/templates/devnet.yaml @@ -6,6 +6,8 @@ nodes: httpPort: 7000 httpsPort: 7001 version: prerelease + corePortP2P: 46656 + corePortRPC: 46657 creator-1.devnet.audius-d: type: content httpPort: 4000 @@ -14,6 +16,8 @@ nodes: privateKey: 21118f9a6de181061a2abd549511105adb4877cf9026f271092e6813b7cf58ab wallet: 0x0D38e653eC28bdea5A2296fD5940aaB2D0B8875c rewardsWallet: 0xb3c66e682Bf9a85F6800c769AC5A05c18C3F331d + corePortP2P: 36656 + corePortRPC: 36657 discovery-1.devnet.audius-d: type: discovery httpPort: 5000 diff --git a/pkg/conf/model.go b/pkg/conf/model.go index 3706302..805e1be 100644 --- a/pkg/conf/model.go +++ b/pkg/conf/model.go @@ -44,6 +44,10 @@ type NodeConfig struct { HttpPort uint `yaml:"httpPort,omitempty"` HttpsPort uint `yaml:"httpsPort,omitempty"` + // Specify non-standard ports for core traffic + CorePortP2P uint `yaml:"corePortP2P,omitempty"` + CorePortRPC uint `yaml:"corePortRPC,omitempty"` + // A string of additional port bindings to allow exposing docker-in-docker containers to the host // e.g. "5433:5432,9201:9200" would expose the postgres and elastic search dind containers // on the host ports 5433 and 9201 respectively @@ -91,10 +95,12 @@ type StorageConfig struct { func NewNodeConfig(nodeType NodeType) NodeConfig { return NodeConfig{ - Type: nodeType, - HttpPort: 80, - HttpsPort: 443, - Version: "current", + Type: nodeType, + HttpPort: 80, + HttpsPort: 443, + CorePortP2P: 26656, + CorePortRPC: 26657, + Version: "current", } } @@ -134,7 +140,6 @@ type Infra struct { AWSRegion string `yaml:"awsRegion,omitempty"` } - // name of the plugin that should match with it's docker profile // this will be used with the REGISTER_PLUGINS env var type PluginName = string diff --git a/pkg/orchestration/docker.go b/pkg/orchestration/docker.go index e27c30b..6bf09a5 100644 --- a/pkg/orchestration/docker.go +++ b/pkg/orchestration/docker.go @@ -27,20 +27,20 @@ import ( var ( internalVolumes = map[conf.NodeType][]string{ - conf.Content: []string{ + conf.Content: { "/var/k8s/mediorum", "/var/k8s/creator-node-backend", "/var/k8s/creator-node-db-15", "/var/k8s/bolt", "/var/k8s/audius-core", }, - conf.Discovery: []string{ + conf.Discovery: { "/var/k8s/discovery-provider-db", "/var/k8s/discovery-provider-chain", "/var/k8s/bolt", "/var/k8s/core", }, - conf.Identity: []string{ + conf.Identity: { "/var/k8s/identity-service-db", }, } @@ -83,7 +83,7 @@ func runNode( hostConfig := &container.HostConfig{ Privileged: true, Mounts: []mount.Mount{ - mount.Mount{ + { Type: mount.TypeVolume, Source: fmt.Sprintf("audius-d-%s", host), Target: "/var/lib/docker", @@ -128,6 +128,17 @@ func runNode( if config.HostPorts != "" { allPorts = append(allPorts, strings.Split(config.HostPorts, ",")...) } + + if config.CorePortP2P == 0 { + config.CorePortP2P = 26656 + } + + if config.CorePortRPC == 0 { + config.CorePortRPC = 26657 + } + + allPorts = append(allPorts, fmt.Sprintf("%d:26656", config.CorePortP2P), fmt.Sprintf("%d:26657", config.CorePortRPC)) + portSet, portBindings, err := nat.ParsePortSpecs(allPorts) if err != nil { return logger.Error(err)