Skip to main content

tools to support builds combining gopass, terraform, dda-pallet, aws & hetzner-cloud

Project description

dda-devops-build

Slack | team@social.meissa-gmbh.de team@social.meissa-gmbh.de | Website & Blog

release prod

dda-devops-build integrates all the tools we use to work with clouds & provide some nice functions around.

Tools we support are

  • terraform: for setting up the plain infrastructure around.
  • docker: for creating images
  • c4k: for generating kubernetes manifests
  • provs: for setting up small single-node k3s clusters
  • gopass: for credential management on devops computers
  • cloud providers: hetzner, digitalocean, aws

In addition we provide a ReleaseMixin for release related tasks like tag / publish & version-bump

classDiagram
    class DevopsBuild {
        name()
        build_path()
        initialize_build_dir()
    }

    class DevopsTerraformBuild {
        initialize_build_dir()
        post_build()
        read_output_json()
        plan()
        plan_fail_on_diff()
        apply(auto_approve=False)
        refresh()
        destroy(auto_approve=False)
        tf_import(tf_import_name,tf_import_resource)
    }

    class DevopsImageBuild {
        initialize_build_dir()
        image()
        drun()
        dockerhub_login()
        dockerhub_publish()
        test()
    }

    class ReleaseMixin {
        prepare_release()
        tag_and_push_release()
    }
    
    class ProvsK3sBuild {
        def update_runtime_config(dns_record)
        write_provs_config()
        provs_apply(dry_run=False)
    }

    class C4kBuild {
        def update_runtime_config(dns_record)
        def write_c4k_config()
        def write_c4k_auth()
        c4k_apply(dry_run=False)
    }

    DevopsBuild <|-- DevopsImageBuild
    DevopsBuild <|-- DevopsTerraformBuild
    DevopsBuild <|-- ReleaseMixin
    DevopsBuild <|-- ProvsK3sBuild
    DevopsBuild <|-- C4kBuild

    link DevopsBuild "dda-devops-build/src/doc/DevopsBuild.md"
    link DevopsImageBuild "dda-devops-build/src/doc/DevopsImageBuild.md"
    link DevopsTerraformBuild "dda-devops-build/src/doc/DevopsTerraformBuild.md"
    link ReleaseMixin "dda-devops-build/src/doc/ReleaseMixin.md"
    link ProvsK3sBuild "dda-devops-build/src/doc/ProvsK3sBuild.md"
    link C4kBuild "dda-devops-build/src/doc/C4kBuild.md"

Principles we follow are:

  • Seperate build artefacts from version controlled code
  • Domain Driven Design - in order to stay sustainable

Installation

Ensure that yout python3 version is at least Python 3.10

sudo apt install python3-pip
pip3 install -r requirements.txt
export PATH=$PATH:~/.local/bin

Reference

Example Build

lets assume the following project structure

my-project
   | -> my-module
   |       | -> build.py
   |       | -> some-terraform.tf
   | -> an-other-module
   | -> target  (here will the build happen)
   |       | -> ...
from pybuilder.core import task, init
from ddadevops import *

name = 'my-project'
MODULE = 'my-module'
PROJECT_ROOT_PATH = '..'


@init
def initialize(project):
    project.build_depends_on("ddadevops>=4.0.0-dev")

    config = {
        "credentials_mapping": [
            {
                "gopass_path": environ.get("DIGITALOCEAN_TOKEN_KEY_PATH", None),
                "name": "do_api_key",
            },
            {
                "gopass_path": environ.get("HETZNER_API_KEY_PATH", None),
                "name": "hetzner_api_key",
            },
        ],
        "name": name,
        "module": MODULE,
        "stage": environ["STAGE"],
        "project_root_path": PROJECT_ROOT_PATH,
        "build_types": ["TERRAFORM"],
        "mixin_types": [],
        "tf_provider_types": ["DIGITALOCEAN", "HETZNER"],
        "tf_use_workspace": False,
        "tf_terraform_semantic_version": "1.4.2",
        "do_as_backend": True,
        "do_bucket": "your-bucket",
    }

    build = DevopsTerraformBuild(project, config)
    build.initialize_build_dir()


@task
def plan(project):
    build = get_devops_build(project)
    build.plan()


@task
def apply(project):
    build = get_devops_build(project)
    build.apply(True)


@task
def destroy(project):
    build = get_devops_build(project)
    build.destroy(True)

Snapshot & Release

pyb dev publish upload
pip3 install --upgrade ddadevops --pre

pyb [patch|minor|major]
pip3 install --upgrade ddadevops

Development & mirrors

Development happens at: https://repo.prod.meissa.de/meissa/dda-devops-build

Mirrors are:

For more details about our repository model see: https://repo.prod.meissa.de/meissa/federate-your-repos

License

Copyright © 2021 meissa GmbH Licensed under the Apache License, Version 2.0 (the "License")

License

Copyright © 2023 meissa GmbH Licensed under the Apache License, Version 2.0 (the "License")

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ddadevops-4.4.0.tar.gz (29.8 kB view details)

Uploaded Source

Built Distribution

ddadevops-4.4.0-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

Details for the file ddadevops-4.4.0.tar.gz.

File metadata

  • Download URL: ddadevops-4.4.0.tar.gz
  • Upload date:
  • Size: 29.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for ddadevops-4.4.0.tar.gz
Algorithm Hash digest
SHA256 caf8850ff8cb4dbdc34ce0d698ca1f36f5d825a4ceebb47a22f5549b073be1e0
MD5 c5519b28dbabed499b6ade8fb191637d
BLAKE2b-256 9a9f705554fbf510dc201c55cc95552f85d971fd1be22226c77c79272888fb03

See more details on using hashes here.

File details

Details for the file ddadevops-4.4.0-py3-none-any.whl.

File metadata

  • Download URL: ddadevops-4.4.0-py3-none-any.whl
  • Upload date:
  • Size: 40.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for ddadevops-4.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e74d73beadf07c46c1788531032b389d02a6e753a98a5c6b05bea08805a166db
MD5 420602cfd628a90d7fdf154a7adea305
BLAKE2b-256 98ea25d9815b5761f6afab1c0338e0431214866ec1bde930555af48c435ca743

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page