NAME

IO::K8s::Role::APIObject - Role for top-level Kubernetes API objects

VERSION

version 1.001

metadata

Standard object's metadata. See IO::K8s::Apimachinery::Pkg::Apis::Meta::V1::ObjectMeta.

api_version

Returns the Kubernetes API version derived from the class name.

$pod->api_version;  # "v1"
$deployment->api_version;  # "apps/v1"

kind

Returns the Kubernetes kind derived from the class name.

$pod->kind;  # "Pod"
$deployment->kind;  # "Deployment"

resource_plural

Returns the plural resource name for URL building, or undef to use automatic pluralization. Override this in CRD classes where the plural name is not simply the lowercased kind with an "s" appended:

sub resource_plural { 'staticwebsites' }

to_yaml

my $yaml = $pod->to_yaml;

Serialize the object to YAML format suitable for kubectl apply -f.

save

$pod->save('pod.yaml');

Save the object to a YAML file. Returns the object for chaining.

add_label

$obj->add_label(app => 'web');

Add a single label. Returns $self for chaining.

add_labels

$obj->add_labels(app => 'web', tier => 'frontend');

Add multiple labels at once. Returns $self for chaining.

label

my $val = $obj->label('app');  # => 'web'

Get the value of a single label, or undef if missing.

has_label

$obj->has_label('app');  # => 1

Returns true if the label key exists.

remove_label

$obj->remove_label('tier');

Remove a label by key. Returns $self for chaining.

match_labels

$obj->match_labels(app => 'web', tier => 'frontend');  # => Bool

Returns true if all given key/value pairs match the object's labels.

add_annotation

$obj->add_annotation('prometheus.io/scrape' => 'true');

Add a single annotation. Returns $self for chaining.

annotation

my $val = $obj->annotation('prometheus.io/scrape');

Get the value of a single annotation, or undef if missing.

has_annotation

$obj->has_annotation('prometheus.io/scrape');  # => 1

Returns true if the annotation key exists.

remove_annotation

$obj->remove_annotation('prometheus.io/scrape');

Remove an annotation by key. Returns $self for chaining.

conditions

my $conds = $obj->conditions;  # => ArrayRef

Returns all status conditions as an arrayref.

get_condition

my $cond = $obj->get_condition('Ready');  # => hashref/object or undef

Get a single condition by type name.

is_condition_true

$obj->is_condition_true('Available');  # => Bool

Returns true if the named condition has status = "True".

is_ready

$obj->is_ready;  # => Bool

Returns true if the Ready or Available condition is true.

condition_message

my $msg = $obj->condition_message('Ready');

Returns the message string for the named condition, or undef.

set_owner

$pod->set_owner($deployment);

Add an ownerReference pointing to another API object. Returns $self for chaining.

is_owned_by

$pod->is_owned_by($deployment);  # => Bool

Returns true if this object has an ownerReference matching the given object.

owner_refs

my $refs = $obj->owner_refs;  # => ArrayRef

Returns the ownerReferences array, or an empty arrayref.

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