4
4
5
5
use RenokiCo \PhpK8s \KubernetesCluster as PhpK8sCluster ;
6
6
7
+ /**
8
+ * @see \RenokiCo\PhpK8s\KubernetesCluster
9
+ */
7
10
class KubernetesCluster
8
11
{
9
12
/**
@@ -28,7 +31,7 @@ public function __construct(array $config)
28
31
* Switch the connection.
29
32
*
30
33
* @param string $connection
31
- * @return $this
34
+ * @return \RenokiCo\LaravelK8s\KubernetesCluster
32
35
*/
33
36
public function connection (string $ connection )
34
37
{
@@ -47,8 +50,6 @@ public function connection(string $connection)
47
50
*/
48
51
protected function loadFromConfig (array $ config )
49
52
{
50
- $ this ->cluster = new PhpK8sCluster ('http://127.0.0.1:8080 ' );
51
-
52
53
switch ($ config ['driver ' ] ?? null ) {
53
54
case 'kubeconfig ' : $ this ->configureWithKubeConfigFile ($ config ); break ;
54
55
case 'http ' : $ this ->configureWithHttpAuth ($ config ); break ;
@@ -66,7 +67,7 @@ protected function loadFromConfig(array $config)
66
67
*/
67
68
protected function configureWithKubeConfigFile (array $ config )
68
69
{
69
- $ this ->cluster -> fromKubeConfigYamlFile (
70
+ $ this ->cluster = PhpK8sCluster:: fromKubeConfigYamlFile (
70
71
$ config ['path ' ], $ config ['context ' ]
71
72
);
72
73
}
@@ -79,7 +80,7 @@ protected function configureWithKubeConfigFile(array $config)
79
80
*/
80
81
protected function configureWithHttpAuth (array $ config )
81
82
{
82
- $ this ->cluster = new PhpK8sCluster ($ config ['host ' ]);
83
+ $ this ->cluster = PhpK8sCluster:: fromUrl ($ config ['host ' ]);
83
84
84
85
if ($ config ['ssl ' ]['verify ' ] ?? true ) {
85
86
$ this ->cluster ->withCertificate (
@@ -111,7 +112,7 @@ protected function configureWithHttpAuth(array $config)
111
112
*/
112
113
protected function configureWithToken (array $ config )
113
114
{
114
- $ this ->cluster = new PhpK8sCluster ($ config ['host ' ]);
115
+ $ this ->cluster = PhpK8sCluster:: fromUrl ($ config ['host ' ]);
115
116
116
117
if ($ config ['ssl ' ]['verify ' ] ?? true ) {
117
118
$ this ->cluster ->withCertificate (
@@ -140,9 +141,7 @@ protected function configureWithToken(array $config)
140
141
*/
141
142
protected function configureInCluster (array $ config )
142
143
{
143
- $ this ->cluster = new PhpK8sCluster ($ config ['host ' ] ?? 'https://kubernetes.default.svc.cluster.local ' );
144
-
145
- $ this ->cluster ->inClusterConfiguration ();
144
+ $ this ->cluster = PhpK8sCluster::inClusterConfiguration ();
146
145
}
147
146
148
147
/**
0 commit comments