44
55use RenokiCo \PhpK8s \KubernetesCluster as PhpK8sCluster ;
66
7+ /**
8+ * @see \RenokiCo\PhpK8s\KubernetesCluster
9+ */
710class 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