-
Notifications
You must be signed in to change notification settings - Fork 75
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
Run PaddleCloud on minikube. #463
Changes from 9 commits
470ff47
24862c6
8277902
4a174d0
3a7f1b3
ee34608
59e089b
961bc07
b1631a7
2ea3d7f
7ebe5ac
c3e0139
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
# Run PaddleCloud on your local machine | ||
|
||
This documentation shows how to run PaddleCloud on minikube. | ||
(This surports only mac now.On unbuntu-16.04,we met a bug of kubernetes when we use `hostpath` to volume a file.) | ||
|
||
## Prerequisites | ||
|
||
- [install minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/) | ||
- [install kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) | ||
|
||
1. Start a local minikube cluster: | ||
|
||
```bash | ||
minikube start --kubernetes-version v1.6.4 | ||
``` | ||
|
||
If you can't connect to minikube distribution server,add https_proxy like that: | ||
|
||
```bash | ||
https_proxy=<your's> minikube start --kubernetes-version v1.6.4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. your's => https://YOURPROXY:PORT There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Done. |
||
``` | ||
1. Enable ingress addon: | ||
|
||
``` | ||
minikube addons enable ingress | ||
``` | ||
|
||
1. Create workspace directory: | ||
|
||
``` | ||
mkdir <yourpath> | ||
``` | ||
Minikube mount `$Home` path default,and you'd better to create path under it or you may find that it can't be changed in minikube virtual mathine or in kubertes pod. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since Minikube mounts There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Done. |
||
|
||
1. Copy `ca` and generate `admin` certificate: | ||
(We must use `ca` under `~/.minikube` instead of under `~/.minikube/certs`.) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We must use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Done. |
||
|
||
``` | ||
mkdir <yourpath>/certs && cd <yourpath>/certs | ||
openssl genrsa -out admin-key.pem 2048 | ||
openssl req -new -key admin-key.pem -out admin.csr -subj "/CN=kube-admin" | ||
openssl x509 -req -in admin.csr -CA ~/.minikube/ca.crt -CAkey ~/.minikube/ca.key \ | ||
-CAcreateserial -out admin.pem -days 365 | ||
cp ~/.minikube/ca.crt . | ||
cp ~/.minikube/ca.key . | ||
``` | ||
|
||
1. Copy and configure paddlecloud configures: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy and update paddlecloud configurations: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Done. |
||
|
||
``` | ||
git clone https://github.com/PaddlePaddle/cloud | ||
cp cloud/k8s/minikube/* <yourpath>/ | ||
sed -i'.bak' -e "s#<yourpath>#yourpath#g" <yourpath>/*.yaml | ||
``` | ||
|
||
1. Edit `/etc/hosts` and add `$(minikube ip) cloud.testpcloud.org` to it. | ||
1. Start all jobs: | ||
|
||
``` | ||
kubectl create -f cloud_ingress.yaml | ||
kubectl create -f cloud_service.yaml | ||
kubectl create -f mysql_deployment.yaml | ||
kubectl create -f mysql_service.yaml | ||
kubectl create -f pfs_deployment.yaml | ||
kubectl create -f pfs_service.yaml | ||
kubectl create -f cloud_deployment.yaml | ||
``` | ||
1. Type `$(minikube ip)` into browser,and sign up a user. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. open There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Done. |
||
1. Edit `~/.paddle/config` like this: | ||
|
||
``` | ||
datacenters: | ||
- name: testpcloud | ||
username: g1@163.com | ||
password: 1 | ||
endpoint: http://cloud.testpcloud.org | ||
current-datacenter: testpcloud | ||
``` | ||
|
||
You can use PaddleCloud command line now. | ||
|
||
|
||
## FAQ | ||
1. We can't get anything when we type `$(minikube ip)` into browser. | ||
You can use `minikube get po --all-namespaces` to check it,it should like: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One possible cause is:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Done. |
||
|
||
``` | ||
NAMESPACE NAME READY STATUS RESTARTS AGE | ||
default paddle-cloud-3328278932-pqtf0 1/1 Running 5 3h | ||
default paddle-cloud-mysql-2598050360-rdzpr 1/1 Running 4 3h | ||
g1-163-com cloud-notebook-deployment-2982752518-6gr0m 0/1 Pending 0 3h | ||
kube-system default-http-backend-cwqd4 1/1 Running 4 4h | ||
kube-system kube-addon-manager-minikube 1/1 Running 4 4h | ||
kube-system kube-dns-4149932207-0clkw 3/3 Running 12 4h | ||
kube-system kubernetes-dashboard-tqrd7 1/1 Running 4 4h | ||
kube-system nginx-ingress-controller-gxgl8 1/1 Running 4 4h | ||
``` | ||
|
||
But docker images such as `default-http-backend` can't be downloaded sometimes , you can use | ||
|
||
- `kubectrl describe po name --namespace=kube-system` to get docker image uri. | ||
- and then pull with proxy and then save to tar `docker save <docker-image-uri> > <tarname>.tar`. | ||
- `minikube ssh`. | ||
- `docker load < <tarname>.tar`. | ||
|
||
1. I edit a file,but it not change in minikube virtual machine some times. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indention issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I edited a file in host file system, but it remained unchanged in Minikube virtual machine sometimes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Done. |
||
Ye, it seems that minikube has a cache of files.You'd better `minikube stop` `minikube start --kubernetes-version v1.6.4` to fix it. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That might be due to the files cache mechanism of Minikube. You can try to restart the Minikube with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Done. |
||
|
||
## TODO | ||
1. The `mysql` docker runs `mysqld` under user `mysql` instead of `root`,so it's difficult to save `mysql` data to hostpath. | ||
1. Fix bug: `kubernetes can't mount a file use host to volume a file` on linux. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Kubernetes can't mount the volume with hostpath to a single file There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Done. |
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: paddle-cloud | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: paddle-cloud | ||
spec: | ||
volumes: | ||
- name: cert-volume | ||
hostPath: | ||
path: <yourpath>/certs | ||
- name: settings | ||
hostPath: | ||
path: <yourpath>/settings.py | ||
containers: | ||
- name: paddle-cloud | ||
imagePullPolicy: IfNotPresent | ||
image: paddlepaddle/cloud | ||
volumeMounts: | ||
- name: cert-volume | ||
mountPath: /certs | ||
- name: settings | ||
mountPath: /pcloud/paddlecloud/settings.py | ||
ports: | ||
- containerPort: 8000 | ||
env: | ||
- name: POD_IP | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.podIP | ||
- name: PORT | ||
value: "8000" | ||
nodeSelector: | ||
kubernetes.io/hostname: minikube |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Ingress | ||
metadata: | ||
name: paddle-cloud-ingress | ||
spec: | ||
rules: | ||
- host: cloud.testpcloud.org | ||
http: | ||
paths: | ||
- path: /api/v1/pfs | ||
backend: | ||
serviceName: pfs-service | ||
servicePort: 8080 | ||
- path: / | ||
backend: | ||
serviceName: paddle-cloud-service | ||
servicePort: 8000 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: paddle-cloud-service | ||
spec: | ||
selector: | ||
app: paddle-cloud | ||
ports: | ||
- protocol: TCP | ||
port: 8000 | ||
targetPort: 8000 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: paddle-cloud-mysql | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: paddle-cloud-mysql | ||
spec: | ||
volumes: | ||
- name: mysql-data | ||
hostPath: | ||
path: "<yourpath>/mysql" | ||
containers: | ||
- name: mysql | ||
image: mysql:5.7 | ||
imagePullPolicy: IfNotPresent | ||
#volumeMounts: | ||
#- name: mysql-data | ||
#mountPath: /var/lib/mysql2 | ||
env: | ||
- name: MYSQL_ROOT_PASSWORD | ||
value: root | ||
- name: MYSQL_DATABASE | ||
value: paddlecloud | ||
args: ["--character-set-server=utf8mb4", "--collation-server=utf8mb4_unicode_ci"] | ||
nodeSelector: | ||
kubernetes.io/hostname: minikube |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: paddle-cloud-mysql-service | ||
spec: | ||
selector: | ||
app: paddle-cloud-mysql | ||
ports: | ||
- protocol: TCP | ||
port: 3306 | ||
targetPort: 3306 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: pfsserver | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: pfsserver | ||
spec: | ||
volumes: | ||
- name: public-data-storage | ||
hostPath: | ||
path: "<yourpath>/public" | ||
- name: data-storage | ||
hostPath: | ||
path: "<yourpath>/users" | ||
containers: | ||
- name: pfs | ||
imagePullPolicy: IfNotPresent | ||
image: paddlepaddle/pfsserver:latest | ||
env: | ||
- name: CURRENT_DATACENTER | ||
value: "datacenter" | ||
command: ["/pfsserver/pfsserver", "-tokenuri", "http://paddle-cloud-service:8000", "-logtostderr=true", "-log_dir=./log", "-v=4"] | ||
volumeMounts: | ||
- name: data-storage | ||
mountPath: /pfs/datacenter/home | ||
- name: public-data-storage | ||
mountPath: /pfs/datacenter/public/dataset | ||
ports: | ||
- containerPort: 8080 | ||
nodeSelector: | ||
kubernetes.io/hostname: minikube | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
kind: Service | ||
apiVersion: v1 | ||
metadata: | ||
name: pfs-service | ||
spec: | ||
selector: | ||
app: pfsserver | ||
ports: | ||
- protocol: TCP | ||
port: 8080 | ||
targetPort: 8080 | ||
type: NodePort |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Currently, This guide works with Mac OS only. On Ubuntu 16.04, the bug for Kubernetes to mount a single file with
hostpath
is a show stopper"also, do we have a link for this bug in kubernetes repo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kubernetes/kubernetes#44815 (comment)
can this help solve the issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I will test it later.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's amazing to find that we can volume a file on Linux now!