Premix Deployment Automation

repository·main·Indexed 41 days ago

https://github.com/geek-cookbook/premix

A deployment automation layer for the Geek Cookbook that provides pre-configured Docker Compose files and Ansible playbooks for quickly deploying Docker Swarm and Kubernetes-based services. It includes Helm charts for applications like Huginn and autopirate, as well as recipes for Bitwarden, Dex, and FileBrowser.

Tokens
6.7K
Snippets
21
Records
31
Agent score
97%

What's inside Premix

  1. What is Premix?

    main

    Premix is a deployment toolkit designed to fast-track the deployment of Docker Swarm and Kubernetes recipes from the Geek Cookbook. It provides opinionated configurations to simplify infrastructure setup.

    The repository contains:

    • Standard docker-compose files for each cookbook recipe.
    • Ansible playbooks for automated deployment of the entire stack and popular recipes.
  2. Understand FileBrowser volume mapping and data access

    main
    In this implementation, FileBrowser manages files by browsing a volume provided from the container's host. The directory mapped in the YAML configuration is bound to /srv inside the container. This allows you to manage any host directory (such as Docker Swarm configs) through the web interface.
  3. Verify Turtlecoin (TRTL) Deployment Status

    main

    After running the setup commands, verify that all pods, services, and ingresses are running correctly in the trtl namespace using kubectl.

    Expected Pods: daemon, pool, redis, and wallet should be in Running status. Expected Services: daemon, pool-mining-nodeport, pool-ui, redis, and wallet should be present. Expected Ingress: trtl-pool should be configured with the appropriate hosts.

    # Check pods
    kubectl get pods -n trtl
    
    # Check services
    kubectl get services -n trtl
    
    # Check ingress
    kubectl get ingress -n trtl
  4. Configure Traefik to proxy to a non-Docker service via Traefik.toml

    main

    If you need Traefik to proxy requests for a Fully Qualified Domain Name (FQDN) to a service running directly on the host machine (e.g., a service requiring direct hardware/USB access) rather than in a Docker container, you can use the [file] provider in your Traefik.toml configuration.

    To do this, you must enable the [file] section with watch=true and define your frontends and backends manually.

    [file]
    watch=true
    
    [frontends]
      [frontends.ipp]
      backend = "ipp"
      pastHostHeader = true
        [frontends.ipp.routes.1]
        rule = "Host:ipp.example.com"
    
    [backends]
      [backends.ipp]
        [backends.ipp.servers.ipp1]
        url = "http://192.168.1.4:4679" # local address of the service
  5. Proxy a non-Docker service through OAuth2 Proxy in Docker Swarm

    main

    If the non-Docker service requires authentication, you can deploy an oauth2_proxy service within a Docker Swarm stack. This proxy acts as the bridge: Traefik routes traffic to the proxy via Docker labels, and the proxy forwards authenticated requests to the external service via the -upstream flag.

    Steps:

    1. Create a Docker Compose file (e.g., /var/data/config/ipp.yml) defining the proxy service.
    2. Use traefik.frontend.rule and traefik.port labels to tell Traefik how to route traffic to the proxy.
    3. Configure the oauth2_proxy command with -upstream pointing to the host service's URL.
    4. Deploy the stack using docker stack deploy.
    version: "3.2"
    
    services:
      proxy:
        image: funkypenguin/oauth2_proxy
        env_file: /var/data/config/ipp/ipp.env
        networks:
          - traefik_public
        volumes:
          - /etc/localtime:/etc/localtime:ro
        deploy:
          labels:
            - traefik.frontend.rule=Host:ipp.example.com
            - traefik.docker.network=traefik_public
            - traefik.port=4180
        command: |
          -cookie-secure=false
          -upstream=http://192.168.1.4:4679
          -redirect-url=https://ipp.example.com
          -http-address=http://0.0.0.0:4180
          -email-domain=gmail.com
          -provider=github
          -authenticated-emails-file=/authenticated-emails.txt
    
    networks:
      traefik_public:
        external: true

    To deploy:

    docker stack deploy ipp -c /var/data/config/ipp.yml
  6. Set up Dex manually

    main

    To deploy Dex manually, follow these steps to prepare the configuration and database directories before deploying the stack:

    1. Create the configuration directory: /var/data/dex/config/.
    2. Initialize the configuration: Copy config.yml.example to /var/data/dex/config/config.yml.
    3. Prepare the database directory: Create /var/data/dex/db and ensure the directory is writable by the user running the dex process (e.g., using chmod to set appropriate permissions).
    4. Deploy the stack using Docker Swarm.
    mkdir -p /var/data/dex/config/
    cp config.yml.example /var/data/dex/config/config.yml
    mkdir -p /var/data/dex/db
    chmod 777 /var/data/dex/db # Use with caution
    docker stack deploy dex -c /var/data/config/dex/dex.yml
  7. Prerequisites for Turtlecoin (TRTL) Mining Pool Setup

    main

    Before deploying the Turtlecoin (TRTL) mining pool to Kubernetes, ensure you have the following infrastructure in place:

    1. A Kubernetes cluster already configured.
    2. A Load Balancer (refer to the geek-cookbook loadbalancer guide).
    3. A Traefik Ingress controller (refer to the geek-cookbook traefik guide).
  8. Configure the hosts file

    main

    The hosts file defines your target environment.

    1. Copy the template: cp hosts.example hosts.
    2. Customize the hosts file for your specific environment.
    3. Important: Comment out the sections you do not intend to use (e.g., if you are using k3s, comment out the swarm section).

    Note: The hosts file is ignored by .gitignore.

    cp hosts.example hosts
  9. Configure Traefik to proxy to a non-Docker service using Traefik.toml

    main

    If you need Traefik to proxy requests to a service running directly on the host machine (e.g., a service requiring direct hardware/USB access) rather than in a Docker container, you can use the [file] provider in your Traefik.toml.

    To do this, you must:

    1. Enable the [file] section with watch=true.
    2. Define a [frontends] entry with a rule (e.g., Host:ipp.example.com).
    3. Define a [backends] entry that points to the specific IP address and port of the host service.
    [file]
    watch=true
    
    [frontends]
      [frontends.ipp]
      backend = "ipp"
      pastHostHeader = true
        [frontends.ipp.routes.1]
        rule = "Host:ipp.example.com"
    
    [backends]
      [backends.ipp]
        [backends.ipp.servers.ipp1]
        url = "http://192.168.1.4:4679" # local address of the service