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

Closes #44392 #44931

Merged
merged 1 commit into from
Apr 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions cluster/juju/layers/kubernetes-worker/actions.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
pause:
description: |
Cordon the unit, draining all active workloads.
params:
delete-local-data:
type: boolean
description: Force deletion of local storage to enable a drain
default: False
force:
type: boolean
description: |
Continue even if there are pods not managed by a RC, RS, Job, DS or SS
default: False

resume:
description: |
UnCordon the unit, enabling workload scheduling.
Expand Down
21 changes: 20 additions & 1 deletion cluster/juju/layers/kubernetes-worker/actions/pause
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,25 @@ set -ex

export PATH=$PATH:/snap/bin

DELETE_LOCAL_DATA=$(action-get delete-local-data)
FORCE=$(action-get force)

# placeholder for additional flags to the command
export EXTRA_FLAGS=""

# Determine if we have extra flags
if [[ "${DELETE_LOCAL_DATA}" == "True" || "${DELETE_LOCAL_DATA}" == "true" ]]; then
EXTRA_FLAGS="${EXTRA_FLAGS} --delete-local-data=true"
fi

if [[ "${FORCE}" == "True" || "${FORCE}" == "true" ]]; then
EXTRA_FLAGS="${EXTRA_FLAGS} --force"
fi


# Cordon and drain the unit
kubectl --kubeconfig=/root/cdk/kubeconfig cordon $(hostname)
kubectl --kubeconfig=/root/cdk/kubeconfig drain $(hostname) --force
kubectl --kubeconfig=/root/cdk/kubeconfig drain $(hostname) ${EXTRA_FLAGS}

# Set status to indicate the unit is paused and under maintenance.
status-set 'waiting' 'Kubernetes unit paused'