From d62795e8c24aac08c35a63c557f3c157dc4c40e3 Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Wed, 3 May 2017 20:05:44 +0800 Subject: [PATCH 1/2] add ceph quickstart --- README.md | 3 ++- quickstart/cephfs/README.md | 34 ++++++++++++++++++++++++++++ quickstart/cephfs/cephfs-secret.yaml | 6 +++++ quickstart/cephfs/pod.yaml | 21 +++++++++++++++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 quickstart/cephfs/README.md create mode 100644 quickstart/cephfs/cephfs-secret.yaml create mode 100644 quickstart/cephfs/pod.yaml diff --git a/README.md b/README.md index 148da67..7624c9b 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ - [Docker基础教程](container/README.md) - [Kubernetes基础教程](kubernetes_guide/README.md) - [配置集群客户端](./configure_kubectl.md) -- [提交一个web应用](#) +- [提交一个web应用](./quickstart/web_server) +- [使用CephFS](./quickstart/cephfs/README.md) ## PaddlePaddle on kubernetes - [提交PaddlePaddle的分布式训练](./quickstart/paddle_dist_train/README.md) diff --git a/quickstart/cephfs/README.md b/quickstart/cephfs/README.md new file mode 100644 index 0000000..e1f8092 --- /dev/null +++ b/quickstart/cephfs/README.md @@ -0,0 +1,34 @@ +# 使用CephFS作为分布式存储 + +- 在使用CephFS之前,你需要知道Ceph集群的以下信息 + - *monitors*: Ceph集群的monitor节点地址 + - *path*: 你有权限的CephFS上的目录,默认为根目录 + - *secret*: cephfs的secret,通常会作为Kubernetes的secret保存在集群, + 也可以参考[cephfs-secret.yaml](./cephfs-secret.yaml)自行提交 +- 使用方法 + 1. 查看是否已存在ceph-secret,若看到已下输入说明已创建过ceph-secret,可跳过步骤2 + ```bash + >kubectl get secret + NAME TYPE DATA AGE + ceph-secret Opaque 1 19m + ``` + 1. 添加ceph-secret,从管理获取ceph集群的secret,并替换下面命令中的``变量 + ```bash + echo -n "" | base64 + ``` + 将上面命令输出的base64编码替换`ceph-secret.yaml`中的 + ```yml + apiVersion: v1 + kind: Secret + metadata: + name: ceph-secret + data: + key: + ``` + ```bash + kubectl create -f ceph-secret.yaml + ``` + 1. 参考[pod.yaml](./pod.yaml)提交pod + ```bash + kubectl create -f pod.yaml + ``` diff --git a/quickstart/cephfs/cephfs-secret.yaml b/quickstart/cephfs/cephfs-secret.yaml new file mode 100644 index 0000000..d61d3c2 --- /dev/null +++ b/quickstart/cephfs/cephfs-secret.yaml @@ -0,0 +1,6 @@ +apiVersion: v1 +kind: Secret +metadata: + name: ceph-secret +data: + key: QVFBaW93bFpCNTJ1SWhBQWdhektCL0o4cWlJVXdMN2QrcHhYVVE9PQ== diff --git a/quickstart/cephfs/pod.yaml b/quickstart/cephfs/pod.yaml new file mode 100644 index 0000000..5c0360e --- /dev/null +++ b/quickstart/cephfs/pod.yaml @@ -0,0 +1,21 @@ +apiVersion: v1 +kind: Pod +metadata: + name: cephfs2 +spec: + containers: + - name: cephfs-rw + image: nginx:1.7.9 + volumeMounts: + - mountPath: "/mnt/cephfs" + name: cephfs + volumes: + - name: cephfs + cephfs: + monitors: + - 172.19.32.166:6789 + path: / + user: admin + secretRef: + name: ceph-secret + readOnly: true From 30fde1cb66e867749368d6365d57a4f801b8d83b Mon Sep 17 00:00:00 2001 From: Yancey1989 Date: Wed, 3 May 2017 20:07:27 +0800 Subject: [PATCH 2/2] delete readonly --- quickstart/cephfs/pod.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/quickstart/cephfs/pod.yaml b/quickstart/cephfs/pod.yaml index 5c0360e..2d75169 100644 --- a/quickstart/cephfs/pod.yaml +++ b/quickstart/cephfs/pod.yaml @@ -18,4 +18,3 @@ spec: user: admin secretRef: name: ceph-secret - readOnly: true