-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create commands to get volumes, and replica sets and to create and de…
…lete pods #6
- Loading branch information
Showing
17 changed files
with
363 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* PHP Kubectl terminal console | ||
* @author Flávio Gomes da Silva Lisboa <[email protected]> | ||
* @license https://www.gnu.org/licenses/lgpl-3.0.en.html | ||
*/ | ||
namespace App\Command; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Fgsl\Kubectl\KubernetesPods; | ||
use App\Helper\Timer; | ||
|
||
class CreatePodCommand extends Command | ||
{ | ||
|
||
// the name of the command (the part after "bin/console") | ||
protected static $defaultName = 'app:create-pod'; | ||
|
||
protected function configure() | ||
{ | ||
$this-> | ||
// the short description shown while running "php bin/console list" | ||
setDescription('Create a pod.') | ||
-> | ||
// the full command description shown when running the command with | ||
// the "--help" option | ||
setHelp('This command allows you to create a pod.') | ||
-> | ||
// configure an argument | ||
addArgument('yaml-file', InputArgument::REQUIRED, 'Name of a yaml file.'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
try { | ||
$yaml = file_get_contents($input->getArgument('yaml-file')); | ||
Timer::start(); | ||
$response = KubernetesPods::create($yaml); | ||
$time = Timer::stop(); | ||
$output->writeln($response); | ||
$output->writeln("Elapsed time: {$time}s"); | ||
} catch (\Exception $e) { | ||
$output->writeln($e->getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
/** | ||
* PHP Kubectl terminal console | ||
* @author Flávio Gomes da Silva Lisboa <[email protected]> | ||
* @license https://www.gnu.org/licenses/lgpl-3.0.en.html | ||
*/ | ||
namespace App\Command; | ||
|
||
use Symfony\Component\Console\Command\Command; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
use Symfony\Component\Console\Input\InputArgument; | ||
use Fgsl\Kubectl\KubernetesPods; | ||
use App\Helper\Timer; | ||
|
||
class DeletePodCommand extends Command | ||
{ | ||
|
||
// the name of the command (the part after "bin/console") | ||
protected static $defaultName = 'app:delete-pod'; | ||
|
||
protected function configure() | ||
{ | ||
$this-> | ||
// the short description shown while running "php bin/console list" | ||
setDescription('Delete a pod.') | ||
-> | ||
// the full command description shown when running the command with | ||
// the "--help" option | ||
setHelp('This command allows you to delete a pod.') | ||
-> | ||
// configure an argument | ||
addArgument('namespace', InputArgument::REQUIRED, 'The namespace of cluster.') | ||
->addArgument('module', InputArgument::REQUIRED, 'The module of namespace.'); | ||
} | ||
|
||
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
try { | ||
Timer::start(); | ||
$response = KubernetesPods::delete($input->getArgument('namespace'), $input->getArgument('module')); | ||
$time = Timer::stop(); | ||
$output->writeln($response); | ||
$output->writeln("Elapsed time: {$time}s"); | ||
} catch (\Exception $e) { | ||
$output->writeln($e->getMessage()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.