This commit is contained in:
parent
a01337425c
commit
efac8e346b
@ -14,16 +14,16 @@ class DeployStaticSite extends Command
|
|||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$name = $this->argument('name');
|
$name = $this->argument('name');
|
||||||
$host = $this->argument('host');
|
$host = $this->argument('host');
|
||||||
$id = $this->argument('id');
|
$id = $this->argument('id');
|
||||||
$namespace = 'hosting-deploy';
|
$namespace = 'hosting-deploy';
|
||||||
$kubeDir = storage_path("app/kube/{$name}");
|
$kubeDir = storage_path("app/kube/{$name}");
|
||||||
File::ensureDirectoryExists($kubeDir);
|
File::ensureDirectoryExists($kubeDir);
|
||||||
|
|
||||||
// 1. Generate K8s YAMLs
|
// 1. Generate K8s YAMLs
|
||||||
File::put("{$kubeDir}/deployment.yaml", $this->deployment($name,$id, $namespace));
|
File::put("{$kubeDir}/deployment.yaml", $this->deployment($name, $id, $namespace));
|
||||||
File::put("{$kubeDir}/service.yaml", $this->service($name,$id, $namespace));
|
File::put("{$kubeDir}/service.yaml", $this->service($name, $id, $namespace));
|
||||||
File::put("{$kubeDir}/ingress.yaml", $this->ingress($name,$host,$id, $namespace));
|
File::put("{$kubeDir}/ingress.yaml", $this->ingress($name, $host, $id, $namespace));
|
||||||
|
|
||||||
$this->info("✅ K8s manifests generated.");
|
$this->info("✅ K8s manifests generated.");
|
||||||
|
|
||||||
@ -38,7 +38,6 @@ class DeployStaticSite extends Command
|
|||||||
'--extra-vars', "siteid={$id}"
|
'--extra-vars', "siteid={$id}"
|
||||||
],
|
],
|
||||||
null, // cwd
|
null, // cwd
|
||||||
['HOME' => '/tmp'] // env vars
|
|
||||||
);
|
);
|
||||||
$process->setTimeout(300);
|
$process->setTimeout(300);
|
||||||
$process->run(function ($type, $buffer) {
|
$process->run(function ($type, $buffer) {
|
||||||
@ -52,7 +51,7 @@ class DeployStaticSite extends Command
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function deployment(string $name,string $id, string $namespace): string
|
private function deployment(string $name, string $id, string $namespace): string
|
||||||
{
|
{
|
||||||
return <<<YAML
|
return <<<YAML
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
@ -107,7 +106,7 @@ spec:
|
|||||||
YAML;
|
YAML;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function ingress(string $name,string $host,string $id, string $namespace): string
|
private function ingress(string $name, string $host, string $id, string $namespace): string
|
||||||
{
|
{
|
||||||
return <<<YAML
|
return <<<YAML
|
||||||
apiVersion: networking.k8s.io/v1
|
apiVersion: networking.k8s.io/v1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user