finalized info_fgrid sync

This commit is contained in:
mik-tf
2024-08-29 19:22:26 -04:00
parent a75e59d42c
commit 0c33119601
53 changed files with 1088 additions and 571 deletions

View File

@@ -0,0 +1,9 @@
<h1> Complete Guides </h1>
This section covers complete guides to deploy workloads on the ThreeFold Grid with Pulumi.
<h2>Table of Contents</h2>
- [Pulumi and YAML](./pulumi_yaml.md)
- [Pulumi and Python](./pulumi_python.md)
- [Pulumi and Go](./pulumi_go.md)

View File

@@ -0,0 +1,90 @@
<h1> Pulumi Complete Go Guide</h1>
<h2>Table of Contents</h2>
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Steps](#steps)
- [Alternative to Make Commands](#alternative-to-make-commands)
---
## Introduction
In this guide, we cover the complete steps to deploy a virtual machine on the grid with Pulumi via Go.
To provide a uniform deployment method, we use Docker for this guide. It is optional but will greatly facilitate the deployment as the steps will be similar for Linux, MacOS and Windows.
This guide is useful to get you started quickly with Pulumi on the TFGrid.
Once you've successfully deployed a VM, you can try all the different Go examples within the [pulumi-threefold repository](https://github.com/threefoldtech/pulumi-threefold). The examples are available in the subdirectory `/examples/go/`.
## Prerequisites
- [A TFChain account](dashboard@@wallet_connector)
- TFT in your TFChain account
- [Buy TFT](threefold_token@@buy_sell_tft)
- [Send TFT to TFChain](threefold_token@@tfchain_stellar_bridge)
- [Get Docker](https://docs.docker.com/get-docker/)
## Steps
- Deploy a Docker Ubuntu container in interactive mode:
```
sudo docker run -it --net=host ubuntu:jammy /bin/bash
```
- In Docker Ubuntu, deploy a VM with Pulumi. Make sure to add your `MNEMONIC` and `SSH_KEY` below before running the script. For this deployment we use `main` as the `NETWORK`. Change this if needed.
```
# Install the prerequisites
apt update && apt install -y curl git wget make
# Install Pulumi
curl -fsSL https://get.pulumi.com | sh
export PATH=$PATH=:/root/.pulumi/bin
# Clone the ThreeFold Pulumi repo
git clone https://github.com/threefoldtech/pulumi-threefold.git
cd pulumi-threefold/examples/go/virtual_machine
# Prepare the Pulumi Go environment
# Install Go
wget https://go.dev/dl/go1.23.0.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.23.0.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
# Export the variables
export NETWORK="main"
export SSH_KEY="<ADD_YOUR_SSH_PUBLIC_KEY>"
export MNEMONIC="<ADD_YOUR_MNEMONIC>"
# Start Pulumi
make run
```
- You can now SSH into the deployment from your local machine terminal
```
ssh root@VM_IP
```
- To destroy the deployment, run the following line within the Docker Ubuntu terminal.
```
make destroy
```
## Alternative to Make Commands
You can use direct Pulumi commands instead of the Make commands above.
- You can replace `make run` with:
```
pulumi login --local
pulumi up
```
- You can replace `make destroy` with:
```
pulumi down
pulumi stack rm <stack_name>
```
That being said, the Make commands run additional features. Feel free to explore the possibilities and consult the files within the repo for more information.

View File

@@ -0,0 +1,89 @@
<h1> Pulumi Complete Python Guide</h1>
<h2>Table of Contents</h2>
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Steps](#steps)
- [Alternative to Make Commands](#alternative-to-make-commands)
---
## Introduction
In this guide, we cover the complete steps to deploy a virtual machine on the grid with Pulumi via Python.
To provide a uniform deployment method, we use Docker for this guide. It is optional but will greatly facilitate the deployment as the steps will be similar for Linux, MacOS and Windows.
This guide is useful to get you started quickly with Pulumi on the TFGrid.
Once you've successfully deployed a VM, you can try all the different Python examples within the [pulumi-threefold repository](https://github.com/threefoldtech/pulumi-threefold). The examples are available in the subdirectory `/examples/python/`.
## Prerequisites
- [A TFChain account](dashboard@@wallet_connector)
- TFT in your TFChain account
- [Buy TFT](threefold_token@@buy_sell_tft)
- [Send TFT to TFChain](threefold_token@@tfchain_stellar_bridge)
- [Get Docker](https://docs.docker.com/get-docker/)
## Steps
- Deploy a Docker Ubuntu container in interactive mode:
```
sudo docker run -it --net=host ubuntu:jammy /bin/bash
```
- In Docker Ubuntu, deploy a VM with Pulumi. Make sure to add your `MNEMONIC` and `SSH_KEY` below before running the script. For this deployment we use `main` as the `NETWORK`. Change this if needed.
```
# Install the prerequisites
apt update && apt install -y curl git python3 python-is-python3 python3-venv python3-pip
# Install Pulumi
curl -fsSL https://get.pulumi.com | sh
export PATH=$PATH=:/root/.pulumi/bin
# Clone the ThreeFold Pulumi repo
git clone https://github.com/threefoldtech/pulumi-threefold.git
cd pulumi-threefold
# Prepare the Pulumi Python environment
cd examples/python
python -m venv venv
source venv/bin/activate
cd virtual_machine
pip install -r requirements.txt
# Export the variables
export NETWORK="main"
export SSH_KEY="<ADD_YOUR_SSH_PUBLIC_KEY>"
export MNEMONIC="<ADD_YOUR_MNEMONIC>"
# Start Pulumi
make run
```
- You can now SSH into the deployment from your local machine terminal
```
ssh root@VM_IP
```
- To destroy the deployment, run the following line within the Docker Ubuntu terminal.
```
make destroy
```
## Alternative to Make Commands
You can use direct Pulumi commands instead of the Make commands above.
- You can replace `make run` with:
```
pulumi login --local
pulumi up
```
- You can replace `make destroy` with:
```
pulumi down
pulumi stack rm <stack_name>
```
That being said, the Make commands run additional features. Feel free to explore the possibilities and consult the files within the repo for more information.

View File

@@ -0,0 +1,77 @@
<h1> Pulumi Complete YAML Guide</h1>
<h2>Table of Contents</h2>
- [Introduction](#introduction)
- [Prerequisites](#prerequisites)
- [Steps](#steps)
- [Alternative to Make Commands](#alternative-to-make-commands)
---
## Introduction
In this guide, we cover the complete steps to deploy a virtual machine on the grid with Pulumi via a YAML file.
To provide a uniform deployment method, we use Docker for this guide. It is optional but will greatly facilitate the deployment as the steps will be similar for Linux, MacOS and Windows.
This guide is useful to get you started quickly with Pulumi on the TFGrid.
Once you've successfully deployed a VM, you can try all the different YAML examples within the [pulumi-threefold repository](https://github.com/threefoldtech/pulumi-threefold). The examples are available in the subdirectory `/examples/yaml/`.
## Prerequisites
- [A TFChain account](dashboard@@wallet_connector)
- TFT in your TFChain account
- [Buy TFT](threefold_token@@buy_sell_tft)
- [Send TFT to TFChain](threefold_token@@tfchain_stellar_bridge)
- [Get Docker](https://docs.docker.com/get-docker/)
## Steps
- Deploy a Docker Ubuntu container in interactive mode:
```
sudo docker run -it --net=host ubuntu:jammy /bin/bash
```
- In Docker Ubuntu, deploy a VM with Pulumi. Make sure to add your `MNEMONIC` and `SSH_KEY` below before running the script. For this deployment we use `main` as the `NETWORK`. Change this if needed.
```
# Install the prerequisites
apt update && apt install -y curl git make
curl -fsSL https://get.pulumi.com | sh
export PATH=$PATH=:/root/.pulumi/bin
git clone https://github.com/threefoldtech/pulumi-threefold.git
cd pulumi-threefold/examples/yaml/virtual_machine
# Export the variables
export NETWORK="main"
export SSH_KEY="<ADD_YOUR_SSH_PUBLIC_KEY>"
export MNEMONIC="<ADD_YOUR_MNEMONIC>"
# Start Pulumi
make run
```
- You can now SSH into the deployment from your local machine terminal
```
ssh root@VM_IP
```
- To destroy the deployment, run the following line within the Docker Ubuntu terminal.
```
make destroy
```
## Alternative to Make Commands
You can use direct Pulumi commands instead of the Make commands above.
- You can replace `make run` with:
```
pulumi login --local
pulumi up
```
- You can replace `make destroy` with:
```
pulumi down
pulumi stack rm <stack_name>
```
That being said, the Make commands provide additional commands. Feel free to explore the possibilities and consult the files within the repo for more information.

View File

@@ -98,7 +98,7 @@ We address here how to create a [network](https://github.com/threefoldtech/pulum
You can find the original file [here](https://github.com/threefoldtech/pulumi-provider-grid/blob/development/examples/yaml/network/Pulumi.yaml).
```yml
name: pulumi-provider-grid
name: pulumi-threefold
runtime: yaml
plugins:
@@ -113,7 +113,7 @@ resources:
mnemonic:
scheduler:
type: grid:internal:Scheduler
type: threefold:provider:Scheduler
options:
provider: ${provider}
properties:
@@ -139,13 +139,14 @@ outputs:
We will now go through this file section by section to properly understand what is happening.
Here we set the name for the project. It can be anything. We also set the runtime. It can be some code in YAML, Python, Go, etc.
```yml
name: pulumi-provider-grid
runtime: yaml
```
- name is for the project name (can be anything)
- runtime: the runtime we are using can be code in yaml, python, go, etc.
We then start by initializing the resources. The provider which we loaded in the plugins section is also a resource that has properties (the main one now is just the mnemonic of TFChain).
```yml
plugins:
@@ -160,13 +161,15 @@ Here, we define the plugins we are using within our project and their locations.
```yml
resources:
provider:
type: pulumi:providers:grid
type: pulumi:providers:threefold
options:
pluginDownloadURL: github://api.github.com/threefoldtech/pulumi-threefold # optional
properties:
mnemonic:
```
We then start by initializing the resources. The provider which we loaded in the plugins section is also a resource that has properties (the main one now is just the mnemonic of TCHhain).
Then, we create a scheduler `threefold:provider:Scheduler`, that does the planning for us. Instead of being too specific about node IDs, we just give it some generic information. For example, "I want to work against these data centers (farms)". As long as the necessary criteria are provided, the scheduler can be more specific in the planning and select the appropriate resources available on the TFGrid.
```yaml
scheduler:
@@ -177,7 +180,7 @@ We then start by initializing the resources. The provider which we loaded in the
farm_ids: [1]
```
Then, we create a scheduler `grid:internal:Scheduler`, that does the planning for us. Instead of being too specific about node IDs, we just give it some generic information. For example, "I want to work against these data centers (farms)". As long as the necessary criteria are provided, the scheduler can be more specific in the planning and select the appropriate resources available on the TFGrid.
Now, that we created the scheduler, we can go ahead and create the network resource `grid:internal:Network`. Please note that the network depends on the scheduler's existence. If we remove it, the scheduler and the network will be created in parallel, that's why we have the `dependsOn` section. We then proceed to specify the network resource properties, e.g. the name, the description, which nodes to deploy our network on, the IP range of the network. In our case, we only choose one node.
```yaml
network:
@@ -194,8 +197,6 @@ Then, we create a scheduler `grid:internal:Scheduler`, that does the planning fo
ip_range: 10.1.0.0/16
```
Now, that we created the scheduler, we can go ahead and create the network resource `grid:internal:Network`. Please note that the network depends on the scheduler's existence. If we remove it, the scheduler and the network will be created in parallel, that's why we have the `dependsOn` section. We then proceed to specify the network resource properties, e.g. the name, the description, which nodes to deploy our network on, the IP range of the network. In our case, we only choose one node.
To access information related to our deployment, we set the section **outputs**. This will display results that we can use, or reuse, while we develop our infrastructure further.
```yaml
@@ -211,7 +212,7 @@ Now, we will check an [example](https://github.com/threefoldtech/pulumi-provider
Just like we've seen above, we will have two files `Makefile` and `Pulumi.yaml` where we describe the infrastructure.
```yml
name: pulumi-provider-grid
name: pulumi-threefold
runtime: yaml
plugins:
@@ -221,12 +222,14 @@ plugins:
resources:
provider:
type: pulumi:providers:grid
type: pulumi:providers:threefold
options:
pluginDownloadURL: github://api.github.com/threefoldtech/pulumi-threefold # optional
properties:
mnemonic: <to be filled>
scheduler:
type: grid:internal:Scheduler
type: threefold:provider:Scheduler
options:
provider: ${provider}
properties:
@@ -280,11 +283,11 @@ outputs:
planetary_ip: ${deployment.vms_computed[0].planetary_ip}
```
We have a scheduler, and a network just like before. But now, we also have a deployment `grid:internal:Deployment` object that can have one or more disks and virtual machines.
We have a scheduler, and a network just like before. But now, we also have a deployment `threefold:provider:Deployment` object that can have one or more disks and virtual machines.
```yaml
deployment:
type: grid:internal:Deployment
type: threefold:provider:Deployment
options:
provider: ${provider}
dependsOn:
@@ -301,11 +304,13 @@ deployment:
cpu: 2
memory: 256
planetary: true
mycelium: true
# mycelium_ip_seed: b60f2b7ec39c # hex encoded 6 bytes [example]
mounts:
- disk_name: data
mount_point: /app
env_vars:
SSH_KEY: <to be filled>
SSH_KEY:
disks:
- name: data
@@ -325,7 +330,7 @@ We now see how to deploy a [Kubernetes cluster using Pulumi](https://github.com/
```yaml
content was removed for brevity
kubernetes:
type: grid:internal:Kubernetes
type: threefold:provider:Kubernetes
options:
provider: ${provider}
dependsOn:
@@ -383,7 +388,7 @@ We present here the file for a simple domain prefix.
```yml
content was removed for brevity
scheduler:
type: grid:internal:Scheduler
type: threefold:provider:Scheduler
options:
provider: ${provider}
properties:
@@ -393,7 +398,7 @@ We present here the file for a simple domain prefix.
free_ips: 1
gatewayName:
type: grid:internal:GatewayName
type: threefold:provider:GatewayName
options:
provider: ${provider}
dependsOn:
@@ -404,10 +409,6 @@ We present here the file for a simple domain prefix.
backends:
- "http://69.164.223.208"
outputs:
node_deployment_id: ${gatewayName.node_deployment_id}
fqdn: ${gatewayName.fqdn}
```
In this example, we create a gateway name resource `grid:internal:GatewayName` for the name `pulumi.gent01.dev.grid.tf`.
@@ -425,7 +426,7 @@ Here's an [example](https://github.com/threefoldtech/pulumi-provider-grid/blob/d
```yml
code removed for brevity
gatewayFQDN:
type: grid:internal:GatewayFQDN
type: threefold:provider:GatewayFQDN
options:
provider: ${provider}
dependsOn:
@@ -444,6 +445,4 @@ Here, we informed the gateway that any request coming for the domain `mydomain.c
## Conclusion
We covered in this guide some basic details concerning the use of the ThreeFold Pulumi plugin.
If you have any questions, you can ask the ThreeFold community for help on the [ThreeFold Forum](http://forum.threefold.io/) or on the [ThreeFold Grid Tester Community](https://t.me/threefoldtesting) on Telegram.
We covered in this guide some basic details concerning the use of the ThreeFold Pulumi plugin.

View File

@@ -3,11 +3,11 @@
<h2>Table of Contents</h2>
- [Introduction](#introduction)
- [Check All the Examples](#check-all-the-examples)
- [Prerequisites](#prerequisites)
- [Set the Environment Variables](#set-the-environment-variables)
- [Test the Plugin](#test-the-plugin)
- [Destroy the Deployment](#destroy-the-deployment)
- [Questions and Feedback](#questions-and-feedback)
***
@@ -19,6 +19,12 @@ We present here the basic steps to test the examples within the [ThreeFold Pulum
Please note that the Pulumi plugin for ThreeFold Grid is not yet officially published. We look forward to your feedback on this project.
## Check All the Examples
In the manual, we cover some basic examples of Pulumi deployments on the grid.
You can access all the Pulumi deployment examples on the ThreeFold Pulumi repository [here](https://github.com/threefoldtech/pulumi-threefold/tree/development/examples).
## Prerequisites
There are a few things to set up before exploring Pulumi. Since we will be using the examples in the ThreeFold Pulumi repository, we must clone the repository before going further.
@@ -83,7 +89,3 @@ You can destroy your Pulumi deployment at any time with the following make comma
```
make destroy
```
## Questions and Feedback
If you have any questions, you can ask the ThreeFold community for help on the [ThreeFold Forum](http://forum.threefold.io/) or on the [ThreeFold Grid Tester Community](https://t.me/threefoldtesting) on Telegram.

View File

@@ -8,13 +8,13 @@ With Pulumi, you can express your infrastructure requirements using the language
- [Benefits of Using Pulumi](#benefits-of-using-pulumi)
- [Declarative vs. Imperative Programming](#declarative-vs-imperative-programming)
- [Declaration Programming Example](#declaration-programming-example)
- [Benefits of declarative programming in IaC](#benefits-of-declarative-programming-in-iac)
- [Benefits of Declarative Programming in IaC](#benefits-of-declarative-programming-in-iac)
- [Concepts](#concepts)
- [Pulumi Project](#pulumi-project)
- [Project File](#project-file)
- [Stacks](#stacks)
- [Resources](#resources)
- [Questions and Feedback](#questions-and-feedback)
- [Pulumi Registry](#pulumi-registry)
***
@@ -22,7 +22,7 @@ With Pulumi, you can express your infrastructure requirements using the language
[ThreeFold Grid](https://threefold.io) is a decentralized cloud infrastructure platform that provides developers with a secure and scalable way to deploy and manage their applications. It is based on a peer-to-peer network of nodes that are distributed around the world.
[Pulumi](https://www.pulumi.com/) is a cloud-native infrastructure as code (IaC) platform that allows developers to manage their infrastructure using code. It supports a wide range of cloud providers, including ThreeFold Grid.
[Pulumi](https://www.pulumi.com/) is a cloud-native infrastructure as code (IaC) platform that allows developers to manage their infrastructure using code. It supports a wide range of cloud providers, including ThreeFold Grid. Consult the official [Pulumi documentation](https://www.pulumi.com/docs/) for more information.
The [Pulumi plugin for ThreeFold Grid](https://github.com/threefoldtech/pulumi-provider-grid) provides developers with a way to deploy and manage their ThreeFold Grid resources using Pulumi. This means that developers can benefit from all of the features and benefits that Pulumi offers, such as cross-cloud support, type safety, preview and diff, and parallel execution -still in the works-.
@@ -55,7 +55,7 @@ Say I want an infrastructure of two virtual machines with X disks. The following
As you can see, the declarative code is much simpler and easier to read. It also makes it easier to make changes to your infrastructure, as you only need to change the desired state, and the IaC tool will figure out how to achieve it.
### Benefits of declarative programming in IaC
### Benefits of Declarative Programming in IaC
There are several benefits to using declarative programming in IaC:
@@ -125,6 +125,6 @@ resources:
options: ...options
```
## Questions and Feedback
## Pulumi Registry
If you have any questions, you can ask the ThreeFold community for help on the [ThreeFold Forum](http://forum.threefold.io/) or on the [ThreeFold Grid Tester Community](https://t.me/threefoldtesting) on Telegram.
You can visit the Pulumi registry to access the ThreeFold package [here](https://www.pulumi.com/registry/packages/threefold/).

View File

@@ -9,4 +9,5 @@ In this section, we will explore the dynamic world of infrastructure as code (Ia
- [Introduction to Pulumi](pulumi_intro.md)
- [Installing Pulumi](pulumi_install.md)
- [Deployment Examples](pulumi_examples.md)
- [Deployment Details](pulumi_deployment_details.md)
- [Deployment Details](pulumi_deployment_details.md)
- [Complete Guides](pulumi_complete_guides_toc.md)