diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68b272f3..b33ecbdf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,25 +15,29 @@ jobs: if: "!contains(github.event.head_commit.message, 'skip ci')" runs-on: ubuntu-latest + timeout-minutes: 15 strategy: fail-fast: false matrix: php: - - '8.0' - '8.1' + - '8.2' kubernetes: - - '1.22.9' - - '1.23.6' - - '1.24.0' + - '1.24.12' + - '1.25.8' + - '1.26.3' laravel: - 9.* + - 10.* prefer: - 'prefer-lowest' - 'prefer-stable' include: - laravel: 9.* testbench: 7.* + - laravel: 10.* + testbench: 8.* name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - K8s v${{ matrix.kubernetes }} --${{ matrix.prefer }} @@ -53,12 +57,12 @@ jobs: path: ~/.composer/cache/files key: composer-php-${{ matrix.php }}-${{ matrix.laravel }}-${{ matrix.prefer }}-${{ hashFiles('composer.json') }} - - uses: manusa/actions-setup-minikube@v2.6.1 + - uses: medyagh/setup-minikube@latest name: Setup Minikube with: - minikube version: v1.25.2 - kubernetes version: "v${{ matrix.kubernetes }}" - github token: "${{ secrets.GITHUB_TOKEN }}" + minikube-version: 1.29.0 + container-runtime: containerd + kubernetes-version: "v${{ matrix.kubernetes }}" - name: Run Kubernetes Proxy run: | @@ -67,7 +71,7 @@ jobs: - name: Install dependencies run: | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.prefer }} --prefer-dist --no-interaction --no-suggest + composer update --${{ matrix.prefer }} --prefer-dist --no-interaction - name: Setup in-cluster config run: | @@ -79,7 +83,7 @@ jobs: - name: Setting CRDs for testing run: | - kubectl apply -f https://raw.githubusercontent.com/bitnami-labs/sealed-secrets/main/helm/sealed-secrets/crds/sealedsecret-crd.yaml + kubectl apply -f https://raw.githubusercontent.com/bitnami-labs/sealed-secrets/main/helm/sealed-secrets/crds/bitnami.com_sealedsecrets.yaml # - name: Run static analysis # run: | diff --git a/README.md b/README.md index 5017cd0c..735264e8 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ PHP K8s [![Total Downloads](https://poser.pugx.org/renoki-co/php-k8s/downloads)](https://packagist.org/packages/renoki-co/php-k8s) [![Monthly Downloads](https://poser.pugx.org/renoki-co/php-k8s/d/monthly)](https://packagist.org/packages/renoki-co/php-k8s) -![v1.22.9 K8s Version](https://img.shields.io/badge/K8s%20v1.22.9-Ready-%23326ce5?colorA=306CE8&colorB=green) -![v1.23.6 K8s Version](https://img.shields.io/badge/K8s%20v1.23.6-Ready-%23326ce5?colorA=306CE8&colorB=green) -![v1.24.0 K8s Version](https://img.shields.io/badge/K8s%20v1.24.0-Ready-%23326ce5?colorA=306CE8&colorB=green) +![v1.24.12 K8s Version](https://img.shields.io/badge/K8s%20v1.24.12-Ready-%23326ce5?colorA=306CE8&colorB=green) +![v1.25.8 K8s Version](https://img.shields.io/badge/K8s%20v1.25.8-Ready-%23326ce5?colorA=306CE8&colorB=green) +![v1.26.3 K8s Version](https://img.shields.io/badge/K8s%20v1.26.3-Ready-%23326ce5?colorA=306CE8&colorB=green) [![Client Capabilities](https://img.shields.io/badge/Kubernetes%20Client-Silver-blue.svg?colorB=C0C0C0&colorA=306CE8)](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/csi-new-client-library-procedure.md#client-capabilities) [![Client Support Level](https://img.shields.io/badge/Kubernetes%20Client-stable-green.svg?colorA=306CE8)](https://github.com/kubernetes/community/blob/master/contributors/design-proposals/api-machinery/csi-new-client-library-procedure.md#client-support-level) diff --git a/composer.json b/composer.json index df2ad327..9229e9fa 100644 --- a/composer.json +++ b/composer.json @@ -12,15 +12,15 @@ } ], "require": { + "ext-yaml": "*", "guzzlehttp/guzzle": "^6.5|^7.0", - "illuminate/macroable": "^9.0.1", - "illuminate/support": "^9.0.1", + "illuminate/macroable": "^9.35|^10.1", + "illuminate/support": "^9.35|^10.1", "ratchet/pawl": "^0.4.1", "symfony/process": "^5.4|^6.0", "vierbergenlars/php-semver": "^2.1|^3.0" }, "suggest": { - "ext-yaml": "YAML extension is used to read or generate YAML from PHP K8s internal classes." }, "autoload": { "psr-4": { @@ -37,9 +37,8 @@ }, "require-dev": { "mockery/mockery": "^1.5", - "orchestra/testbench": "^6.28|^7.0", - "orchestra/testbench-core": "^6.28|^7.0", - "phpunit/phpunit": "^9.5.20", + "orchestra/testbench": "^7.23|^8.1", + "phpunit/phpunit": "^9.5.20|^10.0", "vimeo/psalm": "^4.20" }, "config": { diff --git a/phpunit.xml b/phpunit.xml index 82794b74..ef9baef1 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,25 +1,16 @@ - - - - tests - - - - - src/ - - - - - + + + + src/ + + + + + tests + + + + + diff --git a/src/Kinds/K8sCronJob.php b/src/Kinds/K8sCronJob.php index 708effdb..2a1b5754 100644 --- a/src/Kinds/K8sCronJob.php +++ b/src/Kinds/K8sCronJob.php @@ -4,6 +4,8 @@ use Carbon\Carbon; use Cron\CronExpression; +use DateTime; +use Illuminate\Support\Collection; use RenokiCo\PhpK8s\Contracts\InteractsWithK8sCluster; use RenokiCo\PhpK8s\Contracts\Watchable; use RenokiCo\PhpK8s\Traits\Resource\HasSpec; @@ -26,7 +28,7 @@ class K8sCronJob extends K8sResource implements InteractsWithK8sCluster, Watchab * * @var string */ - protected static $defaultVersion = 'batch/v1beta1'; + protected static $defaultVersion = 'batch/v1'; /** * Wether the resource has a namespace. @@ -38,7 +40,7 @@ class K8sCronJob extends K8sResource implements InteractsWithK8sCluster, Watchab /** * Set the job template. * - * @param array|\RenokiCo\PhpK8s\Kinds\K8sJob $job + * @param array|K8sJob $job * @return $this */ public function setJobTemplate($job) @@ -54,7 +56,7 @@ public function setJobTemplate($job) * Get the template job. * * @param bool $asInstance - * @return array|\RenokiCo\PhpK8s\Kinds\K8sJob + * @return array|K8sJob */ public function getJobTemplate(bool $asInstance = true) { @@ -70,7 +72,7 @@ public function getJobTemplate(bool $asInstance = true) /** * Set the schedule for the cronjob. * - * @param \Cron\CronExpression|string $schedule + * @param CronExpression|string $schedule * @return $this */ public function setSchedule($schedule) @@ -86,7 +88,7 @@ public function setSchedule($schedule) * Retrieve the schedule. * * @param bool $asInstance - * @return \Cron\CronExpression|string + * @return CronExpression|string */ public function getSchedule(bool $asInstance = true) { @@ -102,7 +104,7 @@ public function getSchedule(bool $asInstance = true) /** * Get the last time a job was scheduled. * - * @return \DateTime|null + * @return DateTime|null */ public function getLastSchedule() { @@ -116,12 +118,12 @@ public function getLastSchedule() /** * Get the active jobs created by the cronjob. * - * @return \Illuminate\Support\Collection + * @return Collection */ public function getActiveJobs() { return collect($this->getStatus('active', []))->map(function ($job) { - return $this->cluster->job($job)->refresh(); + return $this->cluster->getJobByName($job['name'], $this->getNamespace()); }); } } diff --git a/src/Kinds/K8sHorizontalPodAutoscaler.php b/src/Kinds/K8sHorizontalPodAutoscaler.php index 77a3f04b..ac9d8bc3 100644 --- a/src/Kinds/K8sHorizontalPodAutoscaler.php +++ b/src/Kinds/K8sHorizontalPodAutoscaler.php @@ -28,7 +28,7 @@ class K8sHorizontalPodAutoscaler extends K8sResource implements InteractsWithK8s * * @var string */ - protected static $defaultVersion = 'autoscaling/v2beta2'; + protected static $defaultVersion = 'autoscaling/v2'; /** * Wether the resource has a namespace. @@ -40,7 +40,7 @@ class K8sHorizontalPodAutoscaler extends K8sResource implements InteractsWithK8s /** * Set the reference to the scaling resource. * - * @param \RenokiCo\PhpK8s\Contracts\Scalable $resource + * @param Scalable $resource * @return $this */ public function setResource(Scalable $resource) @@ -55,7 +55,7 @@ public function setResource(Scalable $resource) /** * Add a new metric. * - * @param \RenokiCo\PhpK8s\Instances\ResourceMetric $metric + * @param ResourceMetric $metric * @return $this */ public function addMetric(ResourceMetric $metric) diff --git a/src/Kinds/K8sJob.php b/src/Kinds/K8sJob.php index cbb60bae..412fa622 100644 --- a/src/Kinds/K8sJob.php +++ b/src/Kinds/K8sJob.php @@ -151,6 +151,6 @@ public function getDurationInSeconds(): int */ public function hasCompleted(): bool { - return $this->getActivePodsCount() === 0; + return ! is_null($this->getCompletionTime()); } } diff --git a/src/Kinds/K8sPodDisruptionBudget.php b/src/Kinds/K8sPodDisruptionBudget.php index e5ae1fa7..67aee7b2 100644 --- a/src/Kinds/K8sPodDisruptionBudget.php +++ b/src/Kinds/K8sPodDisruptionBudget.php @@ -33,7 +33,7 @@ class K8sPodDisruptionBudget extends K8sResource implements InteractsWithK8sClus * * @var string */ - protected static $defaultVersion = 'policy/v1beta1'; + protected static $defaultVersion = 'policy/v1'; /** * Set the maximum unavailable pod budget and diff --git a/src/Kinds/K8sStatefulSet.php b/src/Kinds/K8sStatefulSet.php index 5d68df4b..ccb91f66 100644 --- a/src/Kinds/K8sStatefulSet.php +++ b/src/Kinds/K8sStatefulSet.php @@ -72,7 +72,7 @@ public function setUpdateStrategy(string $strategy, int $partition = 0) /** * Set the statefulset service. * - * @param \RenokiCo\PhpK8s\Kinds\K8sService|string $service + * @param K8sService|string $service * @return $this */ public function setService($service) @@ -97,7 +97,7 @@ public function getService() /** * Get the K8sService instance. * - * @return null|\RenokiCo\PhpK8s\Kinds\K8sService + * @return null|K8sService */ public function getServiceInstance() { diff --git a/tests/ContainerTest.php b/tests/ContainerTest.php index 89657163..fb01309b 100644 --- a/tests/ContainerTest.php +++ b/tests/ContainerTest.php @@ -14,7 +14,7 @@ public function test_container_build() $volume = K8s::volume()->awsEbs('vol-1234', 'ext3'); - $container->setImage('nginx', '1.4') + $container->setImage('public.ecr.aws/docker/library/nginx', '1.23') ->setEnv(['key' => 'value']) ->addEnvs(['key2' => 'value2']) ->addSecretKeyRefs(['SECRET_ONE' => ['secret_ref_name', 'secret_ref_key']]) @@ -55,7 +55,7 @@ public function test_container_build() ->setSuccessThreshold(2) ); - $this->assertEquals('nginx:1.4', $container->getImage()); + $this->assertStringEndsWith('nginx:1.23', $container->getImage()); $this->assertEquals([ ['name' => 'key', 'value' => 'value'], ['name' => 'key2', 'value' => 'value2'], @@ -95,7 +95,7 @@ public function test_container_build() $container->removeEnv(); $this->assertFalse($container->isReady()); - $this->assertEquals('nginx:1.4', $container->getImage()); + $this->assertStringEndsWith('nginx:1.23', $container->getImage()); $this->assertEquals([], $container->getEnv([])); $this->assertEquals(['--test'], $container->getArgs()); $this->assertEquals([ diff --git a/tests/CronJobTest.php b/tests/CronJobTest.php index 29417221..8961c420 100644 --- a/tests/CronJobTest.php +++ b/tests/CronJobTest.php @@ -10,14 +10,14 @@ use RenokiCo\PhpK8s\Kinds\K8sJob; use RenokiCo\PhpK8s\ResourcesList; -class CronCronJobTest extends TestCase +class CronJobTest extends TestCase { public function test_cronjob_build() { $pi = K8s::container() ->setName('pi') - ->setImage('perl') - ->setCommand(['perl', '-Mbignum=bpi', '-wle', 'print bpi(2000)']); + ->setImage('public.ecr.aws/docker/library/perl') + ->setCommand(['perl', '-Mbignum=bpi', '-wle', 'print bpi(200)']); $pod = $this->cluster->pod() ->setName('perl') @@ -39,7 +39,7 @@ public function test_cronjob_build() ->setJobTemplate($job) ->setSchedule(CronExpression::factory('* * * * *')); - $this->assertEquals('batch/v1beta1', $cronjob->getApiVersion()); + $this->assertEquals('batch/v1', $cronjob->getApiVersion()); $this->assertEquals('pi', $cronjob->getName()); $this->assertEquals(['tier' => 'backend'], $cronjob->getLabels()); $this->assertEquals(['perl/annotation' => 'yes'], $cronjob->getAnnotations()); @@ -53,8 +53,8 @@ public function test_cronjob_from_yaml() { $pi = K8s::container() ->setName('pi') - ->setImage('perl') - ->setCommand(['perl', '-Mbignum=bpi', '-wle', 'print bpi(2000)']); + ->setImage('public.ecr.aws/docker/library/perl') + ->setCommand(['perl', '-Mbignum=bpi', '-wle', 'print bpi(200)']); $pod = $this->cluster->pod() ->setName('perl') @@ -64,7 +64,7 @@ public function test_cronjob_from_yaml() $cronjob = $this->cluster->fromYamlFile(__DIR__.'/yaml/cronjob.yaml'); - $this->assertEquals('batch/v1beta1', $cronjob->getApiVersion()); + $this->assertEquals('batch/v1', $cronjob->getApiVersion()); $this->assertEquals('pi', $cronjob->getName()); $this->assertEquals(['tier' => 'backend'], $cronjob->getLabels()); $this->assertEquals(['perl/annotation' => 'yes'], $cronjob->getAnnotations()); @@ -87,28 +87,28 @@ public function test_cronjob_api_interaction() public function runCreationTests() { - $pi = K8s::container() - ->setName('pi') - ->setImage('perl', '5.34.0') - ->setCommand(['perl', '-Mbignum=bpi', '-wle', 'print bpi(2000)']); + $busybox = K8s::container() + ->setName('busybox-exec') + ->setImage('public.ecr.aws/docker/library/busybox') + ->setCommand(['/bin/sh', '-c', 'sleep 30']); $pod = $this->cluster->pod() - ->setName('perl') - ->setContainers([$pi]) + ->setName('sleep') + ->setContainers([$busybox]) ->restartOnFailure() ->neverRestart(); $job = $this->cluster->job() - ->setName('pi') - ->setLabels(['tier' => 'backend']) - ->setAnnotations(['perl/annotation' => 'yes']) + ->setName('sleeper') + ->setLabels(['tier' => 'useless']) + ->setAnnotations(['perl/annotation' => 'no']) ->setTTL(3600) ->setTemplate($pod); $cronjob = $this->cluster->cronjob() - ->setName('pi') - ->setLabels(['tier' => 'backend']) - ->setAnnotations(['perl/annotation' => 'yes']) + ->setName('periodic-sleep') + ->setLabels(['tier' => 'useless']) + ->setAnnotations(['perl/annotation' => 'no']) ->setJobTemplate($job) ->setSchedule(CronExpression::factory('* * * * *')); @@ -122,10 +122,10 @@ public function runCreationTests() $this->assertInstanceOf(K8sCronJob::class, $cronjob); - $this->assertEquals('batch/v1beta1', $cronjob->getApiVersion()); - $this->assertEquals('pi', $cronjob->getName()); - $this->assertEquals(['tier' => 'backend'], $cronjob->getLabels()); - $this->assertEquals(['perl/annotation' => 'yes'], $cronjob->getAnnotations()); + $this->assertEquals('batch/v1', $cronjob->getApiVersion()); + $this->assertEquals('periodic-sleep', $cronjob->getName()); + $this->assertEquals(['tier' => 'useless'], $cronjob->getLabels()); + $this->assertEquals(['perl/annotation' => 'no'], $cronjob->getAnnotations()); $this->assertEquals('Never', $pod->getRestartPolicy()); $this->assertInstanceOf(K8sJob::class, $cronjob->getJobTemplate()); @@ -135,6 +135,7 @@ public function runCreationTests() $activeJobs = $cronjob->getActiveJobs(); + // This check is sensitive to ensuring the jobs take some time to complete. while ($cronjob->getActiveJobs()->count() === 0) { dump("Waiting for the cronjob {$cronjob->getName()} to have active jobs..."); sleep(1); @@ -169,23 +170,23 @@ public function runGetAllTests() public function runGetTests() { - $cronjob = $this->cluster->getCronJobByName('pi'); + $cronjob = $this->cluster->getCronJobByName('periodic-sleep'); $this->assertInstanceOf(K8sCronJob::class, $cronjob); $this->assertTrue($cronjob->isSynced()); - $this->assertEquals('batch/v1beta1', $cronjob->getApiVersion()); - $this->assertEquals('pi', $cronjob->getName()); - $this->assertEquals(['tier' => 'backend'], $cronjob->getLabels()); - $this->assertEquals(['perl/annotation' => 'yes'], $cronjob->getAnnotations()); + $this->assertEquals('batch/v1', $cronjob->getApiVersion()); + $this->assertEquals('periodic-sleep', $cronjob->getName()); + $this->assertEquals(['tier' => 'useless'], $cronjob->getLabels()); + $this->assertEquals(['perl/annotation' => 'no'], $cronjob->getAnnotations()); $this->assertInstanceOf(K8sJob::class, $cronjob->getJobTemplate()); } public function runUpdateTests() { - $cronjob = $this->cluster->getCronJobByName('pi'); + $cronjob = $this->cluster->getCronJobByName('periodic-sleep'); $this->assertTrue($cronjob->isSynced()); @@ -195,9 +196,9 @@ public function runUpdateTests() $this->assertTrue($cronjob->isSynced()); - $this->assertEquals('batch/v1beta1', $cronjob->getApiVersion()); - $this->assertEquals('pi', $cronjob->getName()); - $this->assertEquals(['tier' => 'backend'], $cronjob->getLabels()); + $this->assertEquals('batch/v1', $cronjob->getApiVersion()); + $this->assertEquals('periodic-sleep', $cronjob->getName()); + $this->assertEquals(['tier' => 'useless'], $cronjob->getLabels()); $this->assertEquals([], $cronjob->getAnnotations()); $this->assertInstanceOf(K8sJob::class, $cronjob->getJobTemplate()); @@ -205,7 +206,7 @@ public function runUpdateTests() public function runDeletionTests() { - $cronjob = $this->cluster->getCronJobByName('pi'); + $cronjob = $this->cluster->getCronJobByName('periodic-sleep'); $this->assertTrue($cronjob->delete()); @@ -216,13 +217,13 @@ public function runDeletionTests() $this->expectException(KubernetesAPIException::class); - $this->cluster->getCronJobByName('pi'); + $this->cluster->getCronJobByName('periodic-sleep'); } public function runWatchAllTests() { $watch = $this->cluster->cronjob()->watchAll(function ($type, $cronjob) { - if ($cronjob->getName() === 'pi') { + if ($cronjob->getName() === 'periodic-sleep') { return true; } }, ['timeoutSeconds' => 10]); @@ -232,8 +233,8 @@ public function runWatchAllTests() public function runWatchTests() { - $watch = $this->cluster->cronjob()->watchByName('pi', function ($type, $cronjob) { - return $cronjob->getName() === 'pi'; + $watch = $this->cluster->cronjob()->watchByName('periodic-sleep', function ($type, $cronjob) { + return $cronjob->getName() === 'periodic-sleep'; }, ['timeoutSeconds' => 10]); $this->assertTrue($watch); diff --git a/tests/DaemonSetTest.php b/tests/DaemonSetTest.php index 83fe4565..4f99af64 100644 --- a/tests/DaemonSetTest.php +++ b/tests/DaemonSetTest.php @@ -14,7 +14,7 @@ public function test_daemon_set_build() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]); @@ -43,7 +43,7 @@ public function test_daemon_set_from_yaml() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]); @@ -77,7 +77,7 @@ public function runCreationTests() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]) diff --git a/tests/DeploymentTest.php b/tests/DeploymentTest.php index 2092c2c0..9fd09a9a 100644 --- a/tests/DeploymentTest.php +++ b/tests/DeploymentTest.php @@ -14,7 +14,7 @@ public function test_deployment_build() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]); @@ -44,7 +44,7 @@ public function test_deployment_from_yaml() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]); @@ -82,7 +82,7 @@ public function runCreationTests() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]) diff --git a/tests/EventTest.php b/tests/EventTest.php index 513b030f..0df2bafe 100644 --- a/tests/EventTest.php +++ b/tests/EventTest.php @@ -23,7 +23,7 @@ public function runCreationTests() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]) diff --git a/tests/HorizontalPodAutoscalerTest.php b/tests/HorizontalPodAutoscalerTest.php index bd762807..44301edb 100644 --- a/tests/HorizontalPodAutoscalerTest.php +++ b/tests/HorizontalPodAutoscalerTest.php @@ -15,7 +15,7 @@ public function test_horizontal_pod_autoscaler_build() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]); @@ -42,7 +42,7 @@ public function test_horizontal_pod_autoscaler_build() ->min(1) ->max(10); - $this->assertEquals('autoscaling/v2beta2', $hpa->getApiVersion()); + $this->assertEquals('autoscaling/v2', $hpa->getApiVersion()); $this->assertEquals('mysql-hpa', $hpa->getName()); $this->assertEquals(['tier' => 'backend'], $hpa->getLabels()); $this->assertEquals([$cpuMetric->toArray()], $hpa->getMetrics()); @@ -54,7 +54,7 @@ public function test_horizontal_pod_autoscaler_from_yaml() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]); @@ -74,7 +74,7 @@ public function test_horizontal_pod_autoscaler_from_yaml() $hpa = $this->cluster->fromYamlFile(__DIR__.'/yaml/hpa.yaml'); - $this->assertEquals('autoscaling/v2beta2', $hpa->getApiVersion()); + $this->assertEquals('autoscaling/v2', $hpa->getApiVersion()); $this->assertEquals('mysql-hpa', $hpa->getName()); $this->assertEquals(['tier' => 'backend'], $hpa->getLabels()); $this->assertEquals([$cpuMetric->toArray()], $hpa->getMetrics()); @@ -97,7 +97,7 @@ public function runCreationTests() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]) @@ -141,7 +141,7 @@ public function runCreationTests() $this->assertInstanceOf(K8sDeployment::class, $dep); $this->assertInstanceOf(K8sHorizontalPodAutoscaler::class, $hpa); - $this->assertEquals('autoscaling/v2beta2', $hpa->getApiVersion()); + $this->assertEquals('autoscaling/v2', $hpa->getApiVersion()); $this->assertEquals('mysql-hpa', $hpa->getName()); $this->assertEquals(['tier' => 'backend'], $hpa->getLabels()); $this->assertEquals([$cpuMetric->toArray()], $hpa->getMetrics()); @@ -203,7 +203,7 @@ public function runGetTests() $cpuMetric = K8s::metric()->cpu()->averageUtilization(70); - $this->assertEquals('autoscaling/v2beta2', $hpa->getApiVersion()); + $this->assertEquals('autoscaling/v2', $hpa->getApiVersion()); $this->assertEquals('mysql-hpa', $hpa->getName()); $this->assertEquals(['tier' => 'backend'], $hpa->getLabels()); $this->assertEquals([$cpuMetric->toArray()], $hpa->getMetrics()); @@ -231,7 +231,7 @@ public function runUpdateTests() $cpuMetric = K8s::metric()->cpu()->averageUtilization(70); - $this->assertEquals('autoscaling/v2beta2', $hpa->getApiVersion()); + $this->assertEquals('autoscaling/v2', $hpa->getApiVersion()); $this->assertEquals('mysql-hpa', $hpa->getName()); $this->assertEquals(['tier' => 'backend'], $hpa->getLabels()); $this->assertEquals([$cpuMetric->toArray()], $hpa->getMetrics()); diff --git a/tests/JobTest.php b/tests/JobTest.php index 97cb2e54..72e7664c 100644 --- a/tests/JobTest.php +++ b/tests/JobTest.php @@ -14,8 +14,8 @@ public function test_job_build() { $pi = K8s::container() ->setName('pi') - ->setImage('perl') - ->setCommand(['perl', '-Mbignum=bpi', '-wle', 'print bpi(2000)']); + ->setImage('public.ecr.aws/docker/library/perl') + ->setCommand(['perl', '-Mbignum=bpi', '-wle', 'print bpi(200)']); $pod = $this->cluster->pod() ->setName('perl') @@ -25,14 +25,14 @@ public function test_job_build() $job = $this->cluster->job() ->setName('pi') - ->setLabels(['tier' => 'backend']) + ->setLabels(['tier' => 'compute']) ->setAnnotations(['perl/annotation' => 'yes']) ->setTTL(3600) ->setTemplate($pod); $this->assertEquals('batch/v1', $job->getApiVersion()); $this->assertEquals('pi', $job->getName()); - $this->assertEquals(['tier' => 'backend'], $job->getLabels()); + $this->assertEquals(['tier' => 'compute'], $job->getLabels()); $this->assertEquals(['perl/annotation' => 'yes'], $job->getAnnotations()); $this->assertEquals($pod->getName(), $job->getTemplate()->getName()); $this->assertEquals('Never', $pod->getRestartPolicy()); @@ -44,8 +44,8 @@ public function test_job_from_yaml() { $pi = K8s::container() ->setName('pi') - ->setImage('perl') - ->setCommand(['perl', '-Mbignum=bpi', '-wle', 'print bpi(2000)']); + ->setImage('public.ecr.aws/docker/library/perl') + ->setCommand(['perl', '-Mbignum=bpi', '-wle', 'print bpi(200)']); $pod = $this->cluster->pod() ->setName('perl') @@ -57,7 +57,7 @@ public function test_job_from_yaml() $this->assertEquals('batch/v1', $job->getApiVersion()); $this->assertEquals('pi', $job->getName()); - $this->assertEquals(['tier' => 'backend'], $job->getLabels()); + $this->assertEquals(['tier' => 'compute'], $job->getLabels()); $this->assertEquals(['perl/annotation' => 'yes'], $job->getAnnotations()); $this->assertEquals($pod->getName(), $job->getTemplate()->getName()); $this->assertEquals('Never', $pod->getRestartPolicy()); @@ -80,18 +80,18 @@ public function runCreationTests() { $pi = K8s::container() ->setName('pi') - ->setImage('perl', '5.34.0') - ->setCommand(['perl', '-Mbignum=bpi', '-wle', 'print bpi(2000)']); + ->setImage('public.ecr.aws/docker/library/perl', '5.36') + ->setCommand(['perl', '-Mbignum=bpi', '-wle', 'print bpi(200)']); $pod = $this->cluster->pod() ->setName('perl') - ->setLabels(['tier' => 'backend']) + ->setLabels(['tier' => 'compute']) ->setContainers([$pi]) ->neverRestart(); $job = $this->cluster->job() ->setName('pi') - ->setLabels(['tier' => 'backend']) + ->setLabels(['tier' => 'compute']) ->setAnnotations(['perl/annotation' => 'yes']) ->setTTL(3600) ->setTemplate($pod); @@ -108,12 +108,12 @@ public function runCreationTests() $this->assertEquals('batch/v1', $job->getApiVersion()); $this->assertEquals('pi', $job->getName()); - $this->assertEquals(['tier' => 'backend'], $job->getLabels()); + $this->assertEquals(['tier' => 'compute'], $job->getLabels()); - if ($this->cluster->olderThan('1.23.0') || $this->cluster->newerThan('1.24.0')) { - $this->assertEquals(['perl/annotation' => 'yes'], $job->getAnnotations()); - } else { - $this->assertEquals(['perl/annotation' => 'yes', 'batch.kubernetes.io/job-tracking' => ''], $job->getAnnotations()); + $annotations = $job->getAnnotations(); + foreach (['perl/annotation' => 'yes'] as $key => $value) { + $this->assertContains($key, array_keys($annotations), "Annotation $key missing"); + $this->assertEquals($value, $annotations[$key]); } $this->assertEquals($pod->getName(), $job->getTemplate()->getName()); @@ -131,7 +131,7 @@ public function runCreationTests() K8sJob::selectPods(function ($job) { $this->assertInstanceOf(K8sJob::class, $job); - return ['tier' => 'backend']; + return ['tier' => 'compute']; }); $pods = $job->getPods(); @@ -149,7 +149,7 @@ public function runCreationTests() $job->refresh(); while (! $completionTime = $job->getCompletionTime()) { - dump("Waiting for the competion time report of {$job->getName()}..."); + dump("Waiting for the completion time report of {$job->getName()}..."); sleep(1); $job->refresh(); } @@ -185,12 +185,12 @@ public function runGetTests() $this->assertEquals('batch/v1', $job->getApiVersion()); $this->assertEquals('pi', $job->getName()); - $this->assertEquals(['tier' => 'backend'], $job->getLabels()); + $this->assertEquals(['tier' => 'compute'], $job->getLabels()); - if ($this->cluster->olderThan('1.23.0') || $this->cluster->newerThan('1.24.0')) { - $this->assertEquals(['perl/annotation' => 'yes'], $job->getAnnotations()); - } else { - $this->assertEquals(['perl/annotation' => 'yes', 'batch.kubernetes.io/job-tracking' => ''], $job->getAnnotations()); + $annotations = $job->getAnnotations(); + foreach (['perl/annotation' => 'yes'] as $key => $value) { + $this->assertContains($key, array_keys($annotations), "Annotation $key missing"); + $this->assertEquals($value, $annotations[$key]); } $this->assertInstanceOf(K8sPod::class, $job->getTemplate()); @@ -210,8 +210,7 @@ public function runUpdateTests() $this->assertEquals('batch/v1', $job->getApiVersion()); $this->assertEquals('pi', $job->getName()); - $this->assertEquals(['tier' => 'backend'], $job->getLabels()); - $this->assertEquals([], $job->getAnnotations()); + $this->assertEquals(['tier' => 'compute'], $job->getLabels()); $this->assertInstanceOf(K8sPod::class, $job->getTemplate()); } diff --git a/tests/PersistentVolumeClaimTest.php b/tests/PersistentVolumeClaimTest.php index f6177a5d..2ba30c97 100644 --- a/tests/PersistentVolumeClaimTest.php +++ b/tests/PersistentVolumeClaimTest.php @@ -78,14 +78,16 @@ public function runCreationTests() $this->assertEquals(['ReadWriteOnce'], $pvc->getAccessModes()); $this->assertEquals('standard', $pvc->getStorageClass()); - while (! $pvc->isBound()) { - dump("Waiting for PVC {$pvc->getName()} to be bound..."); - sleep(1); - $pvc->refresh(); - } + if ($standard->getVolumeBindingMode() == 'Immediate') { + while (! $pvc->isBound()) { + dump("Waiting for PVC {$pvc->getName()} to be bound..."); + sleep(1); + $pvc->refresh(); + } - $this->assertFalse($pvc->isAvailable()); - $this->assertTrue($pvc->isBound()); + $this->assertFalse($pvc->isAvailable()); + $this->assertTrue($pvc->isBound()); + } } public function runGetAllTests() diff --git a/tests/PodDisruptionBudgetTest.php b/tests/PodDisruptionBudgetTest.php index c597a571..a6dcc67e 100644 --- a/tests/PodDisruptionBudgetTest.php +++ b/tests/PodDisruptionBudgetTest.php @@ -20,7 +20,7 @@ public function test_pod_disruption_budget_build() ->setMinAvailable(1) ->setMaxUnavailable('25%'); - $this->assertEquals('policy/v1beta1', $pdb->getApiVersion()); + $this->assertEquals('policy/v1', $pdb->getApiVersion()); $this->assertEquals('mysql-pdb', $pdb->getName()); $this->assertEquals(['matchLabels' => ['tier' => 'backend']], $pdb->getSelectors()); $this->assertEquals(['tier' => 'backend'], $pdb->getLabels()); @@ -33,7 +33,7 @@ public function test_pod_disruption_budget_from_yaml() { [$pdb1, $pdb2] = $this->cluster->fromYamlFile(__DIR__.'/yaml/pdb.yaml'); - $this->assertEquals('policy/v1beta1', $pdb1->getApiVersion()); + $this->assertEquals('policy/v1', $pdb1->getApiVersion()); $this->assertEquals('mysql-pdb', $pdb1->getName()); $this->assertEquals(['matchLabels' => ['tier' => 'backend']], $pdb1->getSelectors()); $this->assertEquals(['tier' => 'backend'], $pdb1->getLabels()); @@ -41,7 +41,7 @@ public function test_pod_disruption_budget_from_yaml() $this->assertEquals('25%', $pdb1->getMaxUnavailable()); $this->assertEquals(null, $pdb1->getMinAvailable()); - $this->assertEquals('policy/v1beta1', $pdb2->getApiVersion()); + $this->assertEquals('policy/v1', $pdb2->getApiVersion()); $this->assertEquals('mysql-pdb', $pdb2->getName()); $this->assertEquals(['matchLabels' => ['tier' => 'backend']], $pdb2->getSelectors()); $this->assertEquals(['tier' => 'backend'], $pdb2->getLabels()); @@ -65,7 +65,7 @@ public function runCreationTests() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]) @@ -107,7 +107,7 @@ public function runCreationTests() $this->assertInstanceOf(K8sDeployment::class, $dep); $this->assertInstanceOf(K8sPodDisruptionBudget::class, $pdb); - $this->assertEquals('policy/v1beta1', $pdb->getApiVersion()); + $this->assertEquals('policy/v1', $pdb->getApiVersion()); $this->assertEquals('mysql-pdb', $pdb->getName()); $this->assertEquals(['matchLabels' => ['tier' => 'backend']], $pdb->getSelectors()); $this->assertEquals(['tier' => 'backend'], $pdb->getLabels()); @@ -142,7 +142,7 @@ public function runGetTests() $this->assertTrue($pdb->isSynced()); - $this->assertEquals('policy/v1beta1', $pdb->getApiVersion()); + $this->assertEquals('policy/v1', $pdb->getApiVersion()); $this->assertEquals('mysql-pdb', $pdb->getName()); $this->assertEquals(['matchLabels' => ['tier' => 'backend']], $pdb->getSelectors()); $this->assertEquals(['tier' => 'backend'], $pdb->getLabels()); @@ -153,17 +153,26 @@ public function runGetTests() public function runUpdateTests() { - $pdb = $this->cluster->getPodDisruptionBudgetByName('mysql-pdb'); - - $this->assertTrue($pdb->isSynced()); - - $pdb->setMinAvailable('25%'); - - $pdb->createOrUpdate(); + $backoff = 0; + do { + try { + $pdb = $this->cluster->getPodDisruptionBudgetByName('mysql-pdb')->setMinAvailable('25%')->createOrUpdate(); + } catch (KubernetesAPIException $e) { + if ($e->getCode() == 409) { + sleep(2 * $backoff); + $backoff++; + } else { + throw $e; + } + if ($backoff > 3) { + break; + } + } + } while (! isset($pdb)); $this->assertTrue($pdb->isSynced()); - $this->assertEquals('policy/v1beta1', $pdb->getApiVersion()); + $this->assertEquals('policy/v1', $pdb->getApiVersion()); $this->assertEquals('mysql-pdb', $pdb->getName()); $this->assertEquals(['matchLabels' => ['tier' => 'backend']], $pdb->getSelectors()); $this->assertEquals(['tier' => 'backend'], $pdb->getLabels()); diff --git a/tests/PodTest.php b/tests/PodTest.php index 866445c2..6cbd737c 100644 --- a/tests/PodTest.php +++ b/tests/PodTest.php @@ -15,7 +15,7 @@ public function test_pod_build() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]) @@ -24,7 +24,7 @@ public function test_pod_build() $busybox = K8s::container() ->setName('busybox') - ->setImage('busybox') + ->setImage('public.ecr.aws/docker/library/busybox') ->setCommand(['/bin/sh']); $pod = $this->cluster->pod() @@ -65,7 +65,7 @@ public function test_pod_from_yaml() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]) @@ -74,7 +74,7 @@ public function test_pod_from_yaml() $busybox = K8s::container() ->setName('busybox') - ->setImage('busybox') + ->setImage('public.ecr.aws/docker/library/busybox') ->setCommand(['/bin/sh']); $pod = $this->cluster->fromYamlFile(__DIR__.'/yaml/pod.yaml'); @@ -112,7 +112,7 @@ public function test_pod_exec() { $busybox = K8s::container() ->setName('busybox-exec') - ->setImage('busybox') + ->setImage('public.ecr.aws/docker/library/busybox') ->setCommand(['/bin/sh', '-c', 'sleep 7200']); $pod = $this->cluster->pod() @@ -127,14 +127,10 @@ public function test_pod_exec() } $messages = $pod->exec(['/bin/sh', '-c', 'echo 1 && echo 2 && echo 3'], 'busybox-exec'); - - $hasDesiredOutput = collect($messages)->where('channel', 'stdout')->filter(function ($message) { - return Str::contains($message['output'], '1') - && Str::contains($message['output'], '2') - && Str::contains($message['output'], '3'); - })->isNotEmpty(); - - $this->assertTrue($hasDesiredOutput); + $desiredOutput = collect($messages)->where('channel', 'stdout')->reduce(function (?string $carry, array $message) { + return $carry .= preg_replace('/\s+/', '', $message['output']); + }); + $this->assertEquals('123', $desiredOutput); $pod->delete(); } @@ -143,7 +139,7 @@ public function test_pod_attach() { $mysql = K8s::container() ->setName('mysql-attach') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]) @@ -174,7 +170,7 @@ public function runCreationTests() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]) @@ -183,7 +179,7 @@ public function runCreationTests() $busybox = K8s::container() ->setName('busybox') - ->setImage('busybox') + ->setImage('public.ecr.aws/docker/library/busybox') ->setCommand(['/bin/sh']); $pod = $this->cluster->pod() @@ -217,8 +213,8 @@ public function runCreationTests() $pod->refresh(); - $this->assertEquals('busybox:latest', $pod->getInitContainer('busybox')->getImage()); - $this->assertEquals('mysql:5.7', $pod->getContainer('mysql')->getImage()); + $this->assertStringEndsWith('busybox:latest', $pod->getInitContainer('busybox')->getImage()); + $this->assertStringEndsWith('mysql:5.7', $pod->getContainer('mysql')->getImage()); $this->assertTrue($pod->containersAreReady()); $this->assertTrue($pod->initContainersAreReady()); diff --git a/tests/StatefulSetTest.php b/tests/StatefulSetTest.php index f4da6bf9..ea0e213e 100644 --- a/tests/StatefulSetTest.php +++ b/tests/StatefulSetTest.php @@ -15,7 +15,7 @@ public function test_stateful_set_build() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]); @@ -65,7 +65,7 @@ public function test_stateful_set_from_yaml() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]); @@ -120,7 +120,7 @@ public function runCreationTests() { $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->setPorts([ ['name' => 'mysql', 'protocol' => 'TCP', 'containerPort' => 3306], ]) diff --git a/tests/VolumeTest.php b/tests/VolumeTest.php index c9601d0b..8b3d4820 100644 --- a/tests/VolumeTest.php +++ b/tests/VolumeTest.php @@ -15,7 +15,7 @@ public function test_volume_empty_directory() $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->addMountedVolumes([$mountedVolume]) ->setMountedVolumes([$mountedVolume]); @@ -54,7 +54,7 @@ public function test_volume_config_map() $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->addMountedVolumes([$mountedVolume]); $pod = K8s::pod() @@ -92,7 +92,7 @@ public function test_volume_secret() $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->addMountedVolumes([$mountedVolume]); $pod = K8s::pod() @@ -123,7 +123,7 @@ public function test_volume_gce_pd() $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->addMountedVolumes([$mountedVolume]); $pod = K8s::pod() @@ -156,7 +156,7 @@ public function test_volume_aws_ebs() $mysql = K8s::container() ->setName('mysql') - ->setImage('mysql', '5.7') + ->setImage('public.ecr.aws/docker/library/mysql', '5.7') ->addMountedVolumes([$mountedVolume]); $pod = K8s::pod() diff --git a/tests/yaml/cronjob.yaml b/tests/yaml/cronjob.yaml index 79083f24..4545bc50 100644 --- a/tests/yaml/cronjob.yaml +++ b/tests/yaml/cronjob.yaml @@ -1,4 +1,4 @@ -apiVersion: batch/v1beta1 +apiVersion: batch/v1 kind: CronJob metadata: name: pi @@ -12,8 +12,6 @@ spec: spec: ttlSecondsAfterFinished: 3600 template: - apiVersion: batch/v1 - kind: Job metadata: name: pi labels: @@ -23,13 +21,9 @@ spec: spec: containers: - name: pi - image: perl:latest + image: public.ecr.aws/docker/library/perl:latest command: - perl - Mbignum=bpi - -wle - - print bpi(2000) - kind: Pod - apiVersion: v1 - apiVersion: batch/v1 - kind: Job + - print bpi(200) diff --git a/tests/yaml/daemonset.yaml b/tests/yaml/daemonset.yaml index 2139a051..1fa4ced2 100644 --- a/tests/yaml/daemonset.yaml +++ b/tests/yaml/daemonset.yaml @@ -5,16 +5,18 @@ metadata: labels: tier: backend spec: + selector: + matchLabels: + name: mysql-daemonset template: metadata: name: mysql + labels: + name: mysql-daemonset spec: containers: - name: mysql - image: mysql:5.7 + image: public.ecr.aws/docker/library/mysql:5.7 ports: - name: mysql protocol: TCP - containerPort: 3306 - kind: Pod - apiVersion: v1 diff --git a/tests/yaml/deployment.yaml b/tests/yaml/deployment.yaml index bc936424..cde0d05f 100644 --- a/tests/yaml/deployment.yaml +++ b/tests/yaml/deployment.yaml @@ -7,17 +7,20 @@ metadata: annotations: mysql/annotation: "yes" spec: + selector: + matchLabels: + name: mysql-deployment replicas: 3 template: metadata: name: mysql + labels: + name: mysql-deployment spec: containers: - name: mysql - image: mysql:5.7 + image: public.ecr.aws/docker/library/mysql:5.7 ports: - name: mysql protocol: TCP containerPort: 3306 - kind: Pod - apiVersion: v1 diff --git a/tests/yaml/hpa.yaml b/tests/yaml/hpa.yaml index fe2013a4..33c55e6e 100644 --- a/tests/yaml/hpa.yaml +++ b/tests/yaml/hpa.yaml @@ -1,4 +1,4 @@ -apiVersion: autoscaling/v2beta2 +apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: mysql-hpa diff --git a/tests/yaml/job.yaml b/tests/yaml/job.yaml index de445f98..2d38d7e8 100644 --- a/tests/yaml/job.yaml +++ b/tests/yaml/job.yaml @@ -3,7 +3,7 @@ kind: Job metadata: name: pi labels: - tier: backend + tier: compute annotations: perl/annotation: "yes" spec: @@ -14,11 +14,9 @@ spec: spec: containers: - name: pi - image: perl:latest + image: public.ecr.aws/docker/library/perl:latest command: - perl - Mbignum=bpi - -wle - - print bpi(2000) - kind: Pod - apiVersion: v1 + - print bpi(200) diff --git a/tests/yaml/pdb.yaml b/tests/yaml/pdb.yaml index 9ba6939a..d6583b37 100644 --- a/tests/yaml/pdb.yaml +++ b/tests/yaml/pdb.yaml @@ -1,4 +1,4 @@ -apiVersion: policy/v1beta1 +apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: mysql-pdb @@ -12,7 +12,7 @@ spec: tier: backend maxUnavailable: 25% --- -apiVersion: policy/v1beta1 +apiVersion: policy/v1 kind: PodDisruptionBudget metadata: name: mysql-pdb diff --git a/tests/yaml/pod.yaml b/tests/yaml/pod.yaml index 1daff0cd..8f5840c3 100644 --- a/tests/yaml/pod.yaml +++ b/tests/yaml/pod.yaml @@ -9,12 +9,12 @@ metadata: spec: initContainers: - name: busybox - image: busybox:latest + image: public.ecr.aws/docker/library/busybox:latest command: - /bin/sh containers: - name: mysql - image: mysql:5.7 + image: public.ecr.aws/docker/library/mysql:5.7 ports: - name: mysql protocol: TCP diff --git a/tests/yaml/statefulset.yaml b/tests/yaml/statefulset.yaml index 8d59aadf..024fb0f6 100644 --- a/tests/yaml/statefulset.yaml +++ b/tests/yaml/statefulset.yaml @@ -7,15 +7,20 @@ metadata: annotations: mysql/annotation: "yes" spec: + selector: + matchLabels: + name: mysql-statefulset replicas: 3 serviceName: mysql template: metadata: name: mysql + labels: + name: mysql-statefulset spec: containers: - name: mysql - image: mysql:5.7 + image: public.ecr.aws/docker/library/mysql:5.7 ports: - name: mysql protocol: TCP