-
Notifications
You must be signed in to change notification settings - Fork 786
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch microk8s enable wrapper to Python script (#1467)
* Switch microk8s enable/disable wrappers to Python script For now, they're just clones of the old bash scripts, with the ability to handle unix-style flag arguments. Using click however, will allow expanding the enable scripts to be full click subcommands, instead of just bash scripts.
- Loading branch information
Showing
9 changed files
with
255 additions
and
217 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,46 @@ | ||
#!/usr/bin/env bash | ||
#!/usr/bin/env python3 | ||
|
||
set -eu | ||
import os | ||
import subprocess | ||
|
||
source $SNAP/actions/common/utils.sh | ||
import click | ||
|
||
function disable_kubeflow() { | ||
echo "Disabling Kubeflow..." | ||
"$SNAP/microk8s-juju.wrapper" unregister -y uk8s || true | ||
"$SNAP/microk8s-kubectl.wrapper" delete ns controller-uk8s kubeflow || true | ||
} | ||
|
||
disable_kubeflow | ||
@click.command() | ||
def kubeflow(): | ||
click.echo("Disabling Kubeflow...") | ||
|
||
env = os.environ.copy() | ||
env["PATH"] += ":%s" % os.environ["SNAP"] | ||
|
||
click.echo("Unregistering model...") | ||
try: | ||
subprocess.run( | ||
['microk8s-juju.wrapper', 'unregister', '-y', 'uk8s'], | ||
stdin=subprocess.PIPE, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
env=env, | ||
) | ||
except subprocess.CalledProcessError: | ||
pass | ||
click.echo("Unregistering complete.") | ||
|
||
click.echo("Destroying namespace...") | ||
try: | ||
subprocess.check_call( | ||
['microk8s-kubectl.wrapper', 'delete', 'ns', 'controller-uk8s', 'kubeflow'], | ||
stdin=subprocess.PIPE, | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
env=env, | ||
) | ||
except subprocess.CalledProcessError: | ||
pass | ||
click.echo("Destruction complete.") | ||
|
||
click.echo("Kubeflow is now disabled.") | ||
|
||
|
||
if __name__ == "__main__": | ||
kubeflow(prog_name='microk8s disable kubeflow') |
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.