ComparedKlass8s and Helm

Compared

Klass8s and Helm

Helm is a package manager and a template engine. Klass8s works with the first and replaces the second for your own manifests.

Helm is two products under one name: a package manager that distributes software (charts, repositories, releases), and a template engine for writing manifests (Go templates over values.yaml). The comparison splits along that line:

  • As a package manager, Helm is excellent, and Klass8s does not compete: it renders Helm releases beside your manifests.
  • As the way to write your own manifests, Helm is where Klass8s makes its case.

Why classes has a template and a class side by side; this page does not repeat it.

Writing manifests: templates and classes

The interface of a chart

A chart's interface is its values.yaml, which has no types of its own. Whether replicaCount: "3" works depends on where the template interpolates it; a misspelt key is usually ignored, so the setting quietly does not exist. values.schema.json adds validation, but it is optional and kept by hand next to the templates it describes.

The interface of a manifest class is its constructor and its methods, typed, checked by the same tools as the rest of the code, and impossible to let drift from the implementation because it is the implementation:

src/K8S/Shop/Manifest/ApiDeployment.phnsrc/K8S/Shop/Manifest/ApiDeployment.php
namespace App\K8S\Shop\Manifest;

use App\Service\DatabaseUrls;
use Klass8s\Core\Container\Env\EnvConfigurator;
use Klass8s\Core\Container\Image\Image;
use Klass8s\Core\Deployment\AbstractContainerDeployment;

class ApiDeployment extends AbstractContainerDeployment
{
    // $imageTag and $publicHostname are bindings of config/services.yaml; DatabaseUrls is a service
    __construct(
        private string $imageTag,
        private string $publicHostname,
        private DatabaseUrls $databases,
    ) {}

    static shortName(): string => 'api';

    image(): Image => Image::fromName('acme/shop-api')->setTag($this->imageTag);

    env(EnvConfigurator $env): void {
        $env->var('PUBLIC_URL', 'https://'.$this->publicHostname)
            ->var('DATABASE_URL', $this->databases->forDatabase('shop'));
    }
}
<?php

declare(strict_types=1);

namespace App\K8S\Shop\Manifest;

use App\Service\DatabaseUrls;
use Klass8s\Core\Container\Env\EnvConfigurator;
use Klass8s\Core\Container\Image\Image;
use Klass8s\Core\Deployment\AbstractContainerDeployment;

class ApiDeployment extends AbstractContainerDeployment
{
    // $imageTag and $publicHostname are bindings of config/services.yaml; DatabaseUrls is a service
    public function __construct(
        private string $imageTag,
        private string $publicHostname,
        private DatabaseUrls $databases,
    ) {}

    public static function shortName(): string
    {
        return 'api';
    }

    public function image(): Image
    {
        return Image::fromName('acme/shop-api')->setTag($this->imageTag);
    }

    public function env(EnvConfigurator $env): void
    {
        $env->var('PUBLIC_URL', 'https://'.$this->publicHostname)
            ->var('DATABASE_URL', $this->databases->forDatabase('shop'));
    }
}

Logic

Helm's logic is Go templates: if, range, include, pipelines, and helper templates in _helpers.tpl with no signatures. Tests need a plugin such as helm-unittest, which asserts on rendered documents. A template error points at a line of the output.

Klass8s's logic is PHP or Phaenon: a debugger, PHPUnit, static analysis, navigation in the editor. A render test asserts on parsed output next to the product's tests.

Consistency between resources

A chart's Deployment, Service and monitor agree on names and labels because every template includes the same helpers, by convention. Klass8s derives names, labels and selectors from one declaration, and references are classes that fail the render when their target is missing.

Helm has no counterpart to the event system: helm template has no moment at which every pod spec of the render is an object a program can address. A rule for every chart is a convention each chart implements again.

Releases

Helm records installs as releases: versioned, listed, rolled back. That is useful, and Klass8s has no equivalent on purpose: it renders and stops. The state of a deployment belongs to what you already trust: kubectl apply with diffs, or a GitOps controller, where Git's history is the release history and a rollback is a revert.

Distributing software: keep Helm

Install cert-manager, database operators or Valkey from their charts. Klass8s makes such a release part of the project: its values merge per environment like your own configuration, it renders with k8s:render:all, and its resources carry the same app and deploy-priority annotations as your Apps'. You keep Helm's ecosystem and drop the second configuration system.

Side by side

HelmKlass8s
Third-party softwarethe standarduses Helm's charts
Interface of a packagevalues.yaml, optionally a JSON schemaconstructors, methods, enums, value objects
Logic and reuseGo templates, helper templatesclasses, traits, dependency injection
Consistency between resourcesby conventionderived
Rules for every resourceper chartsubscribers
Testsplugins asserting on outputPHPUnit on parsed output
Release records and rollbackbuilt inleft to kubectl or GitOps
Distributing your software to otherscharts are what users expectnot a goal
Needed to renderthe helm binaryPHP and Composer

Two rows favour Helm and deserve weight. If you distribute software to the public, your users expect a chart. And if your charts are few, small and rarely touched, switching may not pay back: Klass8s earns its place where manifests are many, carry logic, and change often.

Moving from Helm

  1. Render the existing charts through the bridge. Nothing is rewritten; the charts gain per-environment configuration and one pipeline. Third-party charts stay there for good.
  2. Rewrite your own charts one at a time. A chart maps onto an App, each template onto a manifest class. Start with the chart that has the most logic.
  3. Turn conventions into subscribers. What the helper templates enforced by inclusion (labels, pull secrets, resource floors) becomes subscribers.
  4. Compare. bin/console k8s:render:apps | kubectl diff -f - against the cluster running the chart shows what changed, typically only labels.