Skip to content

Commit

Permalink
chore: update ceramic one swarm port to 4101 and rpc port to 5101 (#194)
Browse files Browse the repository at this point in the history
* chore: update ceramic one swarm port to 4101 and rpc port to 5101

* chore: update CAS ipfs ports as well

also renamed some constants

* chore: fmt
  • Loading branch information
dav1do authored Jul 2, 2024
1 parent beded49 commit af38409
Show file tree
Hide file tree
Showing 38 changed files with 178 additions and 172 deletions.
8 changes: 4 additions & 4 deletions operator/src/network/cas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use crate::{
network::{
ceramic::NetworkConfig,
controller::{
CAS_APP, CAS_IPFS_APP, CAS_IPFS_SERVICE_NAME, CAS_POSTGRES_APP,
CAS_APP, CAS_IPFS_APP, CAS_IPFS_SERVICE_NAME, CAS_IPFS_SERVICE_PORT, CAS_POSTGRES_APP,
CAS_POSTGRES_SECRET_NAME, CAS_POSTGRES_SERVICE_NAME, CAS_SERVICE_NAME,
DEFAULT_METRICS_PORT, GANACHE_APP, GANACHE_SERVICE_NAME, LOCALSTACK_APP,
LOCALSTACK_SERVICE_NAME, NETWORK_DEV_MODE_RESOURCES,
Expand Down Expand Up @@ -426,7 +426,7 @@ pub fn cas_stateful_set_spec(
},
EnvVar {
name: "IPFS_API_URL".to_owned(),
value: Some(format!("http://{CAS_IPFS_SERVICE_NAME}:5001")),
value: Some(format!("http://{CAS_IPFS_SERVICE_NAME}:{CAS_IPFS_SERVICE_PORT}")),
..Default::default()
},
EnvVar {
Expand Down Expand Up @@ -621,9 +621,9 @@ pub fn cas_ipfs_service_spec() -> ServiceSpec {
ServiceSpec {
ports: Some(vec![ServicePort {
name: Some("cas-ipfs".to_owned()),
port: 5001,
port: CAS_IPFS_SERVICE_PORT,
protocol: Some("TCP".to_owned()),
target_port: Some(IntOrString::Int(5001)),
target_port: Some(IntOrString::Int(CAS_IPFS_SERVICE_PORT)),
..Default::default()
}]),
selector: selector_labels(CAS_IPFS_APP),
Expand Down
17 changes: 10 additions & 7 deletions operator/src/network/ceramic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use crate::{
labels::{managed_labels, selector_labels},
network::{
controller::{
CAS_SERVICE_NAME, CERAMIC_APP, CERAMIC_POSTGRES_SECRET_NAME, CERAMIC_SERVICE_API_PORT,
CERAMIC_SERVICE_IPFS_PORT, DEFAULT_METRICS_PORT, GANACHE_SERVICE_NAME,
CAS_SERVICE_NAME, CERAMIC_APP, CERAMIC_ONE_IPFS_PORT, CERAMIC_POSTGRES_SECRET_NAME,
CERAMIC_SERVICE_API_PORT, DEFAULT_METRICS_PORT, GANACHE_SERVICE_NAME,
INIT_CONFIG_MAP_NAME, NETWORK_DEV_MODE_RESOURCES, NODE_INSPECTION_PORT,
},
datadog::DataDogConfig,
Expand All @@ -33,7 +33,10 @@ use crate::{
utils::override_and_sort_env_vars,
};

use super::{debug_mode_security_context, storage::PersistentStorageConfig};
use super::{
controller::CERAMIC_ONE_SWARM_PORT, debug_mode_security_context,
storage::PersistentStorageConfig,
};

pub fn config_maps(
info: &CeramicInfo,
Expand Down Expand Up @@ -115,13 +118,13 @@ pub fn service_spec() -> ServiceSpec {
..Default::default()
},
ServicePort {
port: CERAMIC_SERVICE_IPFS_PORT,
port: CERAMIC_ONE_IPFS_PORT,
name: Some("ipfs".to_owned()),
protocol: Some("TCP".to_owned()),
..Default::default()
},
ServicePort {
port: 4001,
port: CERAMIC_ONE_SWARM_PORT,
name: Some("swarm-tcp".to_owned()),
protocol: Some("TCP".to_owned()),
..Default::default()
Expand Down Expand Up @@ -236,7 +239,7 @@ impl CeramicInfo {
/// Determine the IPFS RPC address of a Ceramic peer
pub fn ipfs_rpc_addr(&self, ns: &str, peer: i32) -> String {
format!(
"http://{}-{peer}.{}.{ns}.svc.cluster.local:{CERAMIC_SERVICE_IPFS_PORT}",
"http://{}-{peer}.{}.{ns}.svc.cluster.local:{CERAMIC_ONE_IPFS_PORT}",
self.stateful_set, self.service
)
}
Expand Down Expand Up @@ -360,7 +363,7 @@ pub fn stateful_set_spec(ns: &str, bundle: &CeramicBundle<'_>) -> StatefulSetSpe
},
EnvVar {
name: "CERAMIC_IPFS_HOST".to_owned(),
value: Some(format!("http://localhost:{CERAMIC_SERVICE_IPFS_PORT}")),
value: Some(format!("http://localhost:{CERAMIC_ONE_IPFS_PORT}")),
..Default::default()
},
EnvVar {
Expand Down
37 changes: 19 additions & 18 deletions operator/src/network/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ use crate::{
/// network.
pub const PEERS_CONFIG_MAP_NAME: &str = "keramik-peers";

pub const CERAMIC_SERVICE_IPFS_PORT: i32 = 5001;
pub const CERAMIC_ONE_SWARM_PORT: i32 = 4101;
pub const CERAMIC_ONE_IPFS_PORT: i32 = 5101;
pub const CERAMIC_SERVICE_API_PORT: i32 = 7007;
pub const CERAMIC_POSTGRES_SECRET_NAME: &str = "ceramic-postgres-auth";

Expand All @@ -80,7 +81,7 @@ pub const ADMIN_SECRET_NAME: &str = "ceramic-admin";

pub const CAS_SERVICE_NAME: &str = "cas";
pub const CAS_IPFS_SERVICE_NAME: &str = "cas-ipfs";
pub const CAS_SERVICE_IPFS_PORT: i32 = 5001;
pub const CAS_IPFS_SERVICE_PORT: i32 = 5101;
pub const CAS_POSTGRES_SERVICE_NAME: &str = "cas-postgres";
pub const CAS_POSTGRES_SECRET_NAME: &str = "postgres-auth";
pub const GANACHE_SERVICE_NAME: &str = "ganache";
Expand Down Expand Up @@ -890,7 +891,7 @@ async fn update_peer_status(
let network_config: NetworkConfig = network.spec().into();
if network_config.network_type == NetworkType::Local {
// CAS IPFS peer
let ipfs_rpc_addr = format!("http://{CAS_IPFS_SERVICE_NAME}-0.{CAS_IPFS_SERVICE_NAME}.{ns}.svc.cluster.local:{CAS_SERVICE_IPFS_PORT}");
let ipfs_rpc_addr = format!("http://{CAS_IPFS_SERVICE_NAME}-0.{CAS_IPFS_SERVICE_NAME}.{ns}.svc.cluster.local:{CAS_IPFS_SERVICE_PORT}");
match cx.rpc_client.peer_info(&ipfs_rpc_addr).await {
Ok(info) => {
status.peers.push(Peer::Ipfs(info));
Expand Down Expand Up @@ -2275,7 +2276,7 @@ mod tests {
- "env": [
- {
- "name": "CERAMIC_ONE_BIND_ADDRESS",
- "value": "0.0.0.0:5001"
- "value": "0.0.0.0:5101"
- },
- {
- "name": "CERAMIC_ONE_KADEMLIA_PARALLELISM",
Expand Down Expand Up @@ -2303,7 +2304,7 @@ mod tests {
- },
- {
- "name": "CERAMIC_ONE_SWARM_ADDRESSES",
- "value": "/ip4/0.0.0.0/tcp/4001"
- "value": "/ip4/0.0.0.0/tcp/4101"
- },
- {
- "name": "RUST_LOG",
Expand Down Expand Up @@ -2427,7 +2428,7 @@ mod tests {
- "env": [
- {
- "name": "CERAMIC_ONE_BIND_ADDRESS",
- "value": "0.0.0.0:5001"
- "value": "0.0.0.0:5101"
- },
- {
- "name": "CERAMIC_ONE_KADEMLIA_PARALLELISM",
Expand Down Expand Up @@ -2455,7 +2456,7 @@ mod tests {
- },
- {
- "name": "CERAMIC_ONE_SWARM_ADDRESSES",
- "value": "/ip4/0.0.0.0/tcp/4001"
- "value": "/ip4/0.0.0.0/tcp/4101"
- },
- {
- "name": "RUST_LOG",
Expand Down Expand Up @@ -2584,7 +2585,7 @@ mod tests {
- "env": [
- {
- "name": "CERAMIC_ONE_BIND_ADDRESS",
- "value": "0.0.0.0:5001"
- "value": "0.0.0.0:5101"
- },
- {
- "name": "CERAMIC_ONE_KADEMLIA_PARALLELISM",
Expand Down Expand Up @@ -2612,7 +2613,7 @@ mod tests {
- },
- {
- "name": "CERAMIC_ONE_SWARM_ADDRESSES",
- "value": "/ip4/0.0.0.0/tcp/4001"
- "value": "/ip4/0.0.0.0/tcp/4101"
- },
- {
- "name": "RUST_LOG",
Expand Down Expand Up @@ -2749,7 +2750,7 @@ mod tests {
"value": "0.0.0.0:9465"
},
@@ -252,11 +256,19 @@
"value": "/ip4/0.0.0.0/tcp/4001"
"value": "/ip4/0.0.0.0/tcp/4101"
},
{
+ "name": "ENV_KEY_A",
Expand Down Expand Up @@ -4185,7 +4186,7 @@ mod tests {
- "env": [
- {
- "name": "CERAMIC_ONE_BIND_ADDRESS",
- "value": "0.0.0.0:5001"
- "value": "0.0.0.0:5101"
- },
- {
- "name": "CERAMIC_ONE_KADEMLIA_PARALLELISM",
Expand Down Expand Up @@ -4213,7 +4214,7 @@ mod tests {
- },
- {
- "name": "CERAMIC_ONE_SWARM_ADDRESSES",
- "value": "/ip4/0.0.0.0/tcp/4001"
- "value": "/ip4/0.0.0.0/tcp/4101"
- },
- {
- "name": "RUST_LOG",
Expand Down Expand Up @@ -4547,7 +4548,7 @@ mod tests {
{
"mountPath": "/config",
@@ -252,6 +268,10 @@
"value": "/ip4/0.0.0.0/tcp/4001"
"value": "/ip4/0.0.0.0/tcp/4101"
},
{
+ "name": "CERAMIC_ONE_TOKIO_CONSOLE",
Expand Down Expand Up @@ -4599,7 +4600,7 @@ mod tests {
--- original
+++ modified
@@ -69,6 +69,10 @@
"value": "/ip4/0.0.0.0/tcp/4001"
"value": "/ip4/0.0.0.0/tcp/4101"
},
{
+ "name": "CERAMIC_ONE_TOKIO_CONSOLE",
Expand Down Expand Up @@ -4752,7 +4753,7 @@ mod tests {
+ "env": [
+ {
+ "name": "CERAMIC_ONE_BIND_ADDRESS",
+ "value": "0.0.0.0:5001"
+ "value": "0.0.0.0:5101"
+ },
+ {
+ "name": "CERAMIC_ONE_KADEMLIA_PARALLELISM",
Expand Down Expand Up @@ -4780,7 +4781,7 @@ mod tests {
+ },
+ {
+ "name": "CERAMIC_ONE_SWARM_ADDRESSES",
+ "value": "/ip4/0.0.0.0/tcp/4001"
+ "value": "/ip4/0.0.0.0/tcp/4101"
+ },
+ {
+ "name": "RUST_LOG",
Expand All @@ -4792,12 +4793,12 @@ mod tests {
+ "name": "ipfs-migration",
+ "ports": [
+ {
+ "containerPort": 4001,
+ "containerPort": 4101,
+ "name": "swarm-tcp",
+ "protocol": "TCP"
+ },
+ {
+ "containerPort": 5001,
+ "containerPort": 5101,
+ "name": "rpc",
+ "protocol": "TCP"
+ },
Expand Down
20 changes: 11 additions & 9 deletions operator/src/network/ipfs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use k8s_openapi::{
const IPFS_CONTAINER_NAME: &str = "ipfs";
const IPFS_STORE_DIR: &str = "/data/ipfs";
pub const IPFS_DATA_PV_CLAIM: &str = "ipfs-data";
const IPFS_SERVICE_PORT: i32 = 5001;

use crate::{
network::{
Expand All @@ -22,7 +21,10 @@ use crate::{
utils::override_and_sort_env_vars,
};

use super::debug_mode_security_context;
use super::{
controller::{CERAMIC_ONE_IPFS_PORT, CERAMIC_ONE_SWARM_PORT},
debug_mode_security_context,
};

/// Unique identifying information about this IPFS spec.
#[derive(Debug, Clone)]
Expand Down Expand Up @@ -172,7 +174,7 @@ impl RustIpfsConfig {
},
EnvVar {
name: "CERAMIC_ONE_BIND_ADDRESS".to_owned(),
value: Some(format!("0.0.0.0:{IPFS_SERVICE_PORT}")),
value: Some(format!("0.0.0.0:{CERAMIC_ONE_IPFS_PORT}")),
..Default::default()
},
EnvVar {
Expand All @@ -182,7 +184,7 @@ impl RustIpfsConfig {
},
EnvVar {
name: "CERAMIC_ONE_SWARM_ADDRESSES".to_owned(),
value: Some("/ip4/0.0.0.0/tcp/4001".to_owned()),
value: Some(format!("/ip4/0.0.0.0/tcp/{CERAMIC_ONE_SWARM_PORT}")),
..Default::default()
},
EnvVar {
Expand Down Expand Up @@ -225,13 +227,13 @@ impl RustIpfsConfig {
// Construct the set of ports
let mut ports = vec![
ContainerPort {
container_port: 4001,
container_port: CERAMIC_ONE_SWARM_PORT,
name: Some("swarm-tcp".to_owned()),
protocol: Some("TCP".to_owned()),
..Default::default()
},
ContainerPort {
container_port: IPFS_SERVICE_PORT,
container_port: CERAMIC_ONE_IPFS_PORT,
name: Some("rpc".to_owned()),
protocol: Some("TCP".to_owned()),
..Default::default()
Expand Down Expand Up @@ -361,7 +363,7 @@ ipfs config --json Addresses.Gateway '[]'
# Enable pubsub
ipfs config --json PubSub.Enabled true
# Only listen on specific tcp address as nothing else is exposed
ipfs config --json Addresses.Swarm '["/ip4/0.0.0.0/tcp/4001"]'
ipfs config --json Addresses.Swarm '["/ip4/0.0.0.0/tcp/4101"]'
# Set explicit resource manager limits as Kubo computes them based off
# the k8s node resources and not the pods limits.
ipfs config Swarm.ResourceMgr.MaxMemory '400 MB'
Expand Down Expand Up @@ -415,13 +417,13 @@ ipfs config --json Swarm.ResourceMgr.MaxFileDescriptors 500000
name: IPFS_CONTAINER_NAME.to_owned(),
ports: Some(vec![
ContainerPort {
container_port: 4001,
container_port: CERAMIC_ONE_SWARM_PORT,
name: Some("swarm-tcp".to_owned()),
protocol: Some("TCP".to_owned()),
..Default::default()
},
ContainerPort {
container_port: IPFS_SERVICE_PORT,
container_port: CERAMIC_ONE_IPFS_PORT,
name: Some("rpc".to_owned()),
protocol: Some("TCP".to_owned()),
..Default::default()
Expand Down
8 changes: 4 additions & 4 deletions operator/src/network/testdata/ceramic_go_ss_1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Request {
},
{
"name": "CERAMIC_IPFS_HOST",
"value": "http://localhost:5001"
"value": "http://localhost:5101"
},
{
"name": "CERAMIC_LOG_LEVEL",
Expand Down Expand Up @@ -223,12 +223,12 @@ Request {
"name": "ipfs",
"ports": [
{
"containerPort": 4001,
"containerPort": 4101,
"name": "swarm-tcp",
"protocol": "TCP"
},
{
"containerPort": 5001,
"containerPort": 5101,
"name": "rpc",
"protocol": "TCP"
},
Expand Down Expand Up @@ -290,7 +290,7 @@ Request {
},
{
"name": "CERAMIC_IPFS_HOST",
"value": "http://localhost:5001"
"value": "http://localhost:5101"
},
{
"name": "CERAMIC_LOG_LEVEL",
Expand Down
4 changes: 2 additions & 2 deletions operator/src/network/testdata/ceramic_go_svc_1
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ Request {
},
{
"name": "ipfs",
"port": 5001,
"port": 5101,
"protocol": "TCP"
},
{
"name": "swarm-tcp",
"port": 4001,
"port": 4101,
"protocol": "TCP"
}
],
Expand Down
Loading

0 comments on commit af38409

Please sign in to comment.