You are viewing documentation for Kubeflow 0.6

This is a static snapshot from the time of the Kubeflow 0.6 release.
For up-to-date information, see the latest version.

Multi-user, auth-enabled Kubeflow with kfctl_existing_arrikto

Instructions for installing Kubeflow with kfctl_existing_arrikto.yaml config

Follow these instructions if you want to install Kubeflow on an existing Kubernetes cluster.

This installation of Kubeflow is maintained by Arrikto, it is geared towards existing Kubernetes clusters and does not depend on any cloud-specific feature.

In this reference architecture, we use Dex and Istio for vendor-neutral authentication.

This deployment works well for on-prem installations, where companies/organizations need LDAP/AD integration for multi-user authentication, and they don’t want to depend on any cloud-specific feature.

kfctl_existing_arrikto_architecture

Read the relevant article for more info about this architecture.

Prerequisites

You need a Kubernetes Cluster with LoadBalancer support.

If you don’t have support for LoadBalancer on your cluster, please follow the instructions below to deploy MetalLB in Layer 2 mode. (You can read more about Layer 2 mode in the MetalLB docs.)

Deploy MetalLB:

  1. Apply the manifest:

    kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.8.1/manifests/metallb.yaml
    
  2. Allocate a pool of addresses on your local network for MetalLB to use. You need at least one address for the Istio Gateway. This example assumes addresses 10.0.0.100-10.0.0.110. You must modify these addresses based on your environment.

    cat <<EOF | kubectl apply -f -
    apiVersion: v1
    kind: ConfigMap
    metadata:
      namespace: metallb-system
      name: config
    data:
      config: |
        address-pools:
        - name: default
          protocol: layer2
          addresses:
          - 10.0.0.100-10.0.0.110
    EOF
    

Ensure that MetalLB works as expected (optional):

  1. Create a dummy service:

    kubectl create service loadbalancer nginx --tcp=80:80
    service/nginx created
    
  2. Ensure that MetalLB has allocated an IP address for the service:

    kubectl describe service nginx
    ...
    Events:
      Type    Reason       Age   From                Message
      ----    ------       ----  ----                -------
      Normal  IPAllocated  69s   metallb-controller  Assigned IP "10.0.0.101"
    
  3. Check the corresponding MetalLB logs:

    kubectl logs -n metallb-system -l component=controller
    ...
    {"caller":"service.go:98","event":"ipAllocated","ip":"10.0.0.101","msg":"IP address assigned by controller","service":"default/nginx","ts":"2019-08-09T15:12:09.376779263Z"}
    
  4. Create a pod that will be exposed with the service:

    kubectl run nginx --image nginx --restart=Never -l app=nginx
    pod/nginx created
    
  5. Ensure that MetalLB has assigned a node to announce the allocated IP address:

    kubectl describe service nginx
    ...
    Events:
      Type    Reason       Age   From                Message
      ----    ------       ----  ----                -------
       Normal  nodeAssigned  4s    metallb-speaker     announcing from node "node-2"
    
  6. Check the corresponding MetalLB logs:

    kubectl logs -n metallb-system -l component=speaker
    ...
    {"caller":"main.go:246","event":"serviceAnnounced","ip":"10.0.0.101","msg":"service has IP, announcing","pool":"default","protocol":"layer2","service":"default/nginx","ts":"2019-08-09T15:14:02.433876894Z"}
    
  7. Check that MetalLB responds to ARP requests for the allocated IP address:

    arping -I eth0 10.0.0.101
    ...
    ARPING 10.0.0.101 from 10.0.0.204 eth0
    Unicast reply from 10.0.0.101 [6A:13:5A:D2:65:CB]  2.619ms
    
  8. Check the corresponding MetalLB logs:

    kubectl logs -n metallb-system -l component=speaker
    ...
    {"caller":"arp.go:102","interface":"eth0,"ip":"10.0.0.101","msg":"got ARP request for service IP, sending response","responseMAC":"6a:13:5a:d2:65:cb","senderIP":"10.0.0.204","senderMAC":"9a:1f:7c:95:ca:dc","ts":"2019-08-09T15:14:52.912056021Z"}
    
  9. Verify that everything works as expected:

    curl http://10.0.0.101
    ...
    <p><em>Thank you for using nginx.</em></p>
    ...
    
  10. Clean up:

    kubectl delete service nginx
    kubectl delete pod nginx
    

Deploy Kubeflow

Follow these steps to deploy Kubeflow:

  1. Download a kfctl release from the Kubeflow releases page and unpack it:

    tar -xvf kfctl_<release tag>_<platform>.tar.gz
    
  2. Run the following commands to set up and deploy Kubeflow. The code below includes an optional command to add the binary kfctl to your path. 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.

# Add kfctl to PATH, to make the kfctl binary easier to use.
export PATH=$PATH:"<path to kfctl>"
export KFAPP="<your choice of application directory name>"
export CONFIG="https://raw.githubusercontent.com/kubeflow/kubeflow/v0.6-branch/bootstrap/config/kfctl_existing_arrikto.0.6.2.yaml"

# Specify credentials for the default user.
export KUBEFLOW_USER_EMAIL="admin@kubeflow.org"
export KUBEFLOW_PASSWORD="12341234"

kfctl init ${KFAPP} --config=${CONFIG} -V
cd ${KFAPP}
kfctl generate all -V
kfctl apply all -V
  • ${KFAPP} - the name of a directory where you want Kubeflow configurations to be stored. This directory is created when you run kfctl init. If you want a custom deployment name, specify that name here. The value of this variable becomes the name of your deployment. The value of this variable cannot be greater than 25 characters. It must contain just the directory name, not the full path to the directory. The content of this directory is described in the next section.

Accessing Kubeflow

Log in as a static user

After deploying Kubeflow, the Kubeflow dashboard is available at the Istio Gateway IP. To get the Istio Gateway IP, run:

kubectl get svc -n istio-system istio-ingressgateway -o jsonpath='{.status.loadBalancer.ingress[0].ip}'

Get the IP and open it in a browser: https://<LoadBalancerIP address>/.

Enter the credentials you specified in KUBEFLOW_USER_EMAIL, KUBEFLOW_PASSWORD and access the Kubeflow dashboard!

Add static users for basic auth

To add users to basic auth, you just have to edit the Dex ConfigMap under the key staticPasswords.

# Download the dex config
kubectl get configmap dex -n kubeflow -o jsonpath='{.data.config\.yaml}' > dex-config.yaml

# Edit the dex config with extra users.
# The password must be hashed with bcrypt with an at least 10 difficulty level.
# You can use an online tool like: https://passwordhashing.com/BCrypt

# After editing the config, update the ConfigMap
kubectl create configmap dex --from-file=config.yaml=dex-config.yaml -n kubeflow --dry-run -oyaml | kubectl apply -f -

Log in with LDAP / Active Directory

As you saw in the overview, we use Dex for providing user authentication. Dex supports several authentication methods:

  • Static users, as described above
  • LDAP / Active Directory
  • External Identity Provider (IdP) (for example Google, LinkedIn, GitHub, …)

This section focuses on setting up Dex to authenticate with an existing LDAP database.

  1. (Optional) If you don’t have an LDAP database, you can set one up following these instructions:

    1. Deploy a new LDAP Server as a StatefulSet. This also deploys phpLDAPadmin, a GUI for interacting with your LDAP Server.

    2. Seed the LDAP database with new entries.

      kubectl exec -it -n kubeflow ldap-0 -- bash
      ldapadd -x -D "cn=admin,dc=example,dc=com" -W
      # Enter password "admin".
      # Press Ctrl+D to complete after pasting the snippet below.
      

      dn: ou=People,dc=example,dc=com objectClass: organizationalUnit ou: People

      dn: cn=Nick Kiliadis,ou=People,dc=example,dc=com objectClass: person objectClass: inetOrgPerson givenName: Nick sn: Kiliadis cn: Nick Kiliadis uid: nkili mail: nkili@example.com userpassword: 12341234

      dn: cn=Robin Spanakopita,ou=People,dc=example,dc=com objectClass: person objectClass: inetOrgPerson givenName: Robin sn: Spanakopita cn: Robin Spanakopita uid: rspanakopita mail: rspanakopita@example.com userpassword: 43214321

      Group definitions.

      dn: ou=Groups,dc=example,dc=com objectClass: organizationalUnit ou: Groups

      dn: cn=admins,ou=Groups,dc=example,dc=com objectClass: groupOfNames cn: admins member: cn=Nick Kiliadis,ou=People,dc=example,dc=com

      dn: cn=developers,ou=Groups,dc=example,dc=com objectClass: groupOfNames cn: developers member: cn=Nick Kiliadis,ou=People,dc=example,dc=com member: cn=Robin Spanakopita,ou=People,dc=example,dc=com

      
      </details>
      
      
  2. To use your LDAP/AD server with Dex, you have to edit the Dex config. To edit the ConfigMap containing the Dex config, follow these steps:

    1. Get the current Dex config from the corresponding Config Map.

              kubectl get configmap dex -n kubeflow -o jsonpath='{.data.config\.yaml}' > dex-config.yaml
              
    2. Add the LDAP-specific options. Here is an example to help you out. It is configured to work with the example LDAP Server you set up previously.

    3. Append the LDAP config section to the dex config.

              cat dex-config.yaml dex-config-ldap-partial.yaml > dex-config-final.yaml
              
    4. Apply the new config.

              kubectl create configmap dex --from-file=config.yaml=dex-config-final.yaml -n kubeflow --dry-run -oyaml | kubectl apply -f -
              

    5. Restart the Dex deployment, by doing one of the following:

      • Force recreation, by deleting the Dex deployment’s Pod(s).
        • kubectl delete pods -n kubeflow -l app=dex
      • Trigger a rolling update, by adding/updating a label on the PodTemplate of the Dex deployment.
        • kubectl edit deployment dex -n kubeflow will open the Dex deployment in a text editor.
        • Add or update a label on the PodTemplate.
        • Save the deployment to trigger a rolling update.

Troubleshooting

If the Kubeflow dashboard is not available at https://<LoadBalancerIP address> ensure that:

  1. the LoadBalancer service for Istio has obtained an external IP, for example:

    kubectl get services -n istio-system istio-ingressgateway -o yaml
    ...
    status:
      loadBalancer:
        ingress:
        - ip: 10.0.0.100
    

    If not, then probably there is a misconfiguration of MetalLB.

  2. the virtual services have been created:

    kubectl get virtualservices -n kubeflow
    kubectl get virtualservices -n kubeflow centraldashboard -o yaml
    

    If not, then kfctl has aborted for some reason, and not completed successfully.

  3. OIDC auth service redirects you to Dex:

    curl -k https://<LoadBalancerIP address>/ -v
    ...
    < HTTP/2 302
    < content-type: text/html; charset=utf-8
    < location:
    /dex/auth?client_id=kubeflow-authservice-oidc&redirect_uri=%2Flogin%2Foidc&response_type=code&scope=openid+profile+email+groups&state=vSCMnJ2D
    < date: Fri, 09 Aug 2019 14:33:21 GMT
    < content-length: 181
    < x-envoy-upstream-service-time: 0
    < server: istio-envoy
    

Please join the Kubeflow Slack to report any issues, request help, and give us feedback on this config.

Some additional debugging information:

OIDC Service logs:

kubectl logs -n istio-system -l app=authservice

Dex logs:

kubectl logs -n kubeflow -l app=dex

Istio ingress-gateway logs:

kubectl logs -n istio-system -l istio=ingressgateway

Istio ingressgateway service:

kubectl get service -n istio-system istio-ingressgateway -o yaml

MetalLB logs:

kubectl logs -n metallb-system -l component=speaker
...
{"caller":"arp.go:102","interface":"br100","ip":"10.0.0.100","msg":"got ARP request for service IP, sending response","responseMAC":"62:41:bd:5f:cc:0d","senderIP":"10.0.0.204","senderMAC":"9a:1f:7c:95:ca:dc","ts":"2019-07-31T13:19:19.7082836Z"}
kubectl logs -n metallb-system  -l component=controller
...
{"caller":"service.go:98","event":"ipAllocated","ip":"10.0.0.100","msg":"IP address assigned by controller","service":"istio-system/istio-ingressgateway","ts":"2019-07-31T12:17:46.234638607Z"}

Delete Kubeflow

Run the following commands to delete your deployment and reclaim all resources:

cd ${KFAPP}
# If you want to delete all the resources, run:
kfctl delete all

Understanding the deployment process

The deployment process is controlled by 4 different commands:

  • init - one time set up.
  • generate - creates config files defining the various resources.
  • apply - creates or updates the resources.
  • delete - deletes the resources.

With the exception of init, all commands take an argument which describes the set of resources to apply the command to; this argument can be one of the following:

  • k8s - all resources that run on Kubernetes.
  • all - platform and Kubernetes resources.

App layout

Your Kubeflow app directory contains the following files and directories:

  • ${KFAPP}/app.yaml defines configurations related to your Kubeflow deployment.
  • ${KFAPP}/kustomize: contains the YAML manifests that will be deployed.

Next steps


Last modified 13.09.2019: corrections. (#1150) (a22b6c09)