Skip to content

WIP: initial implemention of evictions #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/Kinds/K8sEviction.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace RenokiCo\PhpK8s\Kinds;

use RenokiCo\PhpK8s\Contracts\InteractsWithK8sCluster;
use RenokiCo\PhpK8s\Contracts\Watchable;
use RenokiCo\PhpK8s\Traits\Resource\HasPods;

class K8sEviction extends K8sResource implements InteractsWithK8sCluster
{
/**
* The resource Kind parameter.
*
* @var null|string
*/
protected static $kind = 'Eviction';

/**
* Wether the resource has a namespace.
*
* @var bool
*/
protected static $namespaceable = true;

protected static $defaultVersion = "policy/v1";

/**
* Creates the path to the api-server eviction api. This is different depending on the pod and namespace
* that is getting evicted
*
* @param bool $withNamespace
* @return string
*/
public function allResourcesPath(bool $withNamespace = true): string
{
$pod = (new K8sPod())
->setNamespace($this->getNamespace())
->setName($this->getName());
Comment on lines +36 to +38
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too happy with this, feedback welcome


return $pod->resourcePath() . "/eviction";
}

}
1 change: 1 addition & 0 deletions src/KubernetesCluster.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* @method \RenokiCo\PhpK8s\ResourcesList getAllNodes(string $namespace = 'default', array $query = ['pretty' => 1])
* @method \RenokiCo\PhpK8s\Kinds\K8sEvent event(array $attributes = [])
* @method \RenokiCo\PhpK8s\Kinds\K8sEvent getEventByName(string $name, string $namespace = 'default', array $query = ['pretty' => 1])
* @method \RenokiCo\PhpK8s\Kinds\K8sEviction eviction(array $attributes = [])
* @method \RenokiCo\PhpK8s\ResourcesList getAllEventsFromAllNamespaces(array $query = ['pretty' => 1])
* @method \RenokiCo\PhpK8s\ResourcesList getAllEvents(string $namespace = 'default', array $query = ['pretty' => 1])
* @method \RenokiCo\PhpK8s\Kinds\K8sNamespace namespace(array $attributes = [])
Expand Down
13 changes: 13 additions & 0 deletions src/Traits/InitializesResources.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use RenokiCo\PhpK8s\Kinds\K8sDaemonSet;
use RenokiCo\PhpK8s\Kinds\K8sDeployment;
use RenokiCo\PhpK8s\Kinds\K8sEvent;
use RenokiCo\PhpK8s\Kinds\K8sEviction;
use RenokiCo\PhpK8s\Kinds\K8sHorizontalPodAutoscaler;
use RenokiCo\PhpK8s\Kinds\K8sIngress;
use RenokiCo\PhpK8s\Kinds\K8sJob;
Expand Down Expand Up @@ -54,6 +55,18 @@ public static function event($cluster = null, array $attributes = [])
return new K8sEvent($cluster, $attributes);
}

/**
* Create a new Eviction kind.
*
* @param \RenokiCo\PhpK8s\KubernetesCluster|null $cluster
* @param array $attributes
* @return \RenokiCo\PhpK8s\Kinds\K8sEviction
*/
public static function eviction($cluster = null, array $attributes = [])
{
return new K8sEviction($cluster, $attributes);
}

/**
* Create a new Namespace kind.
*
Expand Down