-
Notifications
You must be signed in to change notification settings - Fork 3
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
ZOS Boot Generator Flist (Grid Stack Suite Part 2 of 3) #275
Closed
Closed
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7dacaff
added draft of zos boot generator
mik-tf b6bc9ad
updated python yaml script
mik-tf b87a66a
test update for zos boot generator
mik-tf 366dba6
updated boot gen
mik-tf 9761bc6
fixed yaml caddy
mik-tf 6e22072
Update README.md
mik-tf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
FROM ubuntu:22.04 | ||
|
||
RUN dpkg --add-architecture i386 | ||
|
||
RUN apt update && \ | ||
echo "2" | apt install -y python3-flask && \ | ||
apt install -y mtools syslinux isolinux libc6-dev-i386 ufw \ | ||
libc6-dbg:i386 git wget genisoimage liblzma-dev build-essential sqlite3 \ | ||
openssh-server curl sudo inotify-tools iproute2 | ||
|
||
RUN wget -O /sbin/zinit https://github.com/threefoldtech/zinit/releases/download/v0.2.5/zinit && \ | ||
chmod +x /sbin/zinit | ||
|
||
RUN wget -O /sbin/caddy 'https://caddyserver.com/api/download?os=linux&arch=amd64&p=github.com%2Fcaddyserver%2Freplace-response&idempotency=43631173212363' && \ | ||
chmod +x /sbin/caddy | ||
|
||
RUN mkdir -p /code && \ | ||
cd /code && \ | ||
git clone https://github.com/threefoldtech/0-bootstrap && \ | ||
cd 0-bootstrap && \ | ||
bash setup/template.sh | ||
|
||
COPY ./scripts/ /scripts/ | ||
COPY ./zinit/ /etc/zinit/ | ||
RUN chmod +x /scripts/*.sh | ||
|
||
ENTRYPOINT ["/sbin/zinit", "init"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<h1> Z-OS Boot Generator </h1> | ||
|
||
<h2> Table of Contents </h2> | ||
|
||
- [Introduction](#introduction) | ||
- [Create the Docker Image](#create-the-docker-image) | ||
- [Convert the Docker Image to Zero-OS FList](#convert-the-docker-image-to-zero-os-flist) | ||
- [TFGrid Deployment](#tfgrid-deployment) | ||
- [Dashboard Steps](#dashboard-steps) | ||
- [Set the DNS Record for Your Domain](#set-the-dns-record-for-your-domain) | ||
- [Access the Z-OS Bootstrap Generator](#access-the-z-os-bootstrap-generator) | ||
- [Conclusion](#conclusion) | ||
|
||
*** | ||
|
||
## Introduction | ||
|
||
This Z-OS Boot Generator FList can be deployed on a micro VM on the ThreeFold Grid, either via the TF Dashboard, or Terraform. This FList uses `Ubuntu 22.04` and also includes the preinstalled `openssh-server` package. Docker is installed directly from [www.get.docker.com](https://get.docker.com/). This FList Z-OS Boot Generator is installed based on the latest Z-OS Boot Generator release from the Docker Hub. | ||
|
||
To simply deploy the available FList on the ThreeFold Dashboard, skip to [this section](#dashboard-steps). | ||
|
||
<!-- | ||
Note that the official FList for Z-OS Boot Generator is the following: | ||
|
||
``` | ||
https://hub.grid.tf/tf-official-apps/threefoldtech-zos_boot_generator-latest.flist | ||
``` | ||
--> | ||
|
||
*** | ||
|
||
## Create the Docker Image | ||
|
||
To create the the Z-OS Boot Generator image, clone this repository, then build and push the image to the Docker Hub. | ||
|
||
* Clone the repository: | ||
* ``` | ||
git clone https://github.com/threefoldtech/tf-images | ||
``` | ||
* ``` | ||
cd tf-images/tfgrid3/zos_boot_generator | ||
``` | ||
* Build the image: | ||
* ``` | ||
docker build -t <docker_username>/zos_boot_generator . | ||
``` | ||
* Push the image to the Docker Hub: | ||
* ``` | ||
docker push <your_username>/zos_boot_generator | ||
``` | ||
|
||
*** | ||
|
||
## Convert the Docker Image to Zero-OS FList | ||
|
||
The easiest way to convert the docker image to an FList is by using the [Docker Hub Converter Tool](https://hub.grid.tf/docker-convert). This can be done once you've built and pushed the docker image on the [Docker Hub](https://hub.docker.com/). | ||
|
||
> Note: A docker image has already been converted to an FList (see below). | ||
|
||
* Go to the [ThreeFold Hub](https://hub.grid.tf/). | ||
* Sign in with the ThreeFold Connect app. | ||
* Go to the [Docker Hub Converter](https://hub.grid.tf/docker-convert) section. | ||
* Next to `Docker Image Name`, add the docker image repository and name, see the example below: | ||
* Template: | ||
* `<docker_username>/docker_image_name:tagname` | ||
* Click `Convert the docker image`. | ||
* Once the conversion is done, the FList is available as a public link on the ThreeFold Hub. | ||
* To get the FList URL, go to the [TF Hub main page](https://hub.grid.tf/), scroll down to your 3Bot ID and click on it. | ||
* Under `Name`, you will see all your available FLists. | ||
* Right-click on the FList you want and select `Copy Clean Link`. This URL will be used when deploying on the ThreeFold Dashboard. We show below the template and an example of what the FList URL looks like. | ||
* Template: | ||
* ``` | ||
https://hub.grid.tf/<3BOT_name.3bot>/<docker_username>-<docker_image_name>-<tagname>.flist | ||
``` | ||
|
||
*** | ||
## TFGrid Deployment | ||
|
||
The easiest way to deploy a micro VM using the Z-OS Boot Generator FList is to head to to the [ThreeFold Dashboard](https://dashboard.grid.tf) and deploy a [Micro Virtual Machine](https://dashboard.grid.tf/#/deploy/virtual-machines/micro-virtual-machine/) by providing the FList URL. Make sure to select `IPv4`. | ||
|
||
Make sure to provide the correct entrypoint (`/sbin/zinit init`). Note that the entrypoint should already be set by default when you open the micro VM page. | ||
|
||
You could also use Terraform instead of the Dashboard to deploy the Z-OS Boot Generator Micro VM. Read more on this [here](https://github.com/threefoldtech/terraform-provider-grid). | ||
|
||
### Dashboard Steps | ||
|
||
* Go to the [ThreeFold Dashboard](https://dashboard.grid.tf) | ||
* Log into your TF wallet | ||
* Go to the [Micro VM](https://dashboard.grid.tf/#/deploy/virtual-machines/micro-virtual-machine/) page | ||
* In the section `Config`, | ||
* Choose a name for your VM under `Name`. | ||
* Under `VM Image`, select `Other`. | ||
* Enter the Zero-OS Boot Generator FList under `Flist`: | ||
* Template: | ||
* ``` | ||
https://hub.grid.tf/<3BOT_name.3bot>/<docker_username>-<docker_image_name>-<tagname>.flist | ||
``` | ||
* Example: | ||
* ``` | ||
https://hub.grid.tf/tf-official-apps/threefoldtech-zos_boot_generator-latest.flist | ||
``` | ||
* Under `Entry Point`, the following should be set by default: `/sbin/zinit init` | ||
* `Select instance capacity` can be set at `Small` (1vcore, 2GB memory, 25GB SSd) | ||
* Make sure that `Public IPv4` is enabled (required). | ||
* In the tab `Environment Variables`. Click on the `plus` button then add `DOMAIN` for `Name` and your domain (e.g. `example.com`) for `Value`. | ||
* Click `Deploy`. | ||
|
||
### Set the DNS Record for Your Domain | ||
|
||
* Go to your domain name registrar (e.g. Namecheap) | ||
* In the section Advanced DNS, add a DNS A Record to your domain and link it to the VM IPv4 Address | ||
* Type: A Record | ||
* Host: @ | ||
* Value: VM IPv4 Address | ||
* TTL: Automatic | ||
* It might take up to 30 minutes to set the DNS properly. | ||
* To check if the A record has been registered, you can use a common DNS checker: | ||
* ``` | ||
https://dnschecker.org/#A/<domain-name> | ||
``` | ||
|
||
## Access the Z-OS Bootstrap Generator | ||
|
||
You can now access the Z-OS Bootstrap Generator at your domain, e.g. `https://example.com`. | ||
|
||
## Conclusion | ||
|
||
We've seen the overall process of creating a new FList to deploy a Z-OS Boot Generator workload on a Micro VM on the ThreeFold Dashboard. | ||
|
||
If you have any questions or feedback, please let us know by either writing a post on the [ThreeFold Forum](https://forum.threefold.io/), or by chatting with us on the [TF Grid Tester Community](https://t.me/threefoldtesting) Telegram channel. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
caddy reverse-proxy -r --from ${DOMAIN} --to :5555 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
cd /code/0-bootstrap | ||
|
||
python3 bootstrap.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
mkdir -p ~/.ssh | ||
mkdir -p /var/run/sshd | ||
chmod 600 ~/.ssh | ||
chmod 600 /etc/ssh/* | ||
echo $SSH_KEY >> ~/.ssh/authorized_keys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/bash | ||
|
||
ufw allow 80 | ||
ufw allow 443 | ||
ufw allow 22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
cd /code/0-bootstrap | ||
|
||
cp config.py.sample config.py | ||
|
||
domain_name=$(echo $DOMAIN | cut -d. -f1) | ||
domain_tld=$(echo $DOMAIN | cut -d. -f2) | ||
|
||
sed -i "s/http:\/\/default\.tld/https:\/\/$domain_name\.$domain_tld/g" config.py | ||
|
||
cat db/schema.sql | sqlite3 db/bootstrap.sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
exec: /scripts/caddy.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exec: /scripts/python.sh | ||
after: | ||
- zos_boot_generator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
exec: /scripts/sshd_init.sh | ||
oneshot: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exec: bash -c "/usr/sbin/sshd -D" | ||
after: | ||
- ssh-init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exec: /scripts/ufw_init.sh | ||
oneshot: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
exec: ufw --force enable | ||
oneshot: true | ||
after: | ||
- ufw-init |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
exec: /scripts/zos_boot_generator.sh | ||
oneshot: true | ||
after: | ||
- sshd |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check failure
Code scanning / Trivy
Image user should not be 'root' High