Skip to content

Commit 599a0a4

Browse files
feat: longhorn guide (#36)
* feat: longhorn guide * fix: remove line
1 parent 6977040 commit 599a0a4

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
title: Add Storage
3+
---
4+
5+
## Core Concepts
6+
7+
Many applications and services need a physical volume or storage to store their data or configuration.
8+
As you should know, we use AKS (Kubernetes) to host everything from databases to telegram bots.
9+
In our AKS cluster we have (ATTOW) a single node (VM) `Standard_B2ms` which allows to attach only 4 disks,
10+
one of which is the VM's disk itself.
11+
This means that you can only attach 3 managed disks to the Cluster, resulting in limited deployable services.
12+
13+
To solve this problem, we added [Longhorn](https://longhorn.io/) so that we can create multiple
14+
[PVC](https://kubernetes.io/docs/concepts/storage/persistent-volumes) from the VM's disk
15+
(ATTOW it's a 128GB Standard SSD).
16+
17+
:::important
18+
Longhorn is a handy tool to create multiple PVC/volumes without creating new disks, but this comes with degraded performance and stability.
19+
If you want to deploy something critical like a production database, it's recommended to create a dedicated
20+
[Managed Disk](https://learn.microsoft.com/en-us/azure/virtual-machines/managed-disks-overview).
21+
:::
22+
23+
## Add a Longhorn volume
24+
25+
First of all, you must login in [our Longhorn dashboard](https://longhorn.polinetwork.org) and check
26+
how much space is available for scheduling a new volume.
27+
:::tip
28+
- `Schedulable` is space you can use to create new volumes
29+
- `Reserved` is space reserved to the VM, not available to create new volumes
30+
31+
How much `Reserved` space is configured in the `Node` page, but at least 20-25 GB is recommended.
32+
:::
33+
34+
Once you verified you have sufficient `Schedulable` space available, you can create the PVC in the k8s manifest:
35+
36+
```yaml title="my-longhorn-example.yaml"
37+
# add-highlight-start
38+
apiVersion: v1
39+
kind: PersistentVolumeClaim
40+
metadata:
41+
name: <name>-pvc
42+
spec:
43+
accessModes:
44+
- ReadWriteOnce
45+
storageClassName: longhorn-static
46+
resources:
47+
requests:
48+
storage: <size>
49+
# add-highlight-end
50+
---
51+
kind: Pod
52+
apiVersion: v1
53+
metadata:
54+
name: my-longhorn-example-pod
55+
namespace: <namespace>
56+
spec:
57+
containers:
58+
- name: busybox
59+
image: registry.k8s.io/e2e-test-images/busybox:1.29-4
60+
command:
61+
- '/bin/sleep'
62+
- '10000'
63+
# add-highlight-start
64+
volumeMounts:
65+
- name: my-volume # Name of the volume defined below
66+
mountPath: /app/data # Where you need to mount the volume
67+
# add-highlight-end
68+
# add-highlight-start
69+
volumes:
70+
- name: my-volume # it can be whatever you want
71+
persistentVolumeClaim:
72+
claimName: <name>-pvc # the name of the PVC defined above
73+
# add-highlight-end
74+
```
75+
76+
Parameters:
77+
- `namespace` k8s namespace
78+
- `name` should identify the app where the volume will be used
79+
- `size` size of the volume. Check [resource units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory).
80+
e.g. `300M`, `1Gi`, `200Mi`

0 commit comments

Comments
 (0)