Skip to content
This repository was archived by the owner on Jun 29, 2022. It is now read-only.

Commit 7e854f2

Browse files
committed
docs: Add "How to setup storage using Rook Ceph?"
This document enlists steps that will help user setup storage using Rook Ceph component. Signed-off-by: Suraj Deshmukh <suraj@kinvolk.io>
1 parent 863a7a9 commit 7e854f2

File tree

1 file changed

+294
-0
lines changed

1 file changed

+294
-0
lines changed
Lines changed: 294 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,294 @@
1+
# Kubernetes storage with Rook Ceph on Packet cloud
2+
3+
## Contents
4+
5+
- [Introduction](#introduction)
6+
- [Prerequisites](#prerequisites)
7+
- [Steps](#steps)
8+
- [Step 1: Deploy storage worker pool](#step-1-deploy-storage-worker-pool)
9+
- [Config](#config)
10+
- [Deploy the worker pool](#deploy-the-worker-pool)
11+
- [Step 2: Deploy `rook`](#step-2-deploy-rook)
12+
- [Config](#config-1)
13+
- [Deploy the component](#deploy-the-component)
14+
- [Step 3: Deploy `rook-ceph`](#step-3-deploy-rook-ceph)
15+
- [Config](#config-2)
16+
- [Deploy the component](#deploy-the-component-1)
17+
- [Access the Ceph dashboard](#access-the-ceph-dashboard)
18+
- [Enable and access toolbox](#enable-and-access-toolbox)
19+
- [Enable monitoring](#enable-monitoring)
20+
- [Make default storage class](#make-default-storage-class)
21+
- [Additional resources](#additional-resources)
22+
23+
## Introduction
24+
25+
This guide provides the steps for deploying a storage stack using the `rook` and `rook-ceph` Lokomotive component and explains how to access Ceph dashboard, Ceph toolbox and how to enable monitoring.
26+
27+
At the end of this tutorial you will have a storage backed by `rook` and `rook-ceph`. Any application in the cluster can request storage using Kubernetes PVC.
28+
29+
## Prerequisites
30+
31+
* A Lokomotive cluster deployed on a Packet cloud and accessible via `kubectl`.
32+
33+
## Steps
34+
35+
### Step 1: Deploy storage worker pool
36+
37+
#### Config
38+
39+
Deploy a cluster with at least one worker pool dedicated to `rook-ceph`. A dedicated worker pool configuration should look like the following:
40+
41+
```tf
42+
cluster "packet" {
43+
...
44+
45+
worker_pool "storage" {
46+
count = 3
47+
node_type = "c2.medium.x86"
48+
49+
labels = "storage.lokomotive.io=ceph"
50+
taints = "storage.lokomotive.io=ceph:NoSchedule"
51+
}
52+
}
53+
```
54+
55+
- The number of machines provided using `count` should be an odd number greater than or equal to three.
56+
- Type of node, provided using `node_type`, should be one that has multiple disks like `c2.medium.x86` or `s1.large.x86`. Find out more servers [here](https://www.packet.com/cloud/servers/).
57+
- To steer `rook-ceph` workload on these storage nodes provide `labels`.
58+
- Provide `taints` so that other workload can be **steered away** by default. This setting is not mandatory, but isolating storage workloads from others is recommended so that other workloads do not degrade the performance of the storage.
59+
60+
#### Deploy the worker pool
61+
62+
Execute the following command to deploy the `storage` worker pool:
63+
64+
```bash
65+
lokoctl cluster apply -v --skip-components
66+
```
67+
68+
### Step 2: Deploy `rook`
69+
70+
#### Config
71+
72+
Create a file named `storage.lokocfg` with the following contents:
73+
74+
```tf
75+
component "rook" {
76+
node_selector = {
77+
"storage.lokomotive.io" = "ceph"
78+
}
79+
80+
toleration {
81+
key = "storage.lokomotive.io"
82+
operator = "Equal"
83+
value = "ceph"
84+
effect = "NoSchedule"
85+
}
86+
87+
agent_toleration_key = "storage.lokomotive.io"
88+
agent_toleration_effect = "NoSchedule"
89+
90+
discover_toleration_key = "storage.lokomotive.io"
91+
discover_toleration_effect = "NoSchedule"
92+
}
93+
```
94+
95+
- `node_selector` should match the `labels` attribute provided in the `worker_pool`.
96+
- `toleration` should match the `taints` attribute mentioned in the `worker_pool`.
97+
- `agent_toleration_key` and `discover_toleration_key` should match the `key` of the `taints` attribute provided in the `worker_pool`.
98+
- `agent_toleration_effect` and `discover_toleration_effect` should match the `effect` of the `taints` attribute provided in the `worker_pool`.
99+
100+
For more information on available configuration options for the `rook` component, visit the component's [configuration reference](../configuration-reference/components/rook.md).
101+
102+
#### Deploy the component
103+
104+
Execute the following command to deploy the `rook` component:
105+
106+
```bash
107+
lokoctl component apply rook
108+
```
109+
110+
Verify the operator pod in the `rook` namespace is in the `Running` state (this may take a few minutes):
111+
112+
```console
113+
$ kubectl -n rook get pods -l app=rook-ceph-operator
114+
NAME READY STATUS RESTARTS AGE
115+
rook-ceph-operator-76d8687f95-6knf8 1/1 Running 0 2m
116+
```
117+
118+
### Step 3: Deploy `rook-ceph`
119+
120+
#### Config
121+
122+
Add following contents to the previously created file `storage.lokocfg`:
123+
124+
```tf
125+
component "rook-ceph" {
126+
monitor_count = 3
127+
128+
node_affinity {
129+
key = "storage.lokomotive.io"
130+
operator = "Exists"
131+
}
132+
133+
toleration {
134+
key = "storage.lokomotive.io"
135+
operator = "Equal"
136+
value = "ceph"
137+
effect = "NoSchedule"
138+
}
139+
140+
storage_class {
141+
enable = true
142+
}
143+
}
144+
```
145+
146+
- `monitor_count` should be an odd number greater than three and not higher than the `count` attribute of workers in the `worker_pool`.
147+
- `node_affinity` should match the `labels` attribute provided in the `worker_pool`.
148+
- `toleration` should match the `taints` attribute provided in the `worker_pool`.
149+
150+
For more information on available configuration options for the `rook-ceph` component, visit the component's [configuration reference](../configuration-reference/components/rook-ceph.md).
151+
152+
#### Deploy the component
153+
154+
Execute the following command to deploy the `rook-ceph` component:
155+
156+
```bash
157+
lokoctl component apply rook-ceph
158+
```
159+
160+
Verify the [OSD](https://docs.ceph.com/docs/master/glossary/#term-ceph-osd-daemon) pods in the `rook` namespace are in the `Running` state (this may take a few minutes):
161+
162+
```console
163+
$ kubectl -n rook get pods -l app=rook-ceph-osd
164+
NAME READY STATUS RESTARTS AGE
165+
rook-ceph-osd-0-6d4f69dbf9-26kzl 1/1 Running 0 15m
166+
rook-ceph-osd-1-86c9597b84-lmh94 1/1 Running 0 15m
167+
rook-ceph-osd-2-6d97697897-7bprl 1/1 Running 0 15m
168+
rook-ceph-osd-3-5bfb9d86b-rk6v4 1/1 Running 0 15m
169+
rook-ceph-osd-4-5b76cb9675-cxkdw 1/1 Running 0 15m
170+
rook-ceph-osd-5-8c86f5c6c-6qxtz 1/1 Running 0 15m
171+
rook-ceph-osd-6-5b9cc479b7-vjc9v 1/1 Running 0 15m
172+
rook-ceph-osd-7-7b84d6cc48-b46z9 1/1 Running 0 15m
173+
rook-ceph-osd-8-5868969f97-2bn9r 1/1 Running 0 15m
174+
```
175+
176+
## Access the Ceph dashboard
177+
178+
Ceph dashboard provides valuable visual information. It is an essential tool to monitor the Ceph cluster. Here are the steps on how to access it.
179+
180+
Obtain the password for the `admin` Ceph user by running the following command:
181+
182+
```bash
183+
kubectl -n rook get secret rook-ceph-dashboard-password -o jsonpath="{['data']['password']}" | base64 --decode && echo
184+
```
185+
186+
Execute the following command to forward port `8443` locally to the Ceph manager pod:
187+
188+
```bash
189+
kubectl -n rook port-forward svc/rook-ceph-mgr-dashboard 8443
190+
```
191+
192+
Now open the following URL: [https://localhost:8443](https://localhost:8443) and enter the username `admin` and the password obtained from the first step.
193+
194+
## Enable and access toolbox
195+
196+
Ceph is a complex software system, and not everything that happens in the Ceph cluster is visible at the `rook` layer of abstraction. So the command-line interface to interact with Ceph cluster is useful to extract such hidden events and information. Ceph toolbox helps you access the ceph cluster using `ceph` CLI utility. Using the utility you can configure the Ceph cluster setting and debug the cluster.
197+
198+
To deploy the toolbox, the `rook-ceph` component config should set the attribute `enable_toolbox` to `true`.
199+
200+
```tf
201+
component "rook-ceph" {
202+
enable_toolbox = true
203+
...
204+
}
205+
```
206+
207+
Execute the following command to apply the changes:
208+
209+
```bash
210+
lokoctl component apply rook-ceph
211+
```
212+
213+
Verify the toolbox pod in the `rook` namespace is in the `Running` state (this may take a few minutes):
214+
215+
```console
216+
$ kubectl -n rook get deploy rook-ceph-tools
217+
NAME READY UP-TO-DATE AVAILABLE AGE
218+
rook-ceph-tools 1/1 1 1 39s
219+
```
220+
221+
Execute the following command to access the toolbox pod:
222+
223+
```bash
224+
kubectl -n rook exec -it $(kubectl -n rook get pods -l app=rook-ceph-tools -o name) -- bash
225+
```
226+
227+
Once inside the pod you can run usual `ceph` commands:
228+
229+
```bash
230+
ceph status
231+
ceph osd status
232+
ceph df
233+
rados df
234+
```
235+
236+
## Enable monitoring
237+
238+
Monitor `rook` and `rook-ceph` components using the `prometheus-operator` component. To enable your `rook` component config should have the attribute `enable_monitoring` set to `true`.
239+
240+
> **NOTE:** Deploy the `prometheus-operator` component before. For more information follow this [doc](./monitoring-with-prometheus-operator.md).
241+
242+
```tf
243+
component "rook" {
244+
enable_monitoring = true
245+
...
246+
}
247+
```
248+
249+
Execute the following command to apply the changes:
250+
251+
```bash
252+
lokoctl component apply rook
253+
```
254+
255+
## Make default storage class
256+
257+
It is recommended to make the storage class as default if `rook-ceph` is the only storage provider in the cluster. This setting helps to provision volumes for the [PVCs](https://kubernetes.io/docs/concepts/storage/persistent-volumes/#persistentvolumeclaims) created by workloads. The `rook-ceph` component config should look like the following:
258+
259+
```tf
260+
component "rook-ceph" {
261+
...
262+
263+
storage_class {
264+
enable = true
265+
default = true
266+
}
267+
}
268+
```
269+
270+
Execute the following command to apply the changes:
271+
272+
```bash
273+
lokoctl component apply rook
274+
```
275+
276+
Verify the StorageClass is default:
277+
278+
```console
279+
$ kubectl get sc rook-ceph-block
280+
NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE
281+
rook-ceph-block (default) rook.rbd.csi.ceph.com Delete Immediate true 8m17s
282+
```
283+
284+
## Additional resources
285+
286+
- `rook` component [configuration reference](../configuration-reference/components/rook.md) guide.
287+
- `rook-ceph` component [configuration reference](../configuration-reference/components/rook-ceph.md) guide.
288+
- Rook docs:
289+
290+
- [Ceph toolbox](https://rook.io/docs/rook/master/ceph-toolbox.html).
291+
- [Ceph dashboard](https://rook.io/docs/rook/master/ceph-dashboard.html).
292+
- [Ceph direct tools](https://rook.io/docs/rook/master/direct-tools.html).
293+
- [Ceph advanced configuration](https://rook.io/docs/rook/master/ceph-advanced-configuration.html).
294+
- [Disaster recovery](https://rook.io/docs/rook/master/ceph-disaster-recovery.html).

0 commit comments

Comments
 (0)