|
| 1 | +# Setup a Remote Exporter/Client |
| 2 | + |
| 3 | +This guide walks you through the process of creating an exporter using the |
| 4 | +controller service, configuring drivers, and running the exporter. |
| 5 | + |
| 6 | +## Prerequisites |
| 7 | + |
| 8 | +Make sure the following packages are installed in your Python environment: |
| 9 | +- `jumpstarter-cli` - The core Jumpstarter CLI. |
| 10 | +- `jumpstarter-driver-opendal` - The OpenDAL storage driver. |
| 11 | +- `jumpstarter-driver-power` - The base power driver. |
| 12 | + |
| 13 | +You should also have the [Jumpstarter Service](../introduction/service.md) |
| 14 | +running in a Kubernetes cluster you have admin access to. |
| 15 | +For instructions on how to install Jumpstarter in a cluster, |
| 16 | +refer to the [installation guide](../installation/service/index.md). |
| 17 | + |
| 18 | +```{tip} |
| 19 | +Make sure you have the correct cluster in your `kubeconfig` file and the right |
| 20 | +context selected. |
| 21 | +``` |
| 22 | + |
| 23 | +## Create an Exporter |
| 24 | + |
| 25 | +First, we must create an exporter using the controller service API. |
| 26 | +The `jmp admin` CLI provides methods to interact with the controller directly. |
| 27 | + |
| 28 | +To create an exporter and save the config locally, run the following command: |
| 29 | + |
| 30 | +```bash |
| 31 | +# Creates an exporter called "testing" and saves the config |
| 32 | +$ jmp admin create exporter testing --save |
| 33 | + |
| 34 | +# Usage for jmp admin create exporter |
| 35 | +$ jmp admin create exporter |
| 36 | + --help |
| 37 | +Usage: jmp admin create exporter [OPTIONS] [NAME] |
| 38 | + |
| 39 | + Create an exporter object in the Kubernetes cluster |
| 40 | + |
| 41 | +Options: |
| 42 | + -s, --save Save the config file for the created exporter. |
| 43 | + -o, --out FILE Specify an output file for the exporter config. |
| 44 | + -n, --namespace TEXT Kubernetes namespace to use |
| 45 | + --kubeconfig FILENAME path to the kubeconfig file |
| 46 | + --context TEXT Kubernetes context to use |
| 47 | + --help Show this message and exit. |
| 48 | +``` |
| 49 | + |
| 50 | +### Edit the Exporter Config |
| 51 | + |
| 52 | +Once the exporter has been created, a new config file will be saved to |
| 53 | +`/etc/jumpstarter/exporters/testing.yaml`. |
| 54 | + |
| 55 | +To edit the config file with your default text editor, run the following command: |
| 56 | + |
| 57 | +```bash |
| 58 | +# Opens the config for "testing" in your default editor |
| 59 | +$ jmp exporter edit-config testing |
| 60 | +``` |
| 61 | + |
| 62 | +Add the `storage` and `power` drivers under the `export` field in the config file. |
| 63 | +The finished config should look like this: |
| 64 | + |
| 65 | +```yaml |
| 66 | +# /etc/jumpstarter/exporters/testing.yaml |
| 67 | +apiVersion: jumpstarter.dev/v1alpha1 |
| 68 | +kind: ExporterConfig |
| 69 | +# These values are automatically filled by the controller |
| 70 | +endpoint: "..." |
| 71 | +token: "..." |
| 72 | +# Mock drivers for demo purpose |
| 73 | +export: |
| 74 | + storage: |
| 75 | + type: jumpstarter_driver_opendal.driver.MockStorageMux |
| 76 | + power: |
| 77 | + type: jumpstarter_driver_power.driver.MockPower |
| 78 | +``` |
| 79 | +
|
| 80 | +## Run an Exporter |
| 81 | +
|
| 82 | +To run the exporter locally, we can use the `jmp exporter` CLI tool. |
| 83 | + |
| 84 | +Run the following command to start the exporter locally using the config file: |
| 85 | + |
| 86 | +```bash |
| 87 | +# Runs the exporter "testing" locally |
| 88 | +$ jmp exporter run testing |
| 89 | +``` |
| 90 | + |
| 91 | +The exporter will stay running until the process is exited via `^C` or the shell |
| 92 | +is closed. |
| 93 | + |
| 94 | +## Create a Client |
| 95 | + |
| 96 | +To connect to the new exporter, a client must be created. We can also use the |
| 97 | +`jmp admin` CLI tool to create a client using the controller. |
| 98 | + |
| 99 | +```bash |
| 100 | +# This will create a client called "hello", allow unsafe drivers, and save the config |
| 101 | +$ jmp admin create client hello --save --unsafe |
| 102 | +
|
| 103 | +# Usage for jmp admin create client |
| 104 | +jmp admin create client --help |
| 105 | +Usage: jmp admin create client [OPTIONS] [NAME] |
| 106 | +
|
| 107 | + Create a client object in the Kubernetes cluster |
| 108 | +
|
| 109 | +Options: |
| 110 | + -s, --save Save the config file for the created client. |
| 111 | + -a, --allow TEXT A comma-separated list of driver client packages to |
| 112 | + load. |
| 113 | + --unsafe Should all driver client packages be allowed to load |
| 114 | + (UNSAFE!). |
| 115 | + -o, --out FILE Specify an output file for the client config. |
| 116 | + -n, --namespace TEXT Kubernetes namespace to use |
| 117 | + --kubeconfig FILENAME path to the kubeconfig file |
| 118 | + --context TEXT Kubernetes context to use |
| 119 | + --help Show this message and exit. |
| 120 | +``` |
| 121 | + |
| 122 | +## Connect to the Exporter |
| 123 | + |
| 124 | +To interact with the exporter we created above, we can use the |
| 125 | +"client shell" functionality within the `jmp` CLI. When a shell is spawned, |
| 126 | +the client attempts to acquire a lease on an exporter. Once the lease is acquired, |
| 127 | +the client can be interacted with through the magic `j` command or via the |
| 128 | +Python API. |
| 129 | + |
| 130 | +```bash |
| 131 | +# Spawn a shell using the "hello" client |
| 132 | +$ jmp client shell hello |
| 133 | +
|
| 134 | +# Usage for jmp client shell |
| 135 | +$ jmp client shell --help |
| 136 | +Usage: jmp client shell [OPTIONS] [NAME] |
| 137 | +
|
| 138 | + Spawns a shell connecting to a leased remote exporter |
| 139 | +
|
| 140 | +Options: |
| 141 | + -l, --label <TEXT TEXT>... |
| 142 | + -n, --lease TEXT |
| 143 | + --help Show this message and exit. |
| 144 | +``` |
| 145 | + |
| 146 | +Once a lease is acquired, we can interact with the drivers hosted by the exporter |
| 147 | +within the shell instance. |
| 148 | + |
| 149 | +```bash |
| 150 | +# Spawn a shell using the "hello" client |
| 151 | +$ jmp client shell hello |
| 152 | +
|
| 153 | +# Running inside client shell |
| 154 | +$ j |
| 155 | +Usage: j [OPTIONS] COMMAND [ARGS]... |
| 156 | +
|
| 157 | + Generic composite device |
| 158 | +
|
| 159 | +Options: |
| 160 | + --help Show this message and exit. |
| 161 | +
|
| 162 | +Commands: |
| 163 | + power Generic power |
| 164 | + storage Generic storage mux |
| 165 | +
|
| 166 | +# Simulate turning on the power |
| 167 | +$ j power on |
| 168 | +ok |
| 169 | +
|
| 170 | +# Exit the shell |
| 171 | +$ exit |
| 172 | +``` |
0 commit comments