NAME

IO::K8s::APIObject - Base class for top-level Kubernetes API objects

VERSION

version 1.001

SYNOPSIS

# Built-in API object (api_version/kind derived from class name):
package IO::K8s::Api::Core::V1::Pod;
use IO::K8s::APIObject;

k8s spec => 'Core::V1::PodSpec';
k8s status => 'Core::V1::PodStatus';

1;

# Custom Resource Definition (CRD):
package My::StaticWebSite;
use IO::K8s::APIObject
    api_version     => 'homelab.example.com/v1',
    resource_plural => 'staticwebsites';
with 'IO::K8s::Role::Namespaced';

k8s spec   => { Str => 1 };
k8s status => { Str => 1 };

1;

DESCRIPTION

Like IO::K8s::Resource, but for top-level Kubernetes API objects. Automatically applies IO::K8s::Role::APIObject which provides:

  • metadata attribute

  • api_version() method (derived from class name)

  • kind() method (derived from class name)

  • resource_plural() method (returns undef = auto-pluralize)

  • Label, annotation, condition, and owner convenience methods

For Custom Resource Definitions (CRDs), pass api_version and optionally resource_plural as import parameters. These are installed as class methods before the role is composed, avoiding redefinition warnings. CRD classes also get IO::K8s::Role::SpecBuilder applied automatically for deep-path spec manipulation (spec_get, spec_set, spec_push, spec_merge, spec_delete).

Use IO::K8s::Resource for embedded objects (PodSpec, Container, etc.) and IO::K8s::APIObject for top-level resources (Pod, Deployment, Service, etc.)

SUPPORT

Issues

Please report bugs and feature requests on GitHub at https://github.com/pplu/io-k8s-p5/issues.

IRC

Join #kubernetes on irc.perl.org or message Getty directly.

CONTRIBUTING

Contributions are welcome! Please fork the repository and submit a pull request.

AUTHORS

  • Torsten Raudssus <torsten@raudssus.de>

  • Jose Luis Martinez <jlmartin@cpan.org> (original author, inactive)

COPYRIGHT AND LICENSE

This software is Copyright (c) 2018 by Jose Luis Martinez.

This is free software, licensed under:

The Apache License, Version 2.0, January 2004