Skip to content

Commit 814ed65

Browse files
authored
Merge pull request #5 from travisperson/docs/add-development-doc
docs: add development doc
2 parents d8d8a88 + b4521d0 commit 814ed65

File tree

1 file changed

+267
-0
lines changed

1 file changed

+267
-0
lines changed

docs/DEVELOPMENT.md

Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
1+
# DEVELOPMENT
2+
3+
## Summary
4+
5+
This document describes the development environment and how to set it up. This is a feature rich environment that
6+
targets k8s.
7+
8+
Development can also be done using docker / docker-compose and tmux which is handy for doing quick work before
9+
running on k8s somewhere, but is not covered here.
10+
11+
[Deploy MinIO on Docker Compose](https://docs.min.io/docs/deploy-minio-on-docker-compose.html)
12+
13+
This document is not step by step instruction, but provides the large parts. At the end you will have:
14+
15+
- kind k8s local cluster
16+
- minio bucket
17+
- lotus daemon
18+
- with shared jwt token that can be used by other k8s resources
19+
20+
MinIO API
21+
```
22+
http://minio.minio.svc.cluster.local
23+
```
24+
25+
Lotus API Multiaddrs
26+
```
27+
/dns/lotus-a-lotus-daemon.ntwk-butterflynet-filsnap.svc.cluster.local/tcp/1234
28+
/dns/lotus-b-lotus-daemon.ntwk-butterflynet-filsnap.svc.cluster.local/tcp/1234
29+
/dns/lotus-c-lotus-daemon.ntwk-butterflynet-filsnap.svc.cluster.local/tcp/1234
30+
```
31+
32+
## Requirements
33+
34+
The following tools are expected to be installed. This document does not cover their installation, but will cover their
35+
usage as required to setup the development environment.
36+
37+
- [docker](https://docs.docker.com/get-docker/)
38+
- [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl)
39+
- [kind](https://kind.sigs.k8s.io/docs/user/quick-start/)
40+
- kubectl [krew](https://krew.sigs.k8s.io/)
41+
- [helm](https://helm.sh/docs/intro/quickstart/)
42+
- lotus-shed
43+
44+
45+
Install the minio plugin:
46+
47+
```
48+
kubectl krew update
49+
kubectl krew install minio
50+
```
51+
52+
Add required helm chart repositories:
53+
54+
```
55+
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
56+
helm repo add filecoin https://filecoin-project.github.io/helm-charts
57+
helm repo update
58+
```
59+
60+
### Creating a Kind Cluster
61+
62+
[More Information: Cluster Configuration](https://kind.sigs.k8s.io/docs/user/quick-start/#configuring-your-kind-cluster)
63+
64+
Create a cluster with three worker nodes.
65+
66+
```
67+
$ cat > cluster.yaml <<EOF
68+
kind: Cluster
69+
apiVersion: kind.x-k8s.io/v1alpha4
70+
nodes:
71+
- role: control-plane
72+
- role: worker
73+
- role: worker
74+
- role: worker
75+
EOF
76+
```
77+
```
78+
$ kind create cluster --config cluster.yaml
79+
```
80+
81+
#### Moving Container Images
82+
83+
[More Information: Loading Images](https://kind.sigs.k8s.io/docs/user/quick-start/#loading-an-image-into-your-cluster)
84+
85+
When building the docker container, you will need to move it into the cluster. Kind provides an easy way to do this.
86+
87+
```
88+
$ kind load docker-image filsnap:latest
89+
```
90+
91+
### Install Monitoring Stack
92+
93+
[More Information: Helm Chart](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack)
94+
95+
[More Information: Operator](https://github.com/prometheus-operator/prometheus-operator)
96+
97+
98+
Install the prometheus monitoring stack with grafana enabled and persistence storage. This configuration enables cluster
99+
wide monitoring with no selectors, and persistence of data.
100+
101+
```
102+
$ cat > values-prom-stack.yaml <<EOF
103+
prometheus:
104+
prometheusSpec:
105+
ruleSelector: {}
106+
ruleNamespaceSelector: {}
107+
ruleSelectorNilUsesHelmValues: false
108+
serviceMonitorSelector: {}
109+
serviceMonitorNamespaceSelector: {}
110+
serviceMonitorSelectorNilUsesHelmValues: false
111+
podMonitorSelector: {}
112+
podMonitorNamespaceSelector: {}
113+
podMonitorSelectorNilUsesHelmValues: false
114+
115+
storageSpec:
116+
volumeClaimTemplate:
117+
spec:
118+
storageClassName: standard
119+
accessModes: ["ReadWriteOnce"]
120+
resources:
121+
requests:
122+
storage: 10Gi
123+
124+
grafana:
125+
enabled: true
126+
persistence:
127+
enabled: true
128+
size: 10Gi
129+
EOF
130+
```
131+
```
132+
helm install prometheus prometheus-community/kube-prometheus-stack -n monitoring --values values-prom-stack.yaml
133+
```
134+
135+
### Installing MinIO Operator & Creating Tenant
136+
137+
[More Information: Operator](https://github.com/minio/operator)
138+
139+
```
140+
$ kubectl minio init
141+
```
142+
143+
#### Creating a Tenant
144+
145+
[More Information: Tenant](https://docs.min.io/minio/k8s/tenant-management/deploy-minio-tenant.html)
146+
147+
```
148+
$ kubectl create namespace minio
149+
$ kubectl minio proxy -n minio-operator
150+
```
151+
152+
Follow the instruction provided by `minio proxy` and login to the operator console then click the `New Tenant`.
153+
154+
Fill out the form.
155+
156+
| Page | Field | Value |
157+
|----------|--------------------|----------|
158+
| Setup | Name | minio |
159+
| Setup | Namespace | minio |
160+
| Setup | Storage Class | standard |
161+
| Setup | Number of Servers | 3 |
162+
| Setup | Drivers per Server | 2 |
163+
| Setup | Total Size | 300 |
164+
| Setup | CPU Request | 2 |
165+
| Setup | Memory Request | 4 |
166+
| Security | Enabled TLS | OFF |
167+
168+
Copy down the Console Credentials, you will also use these for api access to the bucket.
169+
170+
[More Information: User Management](https://docs.min.io/minio/k8s/tutorials/user-management.html).
171+
172+
#### Accessining MinIO Console & Creating Bucket
173+
174+
```
175+
$ kubectl port-forward service/minio-console 9090:9090 -n minio
176+
```
177+
178+
Open the console http://localhost:9090 and login using the Console Credentials.
179+
180+
Create a bucket called `filsnap` with all options disabled.
181+
182+
### Creating Lotus Nodes
183+
184+
Create a namespace for the lotus daemons
185+
186+
```
187+
$ kubectl create namespace ntwk-butterflynet-filsnap
188+
```
189+
190+
Note: This is the same namespace you will develop in, not technically required, but it's easier
191+
to share the same secret resource, than to copy and manage in two different places. This requirement
192+
could be removed, but due to requiring the ability to shutdown daemons (due to a bug) the admin privilage
193+
is required, otherwise all operations are `read-only` and wouldn't require a token at all.
194+
195+
#### Creating a shared jwt token
196+
197+
```
198+
$ mkdir /tmp/secrets
199+
$ lotus-shed jwt new node
200+
$ lotus-shed base16 -decode < jwt-node.jwts > /tmp/secrets/auth-jwt-private
201+
$ cp jwt-node.token /tmp/secrets/jwt-all-privs-token
202+
203+
$ lotus-shed jwt token --read --output /tmp/secrets/jwt-ro-privs-token jwt-node.jwts
204+
$ lotus-shed jwt token --read --write --output /tmp/secrets/jwt-rw-privs-token jwt-node.jwts
205+
$ lotus-shed jwt token --sign --output /tmp/secrets/jwt-so-privs-token jwt-node.jwts
206+
207+
$ kubectl create secret generic lotus-jwt \
208+
--from-file=auth-jwt-private=/tmp/secrets/auth-jwt-private \
209+
--from-file=jwt-all-privs-token=/tmp/secrets/jwt-all-privs-token \
210+
--from-file=jwt-ro-privs-token=/tmp/secrets/jwt-ro-privs-token \
211+
--from-file=jwt-rw-privs-token=/tmp/secrets/jwt-rw-privs-token \
212+
--from-file=jwt-so-privs-token=/tmp/secrets/jwt-so-privs-token \
213+
--output=name --namespace ntwk-butterflynet-filsnap
214+
215+
$ rm -rf /tmp/secrets
216+
$ rm jwt-node.jwts jwt-node.token
217+
```
218+
219+
#### Install Butterfly Lotus Daemons
220+
221+
[Docker Images](https://hub.docker.com/r/travisperson/lotus/tags?page=1&name=butterfly)
222+
223+
```
224+
$ cat values-lotus.yaml <<EOF
225+
image:
226+
tag: butterflynet-<version>
227+
228+
prometheusOperatorServiceMonitor: true
229+
230+
secrets:
231+
jwt:
232+
enabled: true
233+
secretName: lotus-jwt
234+
235+
daemonEnvs:
236+
- name: GOLOG_LOG_FMT
237+
value: json
238+
239+
daemonConfig: |
240+
[API]
241+
ListenAddress = "/ip4/0.0.0.0/tcp/1234/http"
242+
[Libp2p]
243+
ListenAddresses = ["/ip4/0.0.0.0/tcp/1347"]
244+
245+
additionalLabels:
246+
network: butterflynet
247+
248+
persistence:
249+
datastore:
250+
enabled: true
251+
storageClassName: "standard"
252+
size: "15Gi"
253+
journal:
254+
enabled: true
255+
storageClassName: "standard"
256+
size: "1Gi"
257+
parameters:
258+
enabled: true
259+
storageClassName: "standard"
260+
size: "1Gi"
261+
EOF
262+
```
263+
```
264+
helm install lotus-a filecoin/lotus-fullnode --values values-lotus.yaml --namespace ntwk-butterflynet-filsnap
265+
helm install lotus-b filecoin/lotus-fullnode --values values-lotus.yaml --namespace ntwk-butterflynet-filsnap
266+
helm install lotus-c filecoin/lotus-fullnode --values values-lotus.yaml --namespace ntwk-butterflynet-filsnap
267+
```

0 commit comments

Comments
 (0)