Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using "Hello world" as the first good workflow #85

Merged
merged 5 commits into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ provisioning workflows, that is...
- [Fluent Bit](docs/components.md#fluent-bit)
- [Kibana](docs/components.md#kibana)
- [Architecture](docs/architecture.md)
- [Example: First Good Workflow](docs/first-good-workflow.md)
- [Say "Hello-World!" with a Workflow](docs/hello-world.md)
- [Concepts](docs/concepts.md)
- [Template](docs/concepts.md#template)
- [Target](docs/concepts.md#target)
Expand Down
6 changes: 0 additions & 6 deletions cli/tink/sample.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@ tasks:
- name: "server_partitioning"
image: hello-world
timeout: 60
on-timeout: do_partion recover -timeout
on-failure: do_partion recover -failure
volumes:
- ./host-path:/container-path
environment:
key: value
- name: os_install
image: hello-world
timeout: 60
on-timeout: "os_install -timeout"
on-failure: "os_install -failure"
- name: "Updated DB Entries"
worker: "{{index .Targets "machine1" "mac_addr"}}"
actions:
- name: "update_db"
image: hello-world
timeout: 50
on-timeout: "tinkerbell_client update-timeout"
on-failure: "tinkerbell_client update-failed"
10 changes: 10 additions & 0 deletions docs/examples/hello-world.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: '0.1'
name: hello_world_workflow
global_timeout: 600
tasks:
- name: "hello world"
worker: "{{index .Targets "machine1" "mac_addr"}}"
actions:
- name: "hello_world"
image: hello-world
timeout: 60
49 changes: 0 additions & 49 deletions docs/first-good-workflow.md

This file was deleted.

78 changes: 78 additions & 0 deletions docs/hello-world.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Say Hello World! with a Workflow

Here is an example to execute the most simple workflow that says "Hello World!".

### Prerequisite

You have a setup ready with a provisioner and a worker node. If not, please follow the steps [here](setup.md) to complete the setup.

### Hardware Data

While the data model changes are in progress, the following data should be enough to get your workflow rolling at the moment:
```json
{
"id": "ce2e62ed-826f-4485-a39f-a82bb74338e2", // hardware UUID
"arch": "x86_64",
"allow_pxe": true,
"allow_workflow": true, // to boot into workflow mode
"facility_code": "onprem",
"ip_addresses": [
{
"address": "192.168.1.5", // IP to hand out
"address_family": 4,
"enabled": true,
"gateway": "192.168.1.1", // gateway address
"management": true,
"netmask": "255.255.255.248",
"public": false
}
],
"network_ports": [
{
"data": {
"mac": "ec:0d:9a:bf:ff:dc" // worker mac address
},
"name": "eth0",
"type": "data"
}
]
}
```

Now that we have the hardware data, we need to push it into the database. In order to do so, remove the extra spaces in the above JSON and use the following command to push the data:
```
$ tink hardware push '<json-data-here>'
```

Verify that the data was actually pushed using the command:
```shell
$ tink hardware mac <worker-mac-address>
```

### Action images

The workflow will have a single task that will have a single action. The action here is to say `Hello-world!`, so we will push the action image to the registry running on the provisioner:
```shell
$ docker pull hello-world
$ docker tag hello-world <registry-host>/hello-world
$ docker push <registry-host>/hello-world
```

### Workflow

We can now define a workflow with the following steps:
- Create a target:
```shell
$ tink target create '{"targets": {"machine1": {"mac_addr": "<worker-mac-address>"}}}'
```
- Create a template:
```shell
# get the template from examples/hello-world.tmpl and save it
$ tink template create -n hello-world -p hello-world.tmpl
```
- Create a workflow:
```shell
$ tink workflow create -t <template-uuid> -r <target-uuid>
```
- Reboot the worker machine

37 changes: 4 additions & 33 deletions docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,6 @@ Now, you can execute the setup with the following command:
$ curl https://raw.githubusercontent.com/tinkerbell/tink/master/setup.sh | bash
```

### Good to know
- All the environment variables are kept in the `envrc` file, which is generated from the setup itself.
- It is advised that you keep all the environment variables in the same file.
- It is important to note that if you execute the setup the again, a new `envrc` will be generated. However, the existing environment configuration be saved as `envrc.bak`.
- The setup removes all the `.tar.gz` files downloaded in process.

# Setup the Provisioner

### Prerequisites
- The setup must be executed as a privileged or root user.
- The setup downloads about 1.5GB of assets, therefore, it is advised to have a minimum of 10GB disk space available before you begin.

### Interactive Mode
Execute the following commands to bring up the Tinkerbell stack with an interactive setup:
```shell
$ wget https://raw.githubusercontent.com/tinkerbell/tink/master/setup.sh && chmod +x setup.sh
$ ./setup.sh
```

### Declarative Mode
You can also execute the setup in declarative mode. In order to do so, define the following environment variables (examples here):
```shell
export TB_INTERFACE=network-interface # enp1s0f1
export TB_NETWORK=network-with-cidr # 192.168.1.0/29
export TB_IPADDR=provisioner-ip-address # 192.168.1.1
export TB_REGUSER=registry-username # admin
```

Now, you can execute the setup with the following command:
```shell
$ curl https://raw.githubusercontent.com/tinkerbell/tink/master/setup.sh | bash
```

### Good to know
- All the environment variables are kept in the `envrc` file, which is generated from the setup itself.
- It is advised that you keep all the environment variables in the same file.
Expand All @@ -77,3 +44,7 @@ The script was tested with:
export TB_IPADDR=192.168.1.1
export TB_REGUSER=admin
```
- Command:
```shell
$ curl https://raw.githubusercontent.com/tinkerbell/tink/master/setup.sh | bash
```
28 changes: 0 additions & 28 deletions envrc

This file was deleted.

6 changes: 0 additions & 6 deletions registry/Dockerfile

This file was deleted.

1 change: 1 addition & 0 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ setup_networking() {
echo -e "\nauto $TINKERBELL_NETWORK_INTERFACE\n" >> /etc/network/interfaces
write_iface_config
fi
ip link set $TINKERBELL_NETWORK_INTERFACE nomaster
ifdown "$TINKERBELL_NETWORK_INTERFACE:0"
ifdown "$TINKERBELL_NETWORK_INTERFACE:1"
ifup "$TINKERBELL_NETWORK_INTERFACE:0"
Expand Down