Skip to content

Commit

Permalink
Merge branch 'renoki-co:master' into feature/add-host-aliases-to-pod
Browse files Browse the repository at this point in the history
  • Loading branch information
SiebeVE authored Nov 2, 2023
2 parents 51e9a3f + 046c682 commit 21056c1
Show file tree
Hide file tree
Showing 29 changed files with 215 additions and 210 deletions.
24 changes: 14 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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: |
Expand All @@ -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: |
Expand All @@ -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: |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
],
"require": {
"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"
Expand All @@ -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": {
Expand Down
37 changes: 14 additions & 23 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Renoki Co Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
<php>
<server name="APP_ENV" value="testing" />
</php>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<include>
<directory suffix=".php">src/</directory>
</include>
</coverage>
<testsuites>
<testsuite name="Renoki Co Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<php>
<server name="APP_ENV" value="testing"/>
</php>
</phpunit>
18 changes: 10 additions & 8 deletions src/Kinds/K8sCronJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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.
Expand All @@ -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)
Expand All @@ -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)
{
Expand All @@ -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)
Expand All @@ -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)
{
Expand All @@ -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()
{
Expand All @@ -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());
});
}
}
6 changes: 3 additions & 3 deletions src/Kinds/K8sHorizontalPodAutoscaler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/Kinds/K8sJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,6 @@ public function getDurationInSeconds(): int
*/
public function hasCompleted(): bool
{
return $this->getActivePodsCount() === 0;
return ! is_null($this->getCompletionTime());
}
}
2 changes: 1 addition & 1 deletion src/Kinds/K8sPodDisruptionBudget.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/Kinds/K8sStatefulSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -97,7 +97,7 @@ public function getService()
/**
* Get the K8sService instance.
*
* @return null|\RenokiCo\PhpK8s\Kinds\K8sService
* @return null|K8sService
*/
public function getServiceInstance()
{
Expand Down
6 changes: 3 additions & 3 deletions tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']])
Expand Down Expand Up @@ -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'],
Expand Down Expand Up @@ -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([
Expand Down
Loading

0 comments on commit 21056c1

Please sign in to comment.