From 423c1df6ef45c2f9cbfd6badfd10a31d5e371d2a Mon Sep 17 00:00:00 2001 From: Yang Yang Date: Fri, 25 Oct 2019 12:01:23 -0700 Subject: [PATCH 1/6] [Doc] Submit Argo Jobs from SQLFlow Container --- doc/argo-setup.md | 68 +++++++++++++++++++++++++++++++++++ scripts/build_docker_image.sh | 4 +++ 2 files changed, 72 insertions(+) create mode 100644 doc/argo-setup.md diff --git a/doc/argo-setup.md b/doc/argo-setup.md new file mode 100644 index 0000000000..9837858e4a --- /dev/null +++ b/doc/argo-setup.md @@ -0,0 +1,68 @@ +# Submit Argo Jobs from SQLFlow Container + +This document demonstrates how to setup Minikube on your Mac and submit argo jobs from a running SQLFlow container. + + +| command | version | +|----------|---------| +| minikube | v1.4.0 | +| kubectl | v1.16 | +| argo | v2.3.0 | + +## Step by Step + +**On Host** + +1. Install Minikube following this [guide](https://kubernetes.io/docs/tasks/tools/install-minikube/). +1. Start Minikube + ``` + minikube start --cpus 2 --memory 4000 + ``` +1. Start SQLFlow Docker container. Please be aware that we mount the host `$HOME` as container `/root`, so that the `$HOME/.kube/`(configured by Minikube) can be access inside the container. + ``` + docker run --rm --net=host -it -v $GOPATH:/go -v $HOME:/root -w /go/src/sqlflow.org/sqlflow sqlflow:latest bash + ``` + +**In Container** + +1. One more step for sharing the `$HOME/.kube/`. The credential in `$HOME/.kube/config` is referred by absolute path, e.g. `certificate-authority: /Users/yang.y/.minikube/ca.crt`. So we need to create a symbolic link mapping from `/User/yang.y` to `/root`. Please substitute `yang.y` to your user name and type the following command. + ``` + mkdir /Users && ln -s /root /Users/yang.y + ``` +1. Verify you have access to the Minikube cluster. + ``` + $ kubectl get namespaces + NAME STATUS AGE + default Active 23h + kube-node-lease Active 23h + kube-public Active 23h + kube-system Active 23h + ``` +1. Install the controller and UI. + ``` + kubectl create namespace argo + kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo/stable/manifests/install.yaml + ``` +1. Grant admin privileges to the 'default' service account in the namespace 'default', so that the service account can run workflows. + ``` + kubectl create rolebinding default-admin --clusterrole=admin --serviceaccount=default:default + ``` +1. Install Argo. Skip this step if Argo has been installed. + ``` + curl -sSL -o /usr/local/bin/argo https://github.com/argoproj/argo/releases/download/v2.3.0/argo-linux-amd64 + chmod +x /usr/local/bin/argo + ``` +1. Run example workflows. + ``` + argo submit --watch https://raw.githubusercontent.com/argoproj/argo/master/examples/hello-world.yaml + argo submit --watch https://raw.githubusercontent.com/argoproj/argo/master/examples/coinflip.yaml + argo submit --watch https://raw.githubusercontent.com/argoproj/argo/master/examples/loops-maps.yaml + argo list + argo get xxx-workflow-name-xxx + argo logs xxx-pod-name-xxx #from get command above + ``` + +## Appendix + +1. Argo official demo: https://github.com/argoproj/argo/blob/master/demo.md +1. Minikube installation guide: https://kubernetes.io/docs/tasks/tools/install-minikube/ diff --git a/scripts/build_docker_image.sh b/scripts/build_docker_image.sh index d30f876dbb..0b19e0ef00 100644 --- a/scripts/build_docker_image.sh +++ b/scripts/build_docker_image.sh @@ -129,3 +129,7 @@ git checkout eb93e2a48e6fe8f077c4937d8c0c5987faa9cf56 pip install -r elasticdl/requirements.txt python setup.py install cd .. + +# 10. Install Argo. 34M total. +curl -sSL -o /usr/local/bin/argo https://github.com/argoproj/argo/releases/download/v2.3.0/argo-linux-amd64 +chmod +x /usr/local/bin/argo From 3828dba5a476d12a5b48cffdd1ecbdc431d75654 Mon Sep 17 00:00:00 2001 From: Yang Yang Date: Fri, 25 Oct 2019 12:04:55 -0700 Subject: [PATCH 2/6] polish --- doc/argo-setup.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/argo-setup.md b/doc/argo-setup.md index 9837858e4a..0f900ea52d 100644 --- a/doc/argo-setup.md +++ b/doc/argo-setup.md @@ -1,6 +1,6 @@ -# Submit Argo Jobs from SQLFlow Container +# Submit Argo Workflow from SQLFlow Container -This document demonstrates how to setup Minikube on your Mac and submit argo jobs from a running SQLFlow container. +This document demonstrates how to setup Minikube on your Mac and submit argo workflow from a SQLFlow container. | command | version | @@ -43,7 +43,7 @@ This document demonstrates how to setup Minikube on your Mac and submit argo job kubectl create namespace argo kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo/stable/manifests/install.yaml ``` -1. Grant admin privileges to the 'default' service account in the namespace 'default', so that the service account can run workflows. +1. Grant admin privileges to the 'default' service account in the namespace 'default', so that the service account can run workflow. ``` kubectl create rolebinding default-admin --clusterrole=admin --serviceaccount=default:default ``` @@ -52,7 +52,7 @@ This document demonstrates how to setup Minikube on your Mac and submit argo job curl -sSL -o /usr/local/bin/argo https://github.com/argoproj/argo/releases/download/v2.3.0/argo-linux-amd64 chmod +x /usr/local/bin/argo ``` -1. Run example workflows. +1. Run example workflow. ``` argo submit --watch https://raw.githubusercontent.com/argoproj/argo/master/examples/hello-world.yaml argo submit --watch https://raw.githubusercontent.com/argoproj/argo/master/examples/coinflip.yaml From 4c9d9d836ac5aff3a5655a18dbdcf873584b7a34 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Sat, 26 Oct 2019 11:31:43 -0700 Subject: [PATCH 3/6] Update argo-setup.md --- doc/argo-setup.md | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/doc/argo-setup.md b/doc/argo-setup.md index 0f900ea52d..479f6eb0ca 100644 --- a/doc/argo-setup.md +++ b/doc/argo-setup.md @@ -1,35 +1,27 @@ # Submit Argo Workflow from SQLFlow Container -This document demonstrates how to setup Minikube on your Mac and submit argo workflow from a SQLFlow container. +In this document, we explain how to submit jobs from a SQLFlow server container to a Kubernetes clluster. We use Minikube on a Mac, but you can use Kubernetes clusters on public cloud services as well. The jobs we submit in this document are Argo workflows. +## On the Mac -| command | version | -|----------|---------| -| minikube | v1.4.0 | -| kubectl | v1.16 | -| argo | v2.3.0 | - -## Step by Step - -**On Host** - -1. Install Minikube following this [guide](https://kubernetes.io/docs/tasks/tools/install-minikube/). +1. Install [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/). 1. Start Minikube - ``` + ```bash minikube start --cpus 2 --memory 4000 ``` -1. Start SQLFlow Docker container. Please be aware that we mount the host `$HOME` as container `/root`, so that the `$HOME/.kube/`(configured by Minikube) can be access inside the container. - ``` +1. Start a SQLFlow Docker container. + ```bash docker run --rm --net=host -it -v $GOPATH:/go -v $HOME:/root -w /go/src/sqlflow.org/sqlflow sqlflow:latest bash ``` + We use `-v $HOME:/root` to mount the home directory on the host, `$HOME`, to the home directory in the container, `/root`, so we can access the Minikube cluster configuration files in `$HOME/.kube/` from within the container. -**In Container** +## In the SQLFlow Container -1. One more step for sharing the `$HOME/.kube/`. The credential in `$HOME/.kube/config` is referred by absolute path, e.g. `certificate-authority: /Users/yang.y/.minikube/ca.crt`. So we need to create a symbolic link mapping from `/User/yang.y` to `/root`. Please substitute `yang.y` to your user name and type the following command. +1. One more step for sharing the `$HOME/.kube/`. The credential in `$HOME/.kube/config` is referred to by absolute path, e.g. `certificate-authority: /Users/yang.y/.minikube/ca.crt`. So we need to create a symbolic link mapping `/User/yang.y` to `/root`. Please substitute `yang.y` to your user name and type the following command. ``` mkdir /Users && ln -s /root /Users/yang.y ``` -1. Verify you have access to the Minikube cluster. +1. Verify you have access to the Minikube cluster by typing the following command in the container. ``` $ kubectl get namespaces NAME STATUS AGE @@ -38,12 +30,12 @@ This document demonstrates how to setup Minikube on your Mac and submit argo wor kube-public Active 23h kube-system Active 23h ``` -1. Install the controller and UI. - ``` +1. Install the Argo controller and UI. + ```bash kubectl create namespace argo kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo/stable/manifests/install.yaml ``` -1. Grant admin privileges to the 'default' service account in the namespace 'default', so that the service account can run workflow. +1. Grant admin privileges to the 'default' service account in the namespace `default`, so that the service account can run workflow. ``` kubectl create rolebinding default-admin --clusterrole=admin --serviceaccount=default:default ``` From a1d966027673ab18ff35b624cc73e809f3a20450 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Sat, 26 Oct 2019 11:42:33 -0700 Subject: [PATCH 4/6] Update argo-setup.md --- doc/argo-setup.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/argo-setup.md b/doc/argo-setup.md index 479f6eb0ca..950b152890 100644 --- a/doc/argo-setup.md +++ b/doc/argo-setup.md @@ -2,6 +2,8 @@ In this document, we explain how to submit jobs from a SQLFlow server container to a Kubernetes clluster. We use Minikube on a Mac, but you can use Kubernetes clusters on public cloud services as well. The jobs we submit in this document are Argo workflows. +Please be aware that, in practice, the SQLFlow container might be running on the Kubernetes cluster as Argo workflows, but not in a separate container. And, it is the submitter program running in the SQLFlow server container who submits Argo workflows by calling the Kubernetes API other than the argo command. It is known as **Kubernetes-native** to call Kubernetes APIs from a container running on the Kubernetes cluster. For how to implement Kubernetes-native calls, please refer to the ElasticDL master program as an example. + ## On the Mac 1. Install [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/). From 8790a33dd5282a82ce783326bb2cb7532bd2462f Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Sun, 27 Oct 2019 11:03:04 -0700 Subject: [PATCH 5/6] Update argo-setup.md --- doc/argo-setup.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/argo-setup.md b/doc/argo-setup.md index 950b152890..d2492ef1ba 100644 --- a/doc/argo-setup.md +++ b/doc/argo-setup.md @@ -1,6 +1,6 @@ # Submit Argo Workflow from SQLFlow Container -In this document, we explain how to submit jobs from a SQLFlow server container to a Kubernetes clluster. We use Minikube on a Mac, but you can use Kubernetes clusters on public cloud services as well. The jobs we submit in this document are Argo workflows. +In this document, we explain how to submit jobs from a SQLFlow server container to a Kubernetes cluster. We use Minikube on a Mac, but you can use Kubernetes clusters on public cloud services as well. The jobs we submit in this document are Argo workflows. Please be aware that, in practice, the SQLFlow container might be running on the Kubernetes cluster as Argo workflows, but not in a separate container. And, it is the submitter program running in the SQLFlow server container who submits Argo workflows by calling the Kubernetes API other than the argo command. It is known as **Kubernetes-native** to call Kubernetes APIs from a container running on the Kubernetes cluster. For how to implement Kubernetes-native calls, please refer to the ElasticDL master program as an example. From e3a181f72fb2db3374b7412f3d004adbc996ccd1 Mon Sep 17 00:00:00 2001 From: Yang Yang Date: Mon, 28 Oct 2019 12:07:57 -0700 Subject: [PATCH 6/6] remove argo in Docker image --- scripts/build_docker_image.sh | 4 ---- 1 file changed, 4 deletions(-) diff --git a/scripts/build_docker_image.sh b/scripts/build_docker_image.sh index 0b19e0ef00..d30f876dbb 100644 --- a/scripts/build_docker_image.sh +++ b/scripts/build_docker_image.sh @@ -129,7 +129,3 @@ git checkout eb93e2a48e6fe8f077c4937d8c0c5987faa9cf56 pip install -r elasticdl/requirements.txt python setup.py install cd .. - -# 10. Install Argo. 34M total. -curl -sSL -o /usr/local/bin/argo https://github.com/argoproj/argo/releases/download/v2.3.0/argo-linux-amd64 -chmod +x /usr/local/bin/argo