Skip to content

Commit bdeb82a

Browse files
feat: longhorn guide
1 parent 6977040 commit bdeb82a

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
This is a basic `SecretProviderClass` manifest:
36+
37+
```yaml title="my-longhorn-example.yaml"
38+
# add-highlight-start
39+
apiVersion: v1
40+
kind: PersistentVolumeClaim
41+
metadata:
42+
name: <name>-pvc
43+
spec:
44+
accessModes:
45+
- ReadWriteOnce
46+
storageClassName: longhorn-static
47+
resources:
48+
requests:
49+
storage: <size>
50+
# add-highlight-end
51+
---
52+
kind: Pod
53+
apiVersion: v1
54+
metadata:
55+
name: my-longhorn-example-pod
56+
namespace: <namespace>
57+
spec:
58+
containers:
59+
- name: busybox
60+
image: registry.k8s.io/e2e-test-images/busybox:1.29-4
61+
command:
62+
- '/bin/sleep'
63+
- '10000'
64+
# add-highlight-start
65+
volumeMounts:
66+
- name: my-volume # Name of the volume defined below
67+
mountPath: /app/data # Where you need to mount the volume
68+
# add-highlight-end
69+
# add-highlight-start
70+
volumes:
71+
- name: my-volume # it can be whatever you want
72+
persistentVolumeClaim:
73+
claimName: <name>-pvc # the name of the PVC defined above
74+
# add-highlight-end
75+
```
76+
77+
Parameters:
78+
- `namespace` k8s namespace
79+
- `name` should identify the app where the volume will be used
80+
- `size` size of the volume. Check [resource units](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory).
81+
e.g. `300M`, `1Gi`, `200Mi`

0 commit comments

Comments
 (0)