Skip to content

Commit 838233a

Browse files
committed
Upgraded PHP K8s
1 parent 2c7d9cb commit 838233a

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
}
1313
],
1414
"require": {
15-
"renoki-co/php-k8s": "^2.2"
15+
"renoki-co/php-k8s": "^3.0"
1616
},
1717
"autoload": {
1818
"psr-4": {

src/KubernetesCluster.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use RenokiCo\PhpK8s\KubernetesCluster as PhpK8sCluster;
66

7+
/**
8+
* @see \RenokiCo\PhpK8s\KubernetesCluster
9+
*/
710
class KubernetesCluster
811
{
912
/**
@@ -28,7 +31,7 @@ public function __construct(array $config)
2831
* Switch the connection.
2932
*
3033
* @param string $connection
31-
* @return $this
34+
* @return \RenokiCo\LaravelK8s\KubernetesCluster
3235
*/
3336
public function connection(string $connection)
3437
{
@@ -47,8 +50,6 @@ public function connection(string $connection)
4750
*/
4851
protected function loadFromConfig(array $config)
4952
{
50-
$this->cluster = new PhpK8sCluster('http://127.0.0.1:8080');
51-
5253
switch ($config['driver'] ?? null) {
5354
case 'kubeconfig': $this->configureWithKubeConfigFile($config); break;
5455
case 'http': $this->configureWithHttpAuth($config); break;
@@ -66,7 +67,7 @@ protected function loadFromConfig(array $config)
6667
*/
6768
protected function configureWithKubeConfigFile(array $config)
6869
{
69-
$this->cluster->fromKubeConfigYamlFile(
70+
$this->cluster = PhpK8sCluster::fromKubeConfigYamlFile(
7071
$config['path'], $config['context']
7172
);
7273
}
@@ -79,7 +80,7 @@ protected function configureWithKubeConfigFile(array $config)
7980
*/
8081
protected function configureWithHttpAuth(array $config)
8182
{
82-
$this->cluster = new PhpK8sCluster($config['host']);
83+
$this->cluster = PhpK8sCluster::fromUrl($config['host']);
8384

8485
if ($config['ssl']['verify'] ?? true) {
8586
$this->cluster->withCertificate(
@@ -111,7 +112,7 @@ protected function configureWithHttpAuth(array $config)
111112
*/
112113
protected function configureWithToken(array $config)
113114
{
114-
$this->cluster = new PhpK8sCluster($config['host']);
115+
$this->cluster = PhpK8sCluster::fromUrl($config['host']);
115116

116117
if ($config['ssl']['verify'] ?? true) {
117118
$this->cluster->withCertificate(
@@ -140,9 +141,7 @@ protected function configureWithToken(array $config)
140141
*/
141142
protected function configureInCluster(array $config)
142143
{
143-
$this->cluster = new PhpK8sCluster($config['host'] ?? 'https://kubernetes.default.svc.cluster.local');
144-
145-
$this->cluster->inClusterConfiguration();
144+
$this->cluster = PhpK8sCluster::inClusterConfiguration();
146145
}
147146

148147
/**

0 commit comments

Comments
 (0)