Install Kubeflow

Instructions for deploying Kubeflow on IBM Cloud

This guide describes how to use the kfctl binary to deploy Kubeflow on IBM Cloud Kubernetes Service (IKS).

Prerequisites

  • Authenticate with IBM Cloud

    Log into IBM Cloud using the IBM Cloud Command Line Interface (CLI) as follows:

    1. ibmcloud login
  • Create and access a Kubernetes cluster on IKS

    To deploy Kubeflow on IBM Cloud, you need a cluster running on IKS. If you don’t have a cluster running, follow the Create an IBM Cloud cluster guide.

    Run the following command to switch the Kubernetes context and access the cluster:

    1. ibmcloud ks cluster config --cluster <cluster_name>

    Replace <cluster_name> with your cluster name.

IBM Cloud Block Storage Setup

Note: This section is only required when the worker nodes provider WORKER_NODE_PROVIDER is set to classic. For other infrastructures, IBM Cloud Block Storage is already set up as the cluster’s default storage class.

When using the classic worker nodes provider of IBM Cloud Kubernetes cluster, by default, it uses IBM Cloud File Storage based on NFS as the default storage class. File Storage is designed to run RWX (read-write multiple nodes) workloads with proper security built around it. Therefore, File Storage does not allow fsGroup securityContext which is needed for DEX and Kubeflow Jupyter Server.

IBM Cloud Block Storage provides a fast way to store data and satisfy many of the Kubeflow persistent volume requirements such as fsGroup out of the box and optimized RWO (read-write single node) which is used on all Kubeflow’s persistent volume claim.

Therefore, you’re recommended to set up IBM Cloud Block Storage as the default storage class so that you can get the best experience from Kubeflow.

  1. Follow the instructions to install the Helm version 3 client on your local machine.

  2. Add the IBM Cloud Helm chart repository to the cluster where you want to use the IBM Cloud Block Storage plug-in.

    1. helm repo add iks-charts https://icr.io/helm/iks-charts
    2. helm repo update
  3. Install the IBM Cloud Block Storage plug-in. When you install the plug-in, pre-defined block storage classes are added to your cluster.

    1. helm install 1.7.0 iks-charts/ibmcloud-block-storage-plugin -n kube-system

    Example output:

    1. NAME: 1.7.0
    2. LAST DEPLOYED: Fri Aug 28 11:23:56 2020
    3. NAMESPACE: kube-system
    4. STATUS: deployed
    5. REVISION: 1
    6. NOTES:
    7. Thank you for installing: ibmcloud-block-storage-plugin. Your release is named: 1.7.0
    8. ...
  4. Verify that the installation was successful.

    1. kubectl get pod -n kube-system | grep block
  5. Verify that the storage classes for Block Storage were added to your cluster.

    1. kubectl get storageclasses | grep block
  6. Set the Block Storage as the default storage class.

    1. NEW_STORAGE_CLASS=ibmc-block-gold
    2. OLD_STORAGE_CLASS=$(kubectl get sc -o jsonpath='{.items[?(@.metadata.annotations.storageclass\.kubernetes\.io\/is-default-class=="true")].metadata.name}')
    3. kubectl patch storageclass ${NEW_STORAGE_CLASS} -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
    4. # List all the (default) storage classes
    5. kubectl get storageclass | grep "(default)"

    Example output:

    1. ibmc-block-gold (default) ibm.io/ibmc-block 65s

    Make sure ibmc-block-gold is the only (default) storage class. If there are two or more rows in the above output, unset the previous (default) storage classes with the command below:

    1. kubectl patch storageclass ${OLD_STORAGE_CLASS} -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"false"}}}'

Understanding the Kubeflow deployment process

The deployment process is controlled by the following commands:

  • build - (Optional) Creates configuration files defining the various resources in your deployment. You only need to run kfctl build if you want to edit the resources before running kfctl apply.
  • apply - Creates or updates the resources.
  • delete - Deletes the resources.

App layout

Your Kubeflow application directory ${KF_DIR} contains the following files and directories:

  • ${CONFIG_FILE} is a YAML file that defines configurations related to your Kubeflow deployment.

  • kustomize is a directory that contains the kustomize packages for Kubeflow applications.

    • The directory is created when you run kfctl build or kfctl apply.
    • You can customize the Kubernetes resources (modify the manifests and run kfctl apply again).

Kubeflow installation

Run the following commands to set up and deploy Kubeflow.

  1. Download the kfctl v1.1.0 release from the Kubeflow releases page.

  2. Unpack the tar ball

    1. tar -xvf kfctl_v1.1.0_<platform>.tar.gz
  3. Make kfctl binary easier to use (optional). If you don’t add the binary to your path, you must use the full path to the kfctl binary each time you run it.

    1. export PATH=$PATH:<path to where kfctl was unpacked>

Choose either single user or multi-tenant section based on your usage.

Single user

Run the following commands to set up and deploy Kubeflow for a single user without any authentication.

  1. # Set KF_NAME to the name of your Kubeflow deployment. This also becomes the
  2. # name of the directory containing your configuration.
  3. # For example, your deployment name can be 'my-kubeflow' or 'kf-test'.
  4. export KF_NAME=<your choice of name for the Kubeflow deployment>
  5. # Set the path to the base directory where you want to store one or more
  6. # Kubeflow deployments. For example, /opt/.
  7. # Then set the Kubeflow application directory for this deployment.
  8. export BASE_DIR=<path to a base directory>
  9. export KF_DIR=${BASE_DIR}/${KF_NAME}
  10. # Set the configuration file to use, such as the file specified below:
  11. export CONFIG_URI="https://raw.githubusercontent.com/kubeflow/manifests/v1.1-branch/kfdef/kfctl_ibm.v1.1.0.yaml"
  12. # Generate and deploy Kubeflow:
  13. mkdir -p ${KF_DIR}
  14. cd ${KF_DIR}
  15. kfctl apply -V -f ${CONFIG_URI}
  • ${KF_NAME} - The name of your Kubeflow deployment. If you want a custom deployment name, specify that name here. For example, my-kubeflow or kf-test. The value of KF_NAME must consist of lower case alphanumeric characters or ‘-‘, and must start and end with an alphanumeric character. The value of this variable cannot be greater than 25 characters. It must contain just a name, not a directory path. This value also becomes the name of the directory where your Kubeflow configurations are stored, that is, the Kubeflow application directory.

  • ${KF_DIR} - The full path to your Kubeflow application directory.

Multi-user, auth-enabled

Run the following steps to deploy Kubeflow with IBM Cloud AppID as an authentication provider.

The scenario is a Kubeflow cluster admin configures Kubeflow as a web application in AppID and manages user authentication with builtin identity providers (Cloud Directory, SAML, social log-in with Google or Facebook etc.) or custom providers.

  1. Follow the guide Getting started with App ID to create an AppID service instance.

  2. Follow the step Registering your app to create an application with type regularwebapp under the provisioned AppID instance. Make sure the scope contains email. Then retrieve the following configuration parameters from your AppID:

    • clientId
    • secret
    • oAuthServerUrl
  3. Create the namespace istio-system if not exist:

    1. kubectl create namespace istio-system
  4. Create a secret prior to kubeflow deployment by filling parameters from the step 2 accordingly:

    1. kubectl create secret generic appid-application-configuration -n istio-system \
    2. --from-literal=clientId=<clientId> \
    3. --from-literal=secret=<secret> \
    4. --from-literal=oAuthServerUrl=<oAuthServerUrl> \
    5. --from-literal=oidcRedirectUrl=https://<kubeflow-FQDN>/login/oidc
    • <oAuthServerUrl> - fill in the value of oAuthServerUrl
    • <clientId> - fill in the value of clientId
    • <secret> - fill in the value of secret
    • <kubeflow-FQDN> - fill in the FQDN of Kubeflow, if you don’t know yet, just give a dummy one like localhost. Then change it after you got one.

    Notice: If any of the parameters changed after Kubeflow deployment, it will need to manually update these parameters in the secret appid-application-configuration then restart authservice by running the command kubectl rollout restart sts authservice -n istio-system.

  5. Setup environment variables:

    1. export KF_NAME=<your choice of name for the Kubeflow deployment>
    2. # Set the path to the base directory where you want to store one or more
    3. # Kubeflow deployments. For example, /opt/.
    4. export BASE_DIR=<path to a base directory>
    5. # Then set the Kubeflow application directory for this deployment.
    6. export KF_DIR=${BASE_DIR}/${KF_NAME}
  6. Setup configuration files:

    1. export CONFIG_URI="https://raw.githubusercontent.com/kubeflow/manifests/master/kfdef/kfctl_ibm_multi_user.yaml"
    2. # Generate and deploy Kubeflow:
    3. mkdir -p ${KF_DIR}
    4. cd ${KF_DIR}
    5. kfctl build -V -f ${CONFIG_URI}
  7. Deploy Kubeflow:

    1. kfctl apply -V -f ${CONFIG_URI}
  8. Wait until the deployment finishes successfully. e.g., all pods are in Running state when running kubectl get pod -n kubeflow.

Verify mutli-user installation

Check the pod authservice-0 is in running state in namespace istio-system:

  1. kubectl get pod authservice-0 -n istio-system

Next steps

Please follow the steps in Exposing the Kubeflow dashboard with DNS and TLS termination to secure the Kubeflow dashboard with HTTPS, then you will have the required DNS name as Kubeflow FQDN to enable the OIDC flow for AppID:

  1. Follow the step Adding redirect URIs to fill a URL for AppID to redirect to Kubeflow. The URL should look like https://<kubeflow-FQDN>/login/oidc.
  2. Update the secret appid-application-configuration with the updated Kubeflow FQDN to replace <kubeflow-FQDN> in below command:
  1. redirect_url=$(printf https://<kubeflow-FQDN>/login/oidc | base64 -w0) \
  2. kubectl patch secret appid-application-configuration -n istio-system \
  3. -p $(printf '{"data":{"oidcRedirectUrl": "%s"}}' $redirect_url)
  1. restart the pod authservice-0:
  1. kubectl rollout restart statefulset authservice -n istio-system

Then visit https://<kubeflow-FQDN>/, it should redirect you to AppID for authentication.

Additional information

You can find general information about Kubeflow configuration in the guide to configuring Kubeflow with kfctl and kustomize.

Last modified 06.11.2020: Uses AppID for multi-user installation on IKS (#2327) (9a094895)