Kubernetes-REST

 view release on metacpan or  search on metacpan

eg/demo.pl  view on Meta::CPAN

            labels    => { app => 'demo-app', type => 'batch' },
        },
        spec => {
            backoffLimit          => 2,
            ttlSecondsAfterFinished => 300,
            template => {
                spec => {
                    restartPolicy => 'Never',
                    containers => [{
                        name    => 'worker',
                        image   => 'busybox:latest',
                        command => ['sh', '-c',
                            'echo "Job started at $(date)"; '
                            . 'echo "Processing items..."; '
                            . 'for i in 1 2 3 4 5; do echo "  Item $i done"; sleep 1; done; '
                            . 'echo "Job completed at $(date)"'
                        ],
                        resources => {
                            requests => { cpu => '25m', memory => '16Mi' },
                            limits   => { cpu => '50m', memory => '32Mi' },
                        },

eg/demo.pl  view on Meta::CPAN

            schedule                   => '*/1 * * * *',
            successfulJobsHistoryLimit => 2,
            failedJobsHistoryLimit     => 1,
            jobTemplate => {
                spec => {
                    template => {
                        spec => {
                            restartPolicy => 'OnFailure',
                            containers => [{
                                name    => 'cron-worker',
                                image   => 'busybox:latest',
                                command => ['sh', '-c', 'echo "Cron tick at $(date)"'],
                                resources => {
                                    requests => { cpu => '10m', memory => '8Mi' },
                                    limits   => { cpu => '25m', memory => '16Mi' },
                                },
                            }],
                        },
                    },
                },
            },

eg/demo.pl  view on Meta::CPAN

            labels    => { app => 'demo-app', component => 'utility' },
            annotations => {
                'purpose' => 'Demonstrates ConfigMap + Secret access from a pod',
            },
        },
        spec => {
            serviceAccountName => 'demo-sa',
            restartPolicy => 'Never',
            containers => [{
                name    => 'util',
                image   => 'busybox:latest',
                command => ['sh', '-c', join('; ',
                    'echo "=== Environment ==="',
                    'echo "APP_ENV=$APP_ENV"',
                    'echo "LOG_LEVEL=$LOG_LEVEL"',
                    'echo "DB_HOST=$DB_HOST"',
                    'echo ""',
                    'echo "=== Config Files ==="',
                    'echo "nginx.conf:"',
                    'cat /config/nginx.conf',
                    'echo ""',

lib/Kubernetes/REST/Example.pm  view on Meta::CPAN

            name      => 'batch-job',
            namespace => 'perl-test',
        },
        spec => {
            backoffLimit => 2,
            template => {
                spec => {
                    restartPolicy => 'Never',
                    containers => [{
                        name    => 'worker',
                        image   => 'busybox:latest',
                        command => ['sh', '-c', 'echo "done"; exit 0'],
                    }],
                },
            },
        },
    ));

=head2 CronJob

    my $cron = $api->create($api->new_object(CronJob =>

lib/Kubernetes/REST/Example.pm  view on Meta::CPAN

        },
        spec => {
            schedule => '*/5 * * * *',
            jobTemplate => {
                spec => {
                    template => {
                        spec => {
                            restartPolicy => 'OnFailure',
                            containers => [{
                                name    => 'worker',
                                image   => 'busybox:latest',
                                command => ['sh', '-c', 'date'],
                            }],
                        },
                    },
                },
            },
        },
    ));

=head2 RBAC (Role + RoleBinding)

t/06_examples.t  view on Meta::CPAN

            name      => 'batch-job',
            namespace => 'perl-test',
        },
        spec => {
            backoffLimit => 2,
            template => {
                spec => {
                    restartPolicy => 'Never',
                    containers => [{
                        name    => 'worker',
                        image   => 'busybox:latest',
                        command => ['sh', '-c', 'echo "done"; exit 0'],
                    }],
                },
            },
        },
    );
    ok($job, 'Job created');
    is($job->metadata->name, 'batch-job', 'name');
    is($job->kind, 'Job', 'kind');
    is($job->api_version, 'batch/v1', 'apiVersion');

t/06_examples.t  view on Meta::CPAN

        },
        spec => {
            schedule => '*/5 * * * *',
            jobTemplate => {
                spec => {
                    template => {
                        spec => {
                            restartPolicy => 'OnFailure',
                            containers => [{
                                name    => 'worker',
                                image   => 'busybox:latest',
                                command => ['sh', '-c', 'date'],
                            }],
                        },
                    },
                },
            },
        },
    );
    ok($cron, 'CronJob created');
    is($cron->metadata->name, 'scheduled-job', 'name');

t/07_example_crud.t  view on Meta::CPAN

            name      => 'batch-job',
            namespace => 'perl-test',
        },
        spec => {
            backoffLimit => 2,
            template => {
                spec => {
                    restartPolicy => 'Never',
                    containers => [{
                        name    => 'worker',
                        image   => 'busybox:latest',
                        command => ['sh', '-c', 'echo "done"; exit 0'],
                    }],
                },
            },
        },
    );
    my $created = $api->create($job);
    ok($created, 'Job created');
    is($created->metadata->name, 'batch-job', 'name');
    is($created->kind, 'Job', 'kind');

t/07_example_crud.t  view on Meta::CPAN

        },
        spec => {
            schedule => '*/5 * * * *',
            jobTemplate => {
                spec => {
                    template => {
                        spec => {
                            restartPolicy => 'OnFailure',
                            containers => [{
                                name    => 'worker',
                                image   => 'busybox:latest',
                                command => ['sh', '-c', 'date'],
                            }],
                        },
                    },
                },
            },
        },
    );
    my $created = $api->create($cron);
    ok($created, 'CronJob created');

t/07_example_crud.t  view on Meta::CPAN

            name      => 'roundtrip',
            namespace => 'default',
        },
        spec => {
            replicas => 5,
            selector => { matchLabels => { app => 'rt' } },
            template => {
                metadata => { labels => { app => 'rt' } },
                spec => {
                    containers => [{
                        name => 'test', image => 'busybox',
                    }],
                },
            },
        },
    );

    # TO_JSON -> inflate roundtrip
    my $data = $deploy->TO_JSON;
    is($data->{kind}, 'Deployment', 'TO_JSON kind');
    is($data->{apiVersion}, 'apps/v1', 'TO_JSON apiVersion');



( run in 0.596 second using v1.01-cache-2.11-cpan-39bf76dae61 )