Kubernetes

Kubernetes kubectl helpers for Raku

Kubernetes

Raku kubectl helpers for Kubernetes and OpenShift workflows.

Distribution: Kubernetes:auth<zef:rmv>Repository: Rmv-KubernetesTutorial: docs/tutorial_woven.md

Synopsis

use Kubernetes::Resources::ConfigMap;
use Kubernetes::Resources::Namespace;
use Kubernetes::Client;

my $kubectl = Kubernetes::Client::resolve-kubectl();

# ConfigMap apply/delete and data helpers
my $cm = Kubernetes::Resources::ConfigMap::ConfigMap.new(
    :name<my-config>, :namespace<default>,
    :data(%(foo => 'bar', 'app.yaml' => "key: value\n")),
);
$cm.apply($kubectl);
say $cm.get-key($kubectl, 'foo');
$cm.delete($kubectl);

# Namespace lifecycle
my $ns = Kubernetes::Resources::Namespace::Namespace.new(:name<my-ns>);
$ns.ensure($kubectl);
$ns.label($kubectl, 'tenant=true');
$ns.delete($kubectl);

# Lightweight handle for resources without a manifest class
my $ref = Kubernetes::Resources::Core::ResourceRef.new(
    :name<my-sub>, :namespace<my-namespace>,
    :kubectl-name<subscription>, :kind<Subscription>,
);
$ref.delete($kubectl);

# Poll until a pod reaches Running
use Kubernetes::Resources::Pod;
my $pod = Kubernetes::Resources::Pod::Pod.new(:name<my-pod>, :namespace<default>);
my ($ready, $phase) = $pod.wait-until-ready($kubectl, :timeout-s(120));

Installation

From zef:

zef install 'Kubernetes:auth<zef:rmv>'

Local development:

git clone https://github.com/ruivieira/Rmv-Kubernetes.git
cd Rmv-Kubernetes
zef install --force-install .

Requires kubectl (or set KUBECTL to an alternate binary path).

Modules

ModulePurpose
Kubernetes::ClientResolve kubectl binary (KUBECTL env or kubectl)
Kubernetes::ExecShell execution helpers (run-live, run-query, …)
Kubernetes::LogANSI-colored log output (log-info, log-step, …)
Kubernetes::Resources::CoreBase roles K8sResource, NamespacedResource; ResourceRef class
Kubernetes::Resources::ConfigMapConfigMap apply/delete, YAML from data, exists, get-key
Kubernetes::Resources::SecretSecret apply/delete, YAML from stringData, exists, has-key, ensure-key
Kubernetes::Resources::NamespaceNamespace create/label/delete lifecycle
Kubernetes::Resources::PodPod resource with WaitForReady polling
Kubernetes::Operations::Waitpoll-until and WaitForReady role

Development

make check        # syntax-check all .rakumod files
make unit         # unit tests (dry-run, no cluster)
make integration  # integration tests (requires KUBECONFIG / KinD)
make lint         # style checks (trailing whitespace, tabs, …)
make secrets      # gitleaks scan
make pre-commit   # run all pre-commit hooks
make all          # check + lint + unit + secrets
make docs-kind    # KinD cluster + weave literate tutorial + teardown
make docs         # weave docs/tutorial.md (requires cluster for weave)
make docs-weave   # evaluate code cells → docs/tutorial_woven.md

Install git hooks:

pre-commit install

Testing

Unit tests (t/*.rakutest) exercise roles and dry-run paths without a live cluster.

Integration tests (t/integration/*.rakutest) run against a reachable cluster. They skip when kubectl cluster-info fails (no kubeconfig or cluster unavailable).

Local KinD example:

kind create cluster
make integration
kind delete cluster

Documentation

docs/tutorial_woven.md — tutorial with evaluated Raku cells and live kubectl output. Source: docs/tutorial.md (make docs-weave to regenerate).

CI

GitHub Actions runs two jobs on every push and pull request:

JobWhat it runs
unitmake unit
integrationKinD cluster + kubectl cluster-info + make integration

License

Apache-2.0

Kubernetes v0.0.3

Kubernetes kubectl helpers for Raku

Authors

  • Rui Vieira

License

Apache-2.0

Dependencies

Test Dependencies

Provides

  • Kubernetes
  • Kubernetes::Client
  • Kubernetes::Exec
  • Kubernetes::Log
  • Kubernetes::Operations
  • Kubernetes::Operations::Wait
  • Kubernetes::Resources
  • Kubernetes::Resources::ConfigMap
  • Kubernetes::Resources::Core
  • Kubernetes::Resources::Namespace
  • Kubernetes::Resources::Pod
  • Kubernetes::Resources::Secret

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.