Simple ExampleΒΆ

With avionix, you can build with the typical kubernetes components

For example for a deployment:

from avionix import ChartBuilder, ChartInfo, ObjectMeta
from avionix.kube.apps import Deployment, DeploymentSpec, PodTemplateSpec
from avionix.kube.core import Container, ContainerPort, EnvVar, LabelSelector, PodSpec

container = Container(
    name="test-container",
    image="k8s.gcr.io/echoserver:1.4",
    env=[EnvVar("test", "test-value")],
    ports=[ContainerPort(8080)],
)

deployment = Deployment(
    metadata=ObjectMeta(name="test-deployment", labels={"app": "my_app"}),
    spec=DeploymentSpec(
        replicas=1,
        template=PodTemplateSpec(
            ObjectMeta(labels={"app": "my_app"}), spec=PodSpec(containers=[container]),
        ),
        selector=LabelSelector(match_labels={"app": "my_app"}),
    ),
)

builder = ChartBuilder(
    ChartInfo(api_version="3.2.4", name="test", version="0.1.0", app_version="v1"),
    [deployment],
)

from there you either do

builder.install_chart()

if you want to install the chart directly and let avionix handle it or you can use

builder.generate_chart()

to generate the chart and template yaml files.

Additionally,

builder.uninstall_chart()

and

builder.upgrade_chart()

are included.

For more specifics about chart builder see the Chart documentation.

These are all directly equivalent to their corresponding helm commands and also support passing in command line by passing a dictionary in with the options needed.

For example,

builder.install_chart(options={"create-namespace": None, "dependency-update": None}))

If a command line option takes an argument in helm, then that value should be given as the value in the corresponding dictionary key in the options dictionary.