| 1 | package Example::Comb::NATS; | ||||||||||||
| 2 | # ABSTRACT: Example Comb: a NATS server, run locally | ||||||||||||
| 3 | |||||||||||||
| 4 | # A Comb class as a distribution of your own would ship it: what it offers | ||||||||||||
| 5 | # (endpoints) and what it consists of (manifests). Everything else -- | ||||||||||||
| 6 | # deploying, status, pruning, the status in the custom resource -- is | ||||||||||||
| 7 | # Kubernetes::Comb. The resources are named after the Comb, so the Service | ||||||||||||
| 8 | # is the one its endpoints are reached through. | ||||||||||||
| 9 | |||||||||||||
| 10 | 1 | ▶ | use Moo; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 11 | 1 | extends 'Kubernetes::Comb'; | |||||||||||
| 12 | |||||||||||||
| 13 | 1 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | |||||||||||||
| 15 | 0 | ▶ | sub endpoints { | ||||||||||
|
Subroutine
endpoints: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||
| 16 | return ( | ||||||||||||
| 17 | 0 | { name => 'client', port => 4222 }, | |||||||||||
| 18 | { name => 'monitor', port => 8222 } | ||||||||||||
| 19 | ); | ||||||||||||
| 20 | } | ||||||||||||
| 21 | |||||||||||||
| 22 | 1 | ▶ | sub manifests { | ||||||||||
|
Subroutine
manifests: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 23 | 1 | my ( $self ) = @_; | |||||||||||
| 24 | 1 | my $name = $self->name; | |||||||||||
| 25 | 1 | ▶ | my $image = $self->config->{image} // 'nats:2.10-alpine'; | ||||||||||
|
Condition50%1/2
$self->config->{"image"} // "nats:2.10-alpine"
MC/DC0%0/1
$self->config->{"image"} // "nats:2.10-alpine"
$self->config->{"image"}
Truth table50%1/2
A
A= $self->config->{"image"}
| |||||||||||||
| 26 | 1 | my %app = ( app => $name ); | |||||||||||
| 27 | return ( | ||||||||||||
| 28 | { | ||||||||||||
| 29 | 1 | apiVersion => 'apps/v1', | |||||||||||
| 30 | kind => 'Deployment', | ||||||||||||
| 31 | metadata => { name => $name }, | ||||||||||||
| 32 | spec => { | ||||||||||||
| 33 | replicas => 1, | ||||||||||||
| 34 | selector => { matchLabels => {%app} }, | ||||||||||||
| 35 | template => { | ||||||||||||
| 36 | metadata => { labels => {%app} }, | ||||||||||||
| 37 | spec => { containers => [ { | ||||||||||||
| 38 | name => 'nats', | ||||||||||||
| 39 | image => $image, | ||||||||||||
| 40 | args => [ '--http_port', '8222' ], | ||||||||||||
| 41 | ports => [ | ||||||||||||
| 42 | { name => 'client', containerPort => 4222 }, | ||||||||||||
| 43 | { name => 'monitor', containerPort => 8222 } | ||||||||||||
| 44 | ], | ||||||||||||
| 45 | readinessProbe => { httpGet => { path => '/healthz', port => 8222 } } | ||||||||||||
| 46 | } ] } | ||||||||||||
| 47 | } | ||||||||||||
| 48 | } | ||||||||||||
| 49 | }, | ||||||||||||
| 50 | { | ||||||||||||
| 51 | apiVersion => 'v1', | ||||||||||||
| 52 | kind => 'Service', | ||||||||||||
| 53 | metadata => { name => $name }, | ||||||||||||
| 54 | spec => { | ||||||||||||
| 55 | selector => {%app}, | ||||||||||||
| 56 | ports => [ | ||||||||||||
| 57 | { name => 'client', port => 4222 }, | ||||||||||||
| 58 | { name => 'monitor', port => 8222 } | ||||||||||||
| 59 | ] | ||||||||||||
| 60 | } | ||||||||||||
| 61 | } | ||||||||||||
| 62 | ); | ||||||||||||
| 63 | } | ||||||||||||
| 64 | |||||||||||||
| 65 | 1 | 1; | |||||||||||