Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add deletion of pv and pvcs #119

Merged
merged 2 commits into from
Feb 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pkg/tool/kubectl.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,17 @@ func NewKubectl(exec exec.ProcessExecutor) Kubectl {
// DeleteNamespace deletes the specified namespace. If the namespace does not terminate within 90s, pods running in the
// namespace and, eventually, the namespace itself are force-deleted.
func (k Kubectl) DeleteNamespace(namespace string) {

fmt.Println("Deleting pvcs...")
if err := k.exec.RunProcess("kubectl", "delete", "pvc", "--namespace", namespace, "--all"); err != nil {
fmt.Println("Error deleting pvc(s):", err)
}

fmt.Println("Deleting pvs...")
if err := k.exec.RunProcess("kubectl", "delete", "pv", "--namespace", namespace, "--all"); err != nil {
fmt.Println("Error deleting pv(s):", err)
}

fmt.Printf("Deleting namespace '%s'...\n", namespace)
timeoutSec := "120s"
if err := k.exec.RunProcess("kubectl", "delete", "namespace", namespace, "--timeout", timeoutSec); err != nil {
Expand Down