Skip to content

Commit

Permalink
Combine check for kf client dependencies into one utility function ch…
Browse files Browse the repository at this point in the history
…eck_installed_deps (kubeflow#2369)
  • Loading branch information
ashahba authored and k8s-ci-robot committed Feb 5, 2019
1 parent 01519e7 commit 9c90118
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 17 deletions.
23 changes: 11 additions & 12 deletions scripts/kfctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ createEnv() {
# Remove trailing slash from the repo.
KUBEFLOW_REPO=${KUBEFLOW_REPO%/}

# builds a set of inputs to be used with envsubst for env.sh
# builds a set of inputs to be used with envsubst for env.sh
# writeEnv updates env.sh when any env var changes
# eg: envsubst < input.tmpl > env.sh
INPUT+=('PLATFORM=$PLATFORM\n'
Expand Down Expand Up @@ -94,7 +94,7 @@ createEnv() {

case "$PLATFORM" in
minikube)
export KUBEFLOW_PLATFORM=minikube
export KUBEFLOW_PLATFORM=minikube
export MOUNT_LOCAL=${MOUNT_LOCAL:-""}
;;
docker-for-desktop)
Expand Down Expand Up @@ -134,7 +134,7 @@ createEnv() {
'$CONFIG_FILE$GKE_API_VERSION')

export KUBEFLOW_PLATFORM=gke
export PROJECT="${PROJECT}"
export PROJECT="${PROJECT}"
export ZONE=${ZONE}
export EMAIL=${EMAIL}

Expand All @@ -147,7 +147,7 @@ createEnv() {
export DEPLOYMENT_NAME=${DEPLOYMENT_NAME:-"kubeflow"}

# Kubeflow directories
export KUBEFLOW_DM_DIR=${KUBEFLOW_DM_DIR:-"$(pwd)/gcp_config"}
export KUBEFLOW_DM_DIR=${KUBEFLOW_DM_DIR:-"$(pwd)/gcp_config"}
export KUBEFLOW_SECRETS_DIR=${KUBEFLOW_SECRETS_DIR:-"$(pwd)/secrets"}
export KUBEFLOW_K8S_MANIFESTS_DIR="$(pwd)/k8s_specs"

Expand All @@ -156,7 +156,7 @@ createEnv() {

# GCP Static IP Name
export KUBEFLOW_IP_NAME=${KUBEFLOW_IP_NAME:-"${DEPLOYMENT_NAME}-ip"}

# Name of the endpoint
export KUBEFLOW_ENDPOINT_NAME=${KUBEFLOW_ENDPOINT_NAME:-"${DEPLOYMENT_NAME}"}
# Complete hostname
Expand Down Expand Up @@ -256,7 +256,7 @@ parseArgs() {
--gkeApiVersion)
shift
GKE_API_VERSION=$1
;;
;;
--skipInitProject)
SKIP_INIT_PROJECT=true
;;
Expand Down Expand Up @@ -293,7 +293,7 @@ parseArgs() {
echo "or by setting a default account in gcloud config"
exit 1
fi

# See kubeflow/kubeflow#1936
# gcloud may not get the case correct for the email.
# The iam-policy respects the case so we check the IAM policy for the email
Expand Down Expand Up @@ -328,7 +328,7 @@ main() {
exit 1
fi
if [[ ${#DEPLOYMENT_NAME} -gt 25 ]]; then
echo "Name ${DEPLOYMENT_NAME} should not be longer than 25 characters"
echo "Name ${DEPLOYMENT_NAME} should not be longer than 25 characters"
exit 1
fi
if [[ ${DEPLOYMENT_NAME} == *.* ]]; then
Expand Down Expand Up @@ -359,7 +359,7 @@ main() {
createEnv

source ${ENV_FILE}

if [[ -z "${PLATFORM}" ]]; then
echo "--platform must be provided"
echo "usage: kfctl init <PLATFORM>"
Expand Down Expand Up @@ -393,9 +393,8 @@ main() {
exit 1
fi

# TODO(ankushagarwal): verify ks version is higher than 0.11.0
check_install ks
check_install kubectl
# verify client dependencies like ks and kubectl are installed and have right versions
check_installed_deps

if [[ "${PLATFORM}" == "gcp" ]]; then
checkInstallPy pyyaml yaml
Expand Down
23 changes: 18 additions & 5 deletions scripts/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,22 @@ usage() {
echo "help - print this message"
}

check_install() {
if ! which "${1}" &>/dev/null && ! type -a "${1}" &>/dev/null ; then
echo "You don't have ${1} installed. Please install ${1}."
check_installed_deps() {
declare -a kf_deps=("ks" "kubectl")

for kf_dep in "${kf_app[@]}"; do
if ! which "${kf_dep}" &>/dev/null && ! type -a "${kf_dep}" &>/dev/null ; then
echo "You don't have ${kf_dep} installed. Please install ${kf_dep}."
exit 1
fi
done

# check minimum ks versions
kf_dep="ks"
min_ks_ver="0.11.0"
ks_ver=$(${kf_dep} version | cut -d' ' -f3 | head -1)
if [ ${ks_ver} \< ${min_ks_ver} ]; then
echo "Please install ${kf_dep} version ${min_ks_ver} or newer"
exit 1
fi
}
Expand Down Expand Up @@ -85,7 +98,7 @@ createKsApp() {
ks generate tensorboard tensorboard
ks generate metacontroller metacontroller
ks generate profiles profiles
ks generate notebooks notebooks
ks generate notebooks notebooks
ks generate argo argo
ks generate pipeline pipeline

Expand Down Expand Up @@ -138,7 +151,7 @@ customizeKsAppWithDockerImage() {
find ${KUBEFLOW_KS_DIR} -name config.yaml | xargs sed -i -e "s%gcr.io%$KUBEFLOW_DOCKER_REGISTRY%g"
fi

# The katib images like gcr.io/kubeflow-images-public/katib/tfevent-metrics-collector:v0.4.0 uses sub namespace kubeflow-images-public/katib in
# The katib images like gcr.io/kubeflow-images-public/katib/tfevent-metrics-collector:v0.4.0 uses sub namespace kubeflow-images-public/katib in
# gcr.io repo, but it's not supported by other docker image repo. We need to consider how to support it in other docker repos.
if [[ ! -z "$DOCKER_REGISTRY_KATIB_NAMESPACE" ]]; then
find ${KUBEFLOW_KS_DIR} -name "*.libsonnet" -o -name "*.jsonnet" | xargs sed -i -e "s%kubeflow-images-public/katib%$DOCKER_REGISTRY_KATIB_NAMESPACE%g"
Expand Down

0 comments on commit 9c90118

Please sign in to comment.