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

Ensure namespace exists #1747

Merged
merged 4 commits into from
Oct 11, 2018
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
2 changes: 1 addition & 1 deletion scripts/gke/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ updateDeployment() {
cd ${KUBEFLOW_DM_DIR}
# Check if it already exists
set +e
O=`gcloud deployment-manager --project=${PROJECT} deployments describe ${DEPLOYMENT_NAME} 2>&1`
O=`gcloud deployment-manager --project=${PROJECT} deployments describe ${NAME} 2>&1`
exists=$?
set -e

Expand Down
31 changes: 19 additions & 12 deletions scripts/kfctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ createEnv() {
# GCP Zone
# The default should be a zone that supports Haswell.
ZONE=${ZONE:-$(gcloud config get-value compute/zone 2>/dev/null)}
echo ZONE=${ZONE:-"us-east1-d"} >> ${ENV_FILE}
ZONE=${ZONE:-"us-east1-d"}
echo ZONE=${ZONE} >> ${ENV_FILE}

# Email for cert manager
EMAIL=${EMAIL:-$(gcloud config get-value account 2>/dev/null)}
Expand All @@ -96,8 +97,9 @@ createEnv() {
echo PROJECT_NUMBER=${PROJECT_NUMBER} >> ${ENV_FILE}

# Settig cluster version, while ensuring we still stick with kubernetes 'v1.10.x'
SERVER_CONFIG=$(gcloud --project=${PROJECT} container get-server-config --zone=${ZONE})
CLUSTER_VERSION=$(\
gcloud --project=${PROJECT} container get-server-config --zone=${ZONE} | \
echo "${SERVER_CONFIG}" | \
awk '/validNodeVersions/{f=0} f; /validMasterVersions/{f=1}' | \
awk '{print $2}' | \
grep '^1.10.[0-9]*[-d]gke.[0-9]*$' | \
Expand All @@ -114,6 +116,19 @@ createEnv() {
esac
}

createNamespace() {
set +e
O=`kubectl get namespace ${K8S_NAMESPACE} 2>&1`
RESULT=$?
set -e

if [ "${RESULT}" -eq 0 ]; then
echo "namespace ${K8S_NAMESPACE} already exists"
else
kubectl create namespace ${K8S_NAMESPACE}
fi
}

if [ "${COMMAND}" == "init" ]; then
DEPLOYMENT_NAME=${WHAT}

Expand Down Expand Up @@ -205,16 +220,7 @@ ksApply () {
pushd ${KUBEFLOW_KS_DIR}

if [ "${PLATFORM}" == "minikube" ]; then
set +e
O=`kubectl get namespace ${K8S_NAMESPACE} 2>&1`
RESULT=$?
set -e

if [ "${RESULT}" -eq 0 ]; then
echo "namespace ${K8S_NAMESPACE} already exists"
else
kubectl create namespace ${K8S_NAMESPACE}
fi
createNamespace
fi

set +e
Expand Down Expand Up @@ -290,6 +296,7 @@ if [ "${COMMAND}" == "apply" ]; then
fi

if [ "${WHAT}" == "k8s" ] || [ "${WHAT}" == "all" ]; then
createNamespace
ksApply

if [ "${PLATFORM}" == "gcp" ]; then
Expand Down