-
Notifications
You must be signed in to change notification settings - Fork 77
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
add pfsserver dockerfile #148
Changes from 24 commits
765d0d8
e760269
b0de563
eac9ffc
22d0a8d
122ee25
a520967
612f53c
03f244d
91b4426
64fbb84
d896844
79862db
a61462d
9655d39
473f7ab
2f6e9aa
a7db6e7
de757f8
b88dfe5
bef6072
2633ad4
e121c53
1a9d15e
d4ce648
1ccc748
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,19 @@ | ||
cat > ./Dockerfile << EOF | ||
FROM ubuntu:16.04 | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y wget git && \ | ||
wget -O go.tgz https://storage.googleapis.com/golang/go1.8.1.linux-amd64.tar.gz && \ | ||
tar -C /usr/local -xzf go.tgz && \ | ||
mkdir /root/gopath && \ | ||
rm go.tgz | ||
|
||
ENV GOROOT=/usr/local/go GOPATH=/root/gopath | ||
ENV PATH=${PATH}:${GOROOT}/bin | ||
|
||
CMD ["sh", "-c", "cd /root/gopath/src/github.com/PaddlePaddle/cloud/go/cmd/pfsserver && go get ./... && go build"] | ||
EOF | ||
|
||
docker build . -t pfsserver:dev | ||
|
||
rm -f Dockerfile |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM ubuntu:16.04 | ||
|
||
ADD .tools /pfsserver/.tools | ||
RUN bash /pfsserver/.tools/gen_config.sh | ||
|
||
ADD ./cmd/pfsserver/pfsserver /pfsserver/ | ||
RUN mkdir /pfsserver/log |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
1. 如何构建PFSServer的DockerImage | ||
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. Just a mark, we need to put pfs and pcloud in the same image later. 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. OK |
||
- 构建PFSServer的编译环境 | ||
|
||
``` | ||
cd cloud/docker/pfs | ||
bash build.sh | ||
``` | ||
|
||
- 编译PFSServer | ||
|
||
``` | ||
cd cloud/go | ||
docker run --rm -v $(pwd):/root/gopath/src/github.com/PaddlePaddle/cloud/go pfsserver:dev | ||
``` | ||
|
||
- 构建PFSServer的DockerImage | ||
|
||
``` | ||
cd cloud/go | ||
docker build . -t pfsserver:latest | ||
``` | ||
- PFSServer启动命令 | ||
|
||
``` | ||
docker run pfsserver:latest /pfsserver/pfsserver -tokenuri http://cloud.paddlepaddle.org -logtostderr=true -v=3 | ||
``` | ||
|
||
2. 如何部署PFSServer | ||
|
||
``` | ||
cd ../k8s | ||
kuberctl create -f cloud_pfsserver.yaml | ||
``` | ||
|
||
3. 如何使用PFSClient | ||
- cp | ||
|
||
``` | ||
upload: | ||
paddlecloud cp ./file /pfs/$DATACENTER/home/$USER/file | ||
|
||
download: | ||
paddlecloud cp /pfs/$DATACENTER/home/$USER/file ./file | ||
``` | ||
- ls | ||
|
||
``` | ||
paddlecloud ls /pfs/$DATACENTER/home/$USER/folder | ||
``` | ||
|
||
- rm | ||
|
||
``` | ||
paddlecloud rm /pfs/$DATACENTER/home/$USER/file | ||
paddlecloud rm -r /pfs/$DATACENTER/home/$USER/folder | ||
``` | ||
|
||
- mkdir | ||
|
||
``` | ||
paddlecloud mkdir /pfs/$DATACENTER/home/$USER/folder | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ import ( | |
"errors" | ||
"io" | ||
"net/url" | ||
"path" | ||
"strings" | ||
|
||
log "github.com/golang/glog" | ||
|
@@ -33,13 +34,16 @@ type Command interface { | |
|
||
// CheckUser checks if a user has authority to access a path. | ||
// path example:/pfs/$datacenter/home/$user | ||
func checkUser(path string, user string) error { | ||
a := strings.Split(path, "/") | ||
if len(a) < 3 { | ||
func checkUser(pathStr string, user string) error { | ||
pathStr = path.Clean(strings.TrimSpace(pathStr)) | ||
a := strings.Split(pathStr, "/") | ||
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. Should 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. 这个地方的路径是server端路径,格式是固定的。 |
||
// the first / is convert to " " | ||
if len(a) < 5 { | ||
return errors.New(StatusBadPath) | ||
} | ||
|
||
if a[3] != user { | ||
if a[4] != user { | ||
log.V(4).Infof("request path:%s user:%s split_path:%s\n", pathStr, user, a[4]) | ||
return errors.New(StatusUnAuthorized) | ||
} | ||
return nil | ||
|
@@ -57,7 +61,7 @@ func ValidatePfsPath(paths []string, userName string) error { | |
} | ||
|
||
if err := checkUser(path, userName); err != nil { | ||
return errors.New(StatusShouldBePfsPath + ":" + path) | ||
return err | ||
} | ||
} | ||
return nil | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,7 @@ spec: | |
containers: | ||
- name: paddle-cloud | ||
imagePullPolicy: Always | ||
image: paddlepaddle/cloud | ||
image: gongweibao/pcloud | ||
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.
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. Done |
||
volumeMounts: | ||
- name: cert-volume | ||
mountPath: /certs | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,15 @@ metadata: | |
name: paddle-cloud-ingress | ||
spec: | ||
rules: | ||
- host: cloud.paddlepaddle.org | ||
- host: cloud1.paddlepaddle.org | ||
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.
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. Done |
||
http: | ||
paths: | ||
- path: /api/v1/files | ||
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,31 @@ | ||
apiVersion: extensions/v1beta1 | ||
kind: Deployment | ||
metadata: | ||
name: pfsserver | ||
spec: | ||
replicas: 1 | ||
template: | ||
metadata: | ||
labels: | ||
app: pfsserver | ||
spec: | ||
volumes: | ||
- name: data-storage | ||
hostPath: | ||
path: /home/gongwb/ceph | ||
containers: | ||
- name: pfs | ||
imagePullPolicy: Always | ||
image: gongweibao/pfsserver:latest | ||
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.
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. Done |
||
env: | ||
- name: CURRENT_DATACENTER | ||
value: "meiyan" | ||
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. "meiyan" should be a template too. 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. 我单独搞一个PR来处理 |
||
command: ["/pfsserver/pfsserver", "-tokenuri", "http://paddle-cloud-service:8000", "-logtostderr=true", "-log_dir=./log", "-v=4"] | ||
volumeMounts: | ||
- name: data-storage | ||
mountPath: /pfs/datacenter1/home/ | ||
ports: | ||
- containerPort: 8080 | ||
nodeSelector: | ||
kubernetes.io/hostname: k8s-node1 | ||
|
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.
This
Dockerfile
is used forPFSServer
, so we can move this to./cmd/pfsserver
?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.
目前还不行,依赖了
./tools/gen_config.sh
,用来生成配置文件。后续解耦合以后可以放到./cmd/pfsserver
下。我在这里创建了一个ISSUE:#157