Skip to content

Commit

Permalink
Merge pull request #491 from threefoldtech/development_mycelium_in_al…
Browse files Browse the repository at this point in the history
…l_tests_and_examples

test all in mycelium
  • Loading branch information
rawdaGastan authored Sep 8, 2024
2 parents 7712b8d + 673a48d commit b79e109
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 30 deletions.
27 changes: 16 additions & 11 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,30 @@ jobs:
with:
go-version: 1.21

- name: install curl, wg and yggdrasil and add peers
- name: install curl, wg, mycelium and add peers
run: |
sudo apt-get update
sudo apt-get install -y wireguard
sudo apt-get install dirmngr
sudo apt-get install curl
gpg --fetch-keys https://neilalexander.s3.dualstack.eu-west-2.amazonaws.com/deb/key.txt
gpg --export 569130E8CA20FBC4CB3FDE555898470A764B32C9 | sudo apt-key add -
echo 'deb http://neilalexander.s3.dualstack.eu-west-2.amazonaws.com/deb/ debian yggdrasil' | sudo tee /etc/apt/sources.list.d/yggdrasil.list
sudo apt-get update
sudo apt-get install yggdrasil
sudo systemctl enable yggdrasil
PEERS=$(curl https://raw.githubusercontent.com/AhmedHanafy725/yggdrasil-config/main/config.json | jq '.yggdrasil.peers[]' -r | sed 's/\//\\\//g' | sed -z 's/\n/\\n/g')
sudo sed -i -- 's/Peers\: \[\]/Peers: [\n'"$PEERS"']/g' /etc/yggdrasil/yggdrasil.conf
sudo systemctl stop yggdrasil
sudo systemctl start yggdrasil
wget https://github.com/threefoldtech/mycelium/releases/download/v0.5.4/mycelium-x86_64-unknown-linux-musl.tar.gz
tar xzf mycelium-x86_64-unknown-linux-musl.tar.gz
sudo ./mycelium --peers tcp://188.40.132.242:9651 quic://185.69.166.8:9651 --tun-name utun9 -k /tmp/mycelium_priv_key.bin &
- name: Run Tests
run: make integration
env:
MNEMONIC: ${{ secrets.MNEMONIC }}
NETWORK: ${{ matrix.network }}

# # yggdrasil installation
# gpg --fetch-keys https://neilalexander.s3.dualstack.eu-west-2.amazonaws.com/deb/key.txt
# gpg --export 569130E8CA20FBC4CB3FDE555898470A764B32C9 | sudo apt-key add -
# echo 'deb http://neilalexander.s3.dualstack.eu-west-2.amazonaws.com/deb/ debian yggdrasil' | sudo tee /etc/apt/sources.list.d/yggdrasil.list
# sudo apt-get update
# sudo apt-get install yggdrasil
# sudo systemctl enable yggdrasil
# PEERS=$(curl https://raw.githubusercontent.com/AhmedHanafy725/yggdrasil-config/main/config.json | jq '.yggdrasil.peers[]' -r | sed 's/\//\\\//g' | sed -z 's/\n/\\n/g')
# sudo sed -i -- 's/Peers\: \[\]/Peers: [\n'"$PEERS"']/g' /etc/yggdrasil/yggdrasil.conf
# sudo systemctl stop yggdrasil
# sudo systemctl start yggdrasil
13 changes: 3 additions & 10 deletions .github/workflows/integration_latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,9 @@ jobs:
sudo apt-get install -y wireguard
sudo apt-get install dirmngr
sudo apt-get install curl
gpg --fetch-keys https://neilalexander.s3.dualstack.eu-west-2.amazonaws.com/deb/key.txt
gpg --export 569130E8CA20FBC4CB3FDE555898470A764B32C9 | sudo apt-key add -
echo 'deb http://neilalexander.s3.dualstack.eu-west-2.amazonaws.com/deb/ debian yggdrasil' | sudo tee /etc/apt/sources.list.d/yggdrasil.list
sudo apt-get update
sudo apt-get install yggdrasil
sudo systemctl enable yggdrasil
PEERS=$(curl https://raw.githubusercontent.com/AhmedHanafy725/yggdrasil-config/main/config.json | jq '.yggdrasil.peers[]' -r | sed 's/\//\\\//g' | sed -z 's/\n/\\n/g')
sudo sed -i -- 's/Peers\: \[\]/Peers: [\n'"$PEERS"']/g' /etc/yggdrasil/yggdrasil.conf
sudo systemctl stop yggdrasil
sudo systemctl start yggdrasil
wget https://github.com/threefoldtech/mycelium/releases/download/v0.5.4/mycelium-x86_64-unknown-linux-musl.tar.gz
tar xzf mycelium-x86_64-unknown-linux-musl.tar.gz
sudo ./mycelium --peers tcp://188.40.132.242:9651 quic://185.69.166.8:9651 --tun-name utun9 -k /tmp/mycelium_priv_key.bin &
- name: Install provider
run: make install_latest
Expand Down
22 changes: 22 additions & 0 deletions docs/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func main() {
}).(pulumi.IntOutput),
},
Ip_range: pulumi.String("10.1.0.0/16"),
Mycelium: pulumi.Bool(true),
}, pulumi.Provider(tfProvider), pulumi.DependsOn([]pulumi.Resource{
scheduler,
}))
Expand All @@ -225,6 +226,7 @@ func main() {
Cpu: pulumi.Int(2),
Memory: pulumi.Int(256),
Planetary: pulumi.Bool(true),
Mycelium: pulumi.Bool(true),
Mounts: threefold.MountArray{
&threefold.MountArgs{
Disk_name: pulumi.String("data"),
Expand Down Expand Up @@ -252,6 +254,9 @@ func main() {
ctx.Export("planetary_ip", deployment.Vms_computed.ApplyT(func(vms_computed []threefold.VMComputed) (*string, error) {
return &vms_computed[0].Planetary_ip, nil
}).(pulumi.StringPtrOutput))
ctx.Export("mycelium_ip", deployment.Vms_computed.ApplyT(func(vms_computed []threefold.VMComputed) (*string, error) {
return &vms_computed[0].Mycelium_ip, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
Expand Down Expand Up @@ -496,6 +501,7 @@ func main() {
}).(pulumi.IntOutput),
},
Ip_range: pulumi.String("10.1.0.0/16"),
Mycelium: pulumi.Bool(true),
}, pulumi.Provider(tfProvider), pulumi.DependsOn([]pulumi.Resource{
scheduler,
}))
Expand All @@ -511,6 +517,7 @@ func main() {
}).(pulumi.IntOutput),
Disk_size: pulumi.Int(2),
Planetary: pulumi.Bool(true),
Mycelium: pulumi.Bool(true),
Cpu: pulumi.Int(2),
Memory: pulumi.Int(2048),
},
Expand Down Expand Up @@ -549,6 +556,9 @@ func main() {
ctx.Export("planetary_ip", kubernetes.Master_computed.ApplyT(func(master_computed threefold.K8sNodeComputed) (*string, error) {
return &master_computed.Planetary_ip, nil
}).(pulumi.StringPtrOutput))
ctx.Export("mycelium_ip", kubernetes.Master_computed.ApplyT(func(master_computed threefold.K8sNodeComputed) (*string, error) {
return &master_computed.Mycelium_ip, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
Expand Down Expand Up @@ -577,6 +587,7 @@ network = threefold.Network("network",
description="example network",
nodes=[scheduler.nodes[0]],
ip_range="10.1.0.0/16",
mycelium=True,
opts = pulumi.ResourceOptions(provider=provider,
depends_on=[scheduler]))
kubernetes = threefold.Kubernetes("kubernetes",
Expand All @@ -586,6 +597,7 @@ kubernetes = threefold.Kubernetes("kubernetes",
node=scheduler.nodes[0],
disk_size=2,
planetary=True,
mycelium=True,
cpu=2,
memory=2048,
),
Expand Down Expand Up @@ -654,6 +666,7 @@ resources:
nodes:
- ${scheduler.nodes[0]}
ip_range: 10.1.0.0/16
mycelium: true

kubernetes:
type: threefold:Kubernetes
Expand All @@ -668,6 +681,7 @@ resources:
node: ${scheduler.nodes[0]}
disk_size: 2
planetary: true
mycelium: true
cpu: 2
memory: 2048

Expand All @@ -678,12 +692,14 @@ resources:
disk_size: 2
cpu: 2
memory: 2048
mycelium: true
- name: worker2
network_name: test
node: ${scheduler.nodes[0]}
disk_size: 2
cpu: 2
memory: 2048
mycelium: true

token: t123456789
network_name: test
Expand All @@ -692,6 +708,7 @@ resources:
outputs:
node_deployment_id: ${kubernetes.node_deployment_id}
planetary_ip: ${kubernetes.master_computed.planetary_ip}
mycelium_ip: ${kubernetes.master_computed.mycelium_ip}
```
{{% /choosable %}}
Expand All @@ -714,6 +731,7 @@ const network = new threefold.Network("network", {
description: "test network",
nodes: [scheduler.nodes[0]],
ip_range: "10.1.0.0/16",
mycelium: true,
}, {
provider: provider,
dependsOn: [scheduler],
Expand All @@ -725,6 +743,7 @@ const kubernetes = new threefold.Kubernetes("kubernetes", {
node: scheduler.nodes[0],
disk_size: 2,
planetary: true,
mycelium: true,
cpu: 2,
memory: 2048,
},
Expand All @@ -736,6 +755,7 @@ const kubernetes = new threefold.Kubernetes("kubernetes", {
disk_size: 2,
cpu: 2,
memory: 2048,
mycelium: true,
},
{
name: "worker2",
Expand All @@ -744,6 +764,7 @@ const kubernetes = new threefold.Kubernetes("kubernetes", {
disk_size: 2,
cpu: 2,
memory: 2048,
mycelium: true,
},
],
token: "t123456789",
Expand All @@ -755,6 +776,7 @@ const kubernetes = new threefold.Kubernetes("kubernetes", {
});
export const nodeDeploymentId = kubernetes.node_deployment_id;
export const planetaryIp = kubernetes.master_computed.apply(master_computed => master_computed.planetary_ip);
export const myceliumIp = kubernetes.master_computed.apply(master_computed => master_computed.mycelium_ip);
```

{{% /choosable %}}
Expand Down
5 changes: 5 additions & 0 deletions examples/go/kubernetes/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func main() {
}).(pulumi.IntOutput),
},
Ip_range: pulumi.String("10.1.0.0/16"),
Mycelium: pulumi.Bool(true),
}, pulumi.Provider(tfProvider), pulumi.DependsOn([]pulumi.Resource{
scheduler,
}))
Expand All @@ -49,6 +50,7 @@ func main() {
}).(pulumi.IntOutput),
Disk_size: pulumi.Int(2),
Planetary: pulumi.Bool(true),
Mycelium: pulumi.Bool(true),
Cpu: pulumi.Int(2),
Memory: pulumi.Int(2048),
},
Expand Down Expand Up @@ -87,6 +89,9 @@ func main() {
ctx.Export("planetary_ip", kubernetes.Master_computed.ApplyT(func(master_computed threefold.K8sNodeComputed) (*string, error) {
return &master_computed.Planetary_ip, nil
}).(pulumi.StringPtrOutput))
ctx.Export("mycelium_ip", kubernetes.Master_computed.ApplyT(func(master_computed threefold.K8sNodeComputed) (*string, error) {
return &master_computed.Mycelium_ip, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
5 changes: 5 additions & 0 deletions examples/go/virtual_machine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func main() {
}).(pulumi.IntOutput),
},
Ip_range: pulumi.String("10.1.0.0/16"),
Mycelium: pulumi.Bool(true),
}, pulumi.Provider(tfProvider), pulumi.DependsOn([]pulumi.Resource{
scheduler,
}))
Expand All @@ -58,6 +59,7 @@ func main() {
Cpu: pulumi.Int(2),
Memory: pulumi.Int(256),
Planetary: pulumi.Bool(true),
Mycelium: pulumi.Bool(true),
Mounts: threefold.MountArray{
&threefold.MountArgs{
Disk_name: pulumi.String("data"),
Expand Down Expand Up @@ -85,6 +87,9 @@ func main() {
ctx.Export("planetary_ip", deployment.Vms_computed.ApplyT(func(vms_computed []threefold.VMComputed) (*string, error) {
return &vms_computed[0].Planetary_ip, nil
}).(pulumi.StringPtrOutput))
ctx.Export("mycelium_ip", deployment.Vms_computed.ApplyT(func(vms_computed []threefold.VMComputed) (*string, error) {
return &vms_computed[0].Mycelium_ip, nil
}).(pulumi.StringPtrOutput))
return nil
})
}
5 changes: 4 additions & 1 deletion examples/nodejs/kubernetes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const network = new threefold.Network("network", {
description: "test network",
nodes: [scheduler.nodes[0]],
ip_range: "10.1.0.0/16",
mycelium: true,
}, {
provider: provider,
dependsOn: [scheduler],
Expand All @@ -24,6 +25,7 @@ const kubernetes = new threefold.Kubernetes("kubernetes", {
node: scheduler.nodes[0],
disk_size: 2,
planetary: true,
mycelium: true,
cpu: 2,
memory: 2048,
},
Expand Down Expand Up @@ -53,4 +55,5 @@ const kubernetes = new threefold.Kubernetes("kubernetes", {
dependsOn: [network],
});
export const nodeDeploymentId = kubernetes.node_deployment_id;
export const planetaryIp = kubernetes.master_computed.apply(master_computed => master_computed.planetary_ip);
export const planetaryIP = kubernetes.master_computed.apply(master_computed => master_computed.planetary_ip);
export const myceliumIP = kubernetes.master_computed.apply(master_computed => master_computed.mycelium_ip);
4 changes: 4 additions & 0 deletions examples/python/kubernetes/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
description="test network",
nodes=[scheduler.nodes[0]],
ip_range="10.1.0.0/16",
mycelium=True,
opts = pulumi.ResourceOptions(provider=provider,
depends_on=[scheduler]))
kubernetes = threefold.Kubernetes("kubernetes",
Expand All @@ -25,6 +26,7 @@
node=scheduler.nodes[0],
disk_size=2,
planetary=True,
mycelium=True,
cpu=2,
memory=2048,
),
Expand All @@ -36,6 +38,7 @@
disk_size=2,
cpu=2,
memory=2048,
mycelium=True,
),
threefold.K8sNodeInputArgs(
name="worker2",
Expand All @@ -44,6 +47,7 @@
disk_size=2,
cpu=2,
memory=2048,
mycelium=True,
),
],
token="t123456789",
Expand Down
5 changes: 5 additions & 0 deletions examples/yaml/kubernetes/Pulumi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ resources:
nodes:
- ${scheduler.nodes[0]}
ip_range: 10.1.0.0/16
mycelium: true

kubernetes:
type: threefold:Kubernetes
Expand All @@ -50,6 +51,7 @@ resources:
node: ${scheduler.nodes[0]}
disk_size: 2
planetary: true
mycelium: true
cpu: 2
memory: 2048

Expand All @@ -60,12 +62,14 @@ resources:
disk_size: 2
cpu: 2
memory: 2048
mycelium: true
- name: worker2
network_name: test
node: ${scheduler.nodes[0]}
disk_size: 2
cpu: 2
memory: 2048
mycelium: true

token: t123456789
network_name: test
Expand All @@ -74,3 +78,4 @@ resources:
outputs:
node_deployment_id: ${kubernetes.node_deployment_id}
planetary_ip: ${kubernetes.master_computed.planetary_ip}
mycelium_ip: ${kubernetes.master_computed.mycelium_ip}
4 changes: 4 additions & 0 deletions tests/examples/kubernetes/Pulumi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ resources:
nodes:
- ${scheduler.nodes[0]}
ip_range: 10.1.0.0/16
mycelium: true

kubernetes:
type: threefold:Kubernetes
Expand All @@ -47,6 +48,7 @@ resources:
node: ${scheduler.nodes[0]}
disk_size: 2
planetary: true
mycelium: true
cpu: 2
memory: 2048

Expand All @@ -57,12 +59,14 @@ resources:
disk_size: 2
cpu: 2
memory: 2048
mycelium: true
- name: worker2
network_name: test
node: ${scheduler.nodes[0]}
disk_size: 2
cpu: 2
memory: 2048
mycelium: true

token: t123456789
network_name: test
Expand Down
2 changes: 2 additions & 0 deletions tests/examples/virtual_machine/Pulumi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ resources:
nodes:
- ${scheduler.nodes[0]}
ip_range: 10.1.0.0/16
mycelium: true

deployment:
type: threefold:Deployment
Expand All @@ -53,6 +54,7 @@ resources:
cpu: 2
memory: 256
planetary: true
mycelium: true
mounts:
- disk_name: data
mount_point: /app
Expand Down
Loading

0 comments on commit b79e109

Please sign in to comment.