From cb7dd981bf25387c6138417d3c752ceffcb194bd Mon Sep 17 00:00:00 2001 From: Xavier Logerais Date: Sun, 28 Sep 2025 17:39:46 +0200 Subject: [PATCH] feat: Improve documentation and add example scripts --- docs/create-docker-container.md | 51 +++++++++++++++++++++++ docs/create-microk8s-container.md | 52 ++++++++++++++++++++++++ docs/create-traefik-container.md | 58 +++++++++++++++++++++++++++ docs/lxd-create-microk8s.bash | 19 --------- docs/lxd-create-traefik.md | 15 ------- examples/scripts/create-docker.bash | 18 +++++++++ examples/scripts/create-microk8s.bash | 18 +++++++++ examples/scripts/create-traefik.bash | 18 +++++++++ 8 files changed, 215 insertions(+), 34 deletions(-) create mode 100644 docs/create-docker-container.md create mode 100644 docs/create-microk8s-container.md create mode 100644 docs/create-traefik-container.md delete mode 100644 docs/lxd-create-microk8s.bash delete mode 100644 docs/lxd-create-traefik.md create mode 100755 examples/scripts/create-docker.bash create mode 100755 examples/scripts/create-microk8s.bash create mode 100755 examples/scripts/create-traefik.bash diff --git a/docs/create-docker-container.md b/docs/create-docker-container.md new file mode 100644 index 0000000..9ca845b --- /dev/null +++ b/docs/create-docker-container.md @@ -0,0 +1,51 @@ +# Create Docker Container + +## Install Profile + +Install the docker profile : + +```bash +lxc profile create docker +curl https://gitea.cloud.logerais.com/cloud.logerais.com/lxd-profiles/raw/branch/main/profiles/containerization/docker.profile.yaml | lxc profile edit docker +``` + +Or use the local profile: + +```bash +./install.bash profiles/containerization/docker.profile.yaml +``` + +## Launch Container + +Create and start a Docker container: + +```bash +lxc launch ubuntu:lts -p default -p docker docker-container +``` + +### Fix IP Address (Optional) + +To assign a static IP address: + +```bash +lxc network attach lxdbr0 docker-container eth0 eth0 +lxc config device set docker-container eth0 ipv4.address 10.0.1.10 +``` + +## Use the Container + +Access the container and verify Docker installation: + +```bash +# Wait for cloud-init to complete +lxc exec docker-container -- cloud-init status --wait + +# Access the container +lxc shell docker-container + +# Inside the container - verify Docker is running +docker --version +docker run hello-world +``` + +Your Docker container is now ready for use with Docker already installed and configured. diff --git a/docs/create-microk8s-container.md b/docs/create-microk8s-container.md new file mode 100644 index 0000000..af8061e --- /dev/null +++ b/docs/create-microk8s-container.md @@ -0,0 +1,52 @@ +# Create MicroK8s Container + +## Install Profile + +Install the microk8s profile : + +```bash +lxc profile create microk8s +curl https://gitea.cloud.logerais.com/cloud.logerais.com/lxd-profiles/raw/branch/main/profiles/containerization/microk8s.profile.yaml | lxc profile edit microk8s +``` + +Or use the local profile: + +```bash +./install.bash profiles/containerization/microk8s.profile.yaml +``` + +## Launch Container + +Import the base image and create the container: + +```bash +# Create and start the container +lxc launch ubuntu:lts -p default -p microk8s microk8s-container +``` + +### Fix IP Address (Optional) + +To assign a static IP address: + +```bash +lxc network attach lxdbr0 microk8s-container eth0 eth0 +lxc config device set microk8s-container eth0 ipv4.address 10.0.2.10 +``` + +## Use the Container + +Access the container and verify MicroK8s installation: + +```bash +# Wait for cloud-init to complete +lxc exec microk8s-container -- cloud-init status --wait + +# Access the container +lxc shell microk8s-container + +# Inside the container - MicroK8s is already installed via the profile +microk8s status --wait-ready +microk8s kubectl get nodes +``` + +Your MicroK8s container is now ready for Kubernetes workloads. The profile handles the MicroK8s installation automatically. diff --git a/docs/create-traefik-container.md b/docs/create-traefik-container.md new file mode 100644 index 0000000..af6d293 --- /dev/null +++ b/docs/create-traefik-container.md @@ -0,0 +1,58 @@ +# Create Traefik Container + +## Install Profile + +Install the traefik profile : + +```bash +lxc profile create traefik +curl https://gitea.cloud.logerais.com/cloud.logerais.com/lxd-profiles/raw/branch/main/profiles/applications/traefik.profile.yaml | lxc profile edit traefik +``` + +Or use the local profile: + +```bash +./install.bash profiles/applications/traefik.profile.yaml +``` + +## Launch Container + +Create the container with required profiles: + +```bash +# Create the container (without starting) +lxc init ubuntu:lts -p default -p traefik traefik-container + +# Or with additional profiles for production use: +# lxc init ubuntu:lts -p default -p zfs -p net-front -p traefik -p traefik-volume-config traefik-container +``` + +### Fix IP Address (Optional) + +To assign a static IP address: + +```bash +lxc network attach lxdbr0 traefik-container eth0 eth0 +lxc config device set traefik-container eth0 ipv4.address 10.0.3.10 +``` + +## Start and Use the Container + +Start the container and verify the setup: + +```bash +# Start the container +lxc start traefik-container + +# Wait for cloud-init to complete +lxc exec traefik-container -- cloud-init status --wait + +# Access the container +lxc shell traefik-container + +# Inside the container - Traefik is configured via the profile +# Check if Traefik service is running +systemctl status traefik +``` + +Your Traefik container is now ready to serve as a reverse proxy. The profile handles the Traefik installation and basic configuration automatically. diff --git a/docs/lxd-create-microk8s.bash b/docs/lxd-create-microk8s.bash deleted file mode 100644 index f0b8205..0000000 --- a/docs/lxd-create-microk8s.bash +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# See https://microk8s.io/docs/install-lxd - -lxc profile create microk8s -curl https://raw.githubusercontent.com/ubuntu/microk8s/master/tests/lxc/microk8s.profile | lxc profile edit microk8s - -# Import the baseimage -lxc image copy ubuntu:lts local: --auto-update --copy-aliases - -# Create an instance -lxc launch -p default -p microk8s ubuntu:lts microk8s - -# Fix the ip address -lxc network attach lxdbr0 microk8s eth0 eth0 -lxc config device set microk8s eth0 ipv4.address 10.162.242.10 - -# Install microk8s inside the container -lxc exec microk8s -- sudo snap install microk8s --classic diff --git a/docs/lxd-create-traefik.md b/docs/lxd-create-traefik.md deleted file mode 100644 index 62f9442..0000000 --- a/docs/lxd-create-traefik.md +++ /dev/null @@ -1,15 +0,0 @@ -## Create traefik instance - -### Create container -lxc init ubuntu:lts -p default -p zfs -p front -p traefik -p letsencrypt traefik - -### Fix ip address -lxc network attach front traefik eth0 eth0 -lxc config device set traefik eth0 ipv4.address 10.112.16.10 - -### Start it -lxc start traefik - -### Check it -lxc exec traefik -- cloud-init status --wait -lxc shell traefik \ No newline at end of file diff --git a/examples/scripts/create-docker.bash b/examples/scripts/create-docker.bash new file mode 100755 index 0000000..2777324 --- /dev/null +++ b/examples/scripts/create-docker.bash @@ -0,0 +1,18 @@ +#!/bin/bash + +CONTAINER_NAME="${1:-docker-container}" + +echo "Creating Docker container: $CONTAINER_NAME" + +# Install the profile using the helper script +./install.bash profiles/containerization/docker.profile.yaml + +# Launch the container +lxc launch ubuntu:lts -p default -p docker "$CONTAINER_NAME" + +# Wait for cloud-init +echo "Waiting for cloud-init to complete..." +lxc exec "$CONTAINER_NAME" -- cloud-init status --wait + +echo "Docker container '$CONTAINER_NAME' is ready!" +echo "Access with: lxc shell $CONTAINER_NAME" diff --git a/examples/scripts/create-microk8s.bash b/examples/scripts/create-microk8s.bash new file mode 100755 index 0000000..875849c --- /dev/null +++ b/examples/scripts/create-microk8s.bash @@ -0,0 +1,18 @@ +#!/bin/bash + +CONTAINER_NAME="${1:-microk8s-container}" + +echo "Creating microk8s container: $CONTAINER_NAME" + +# Install the profile using the helper script +./install.bash profiles/containerization/microk8s.profile.yaml + +# Launch the container +lxc launch ubuntu:lts -p default -p microk8s "$CONTAINER_NAME" + +# Wait for cloud-init +echo "Waiting for cloud-init to complete..." +lxc exec "$CONTAINER_NAME" -- cloud-init status --wait + +echo "microk8s container '$CONTAINER_NAME' is ready!" +echo "Access with: lxc shell $CONTAINER_NAME" diff --git a/examples/scripts/create-traefik.bash b/examples/scripts/create-traefik.bash new file mode 100755 index 0000000..8c6145c --- /dev/null +++ b/examples/scripts/create-traefik.bash @@ -0,0 +1,18 @@ +#!/bin/bash + +CONTAINER_NAME="${1:-traefik-container}" + +echo "Creating Traefik container: $CONTAINER_NAME" + +# Install the profile using the helper script +./install.bash profiles/applications/traefik.profile.yaml + +# Launch the container +lxc launch ubuntu:lts -p default -p traefik "$CONTAINER_NAME" + +# Wait for cloud-init +echo "Waiting for cloud-init to complete..." +lxc exec "$CONTAINER_NAME" -- cloud-init status --wait + +echo "Traefik container '$CONTAINER_NAME' is ready!" +echo "Access with: lxc shell $CONTAINER_NAME"