Skip to content

Commit 0bf55d8

Browse files
authored
Merge pull request #73 from francescotimperi/seaweedfs
2 parents 7b36270 + 9b63874 commit 0bf55d8

24 files changed

+1032
-38
lines changed

.github/cisetup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ curl -sL $URL | tar tzvf - -C ~/.local/bin
3131
YQ_VER=v4.27.2
3232
YQ_BIN=yq_linux_amd64
3333
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VER}/${YQ_BIN} -O /usr/bin/yq && sudo chmod +x /usr/bin/yq
34-
MC_VER=RELEASE.2023-03-23T20-03-04Z
34+
MC_VER=RELEASE.2025-05-21T01-59-54Z
3535
sudo wget https://dl.min.io/client/mc/release/linux-${ARCH}/archive/mc.${MC_VER} -O /usr/bin/mc && sudo chmod +x /usr/bin/mc
3636
#URL="https://dl.k8s.io/release/$VER/bin/linux/$ARCH/kubectl"
3737
#curl -sSL "$URL" | sudo tee /usr/local/bin/kubectl && sudo chmod +x /usr/bin/kubectl

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ ADD --chown=nuvolaris:nuvolaris deploy/milvus-operator /home/nuvolaris/deploy/mi
7070
ADD --chown=nuvolaris:nuvolaris deploy/milvus /home/nuvolaris/deploy/milvus
7171
ADD --chown=nuvolaris:nuvolaris deploy/milvus-slim /home/nuvolaris/deploy/milvus-slim
7272
ADD --chown=nuvolaris:nuvolaris deploy/registry /home/nuvolaris/deploy/registry
73+
ADD --chown=nuvolaris:nuvolaris deploy/seaweedfs /home/nuvolaris/deploy/seaweedfs
7374
ADD --chown=nuvolaris:nuvolaris quota.sh /home/nuvolaris/
7475

7576
#------------------------------------------------------------------------------

deploy/nuvolaris-permissions/whisk-crd.yaml

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ spec:
149149
type: boolean
150150
registry:
151151
description: deploys a private registry to load on the fly generated action runtimes (false by default)
152-
type: boolean
152+
type: boolean
153+
seaweedfs:
154+
description: deploys an S3 compatible layer using a standalone deployment of seaweedfs
155+
type: boolean
153156
required:
154157
- openwhisk
155158
- couchdb
@@ -751,7 +754,10 @@ spec:
751754
type: integer
752755
ledgers:
753756
description: pulsar bookie ledgers instance volume size
754-
type: integer
757+
type: integer
758+
bucket:
759+
description: used to setup a quota on the S3 bucket when running under seaweedfs (default to 10240MB)
760+
type: integer
755761
replicas:
756762
description: number of total milvus replicas. Defaulted to 1
757763
type: integer
@@ -835,7 +841,50 @@ spec:
835841
- mode
836842
- volume-size
837843
- auth
838-
- hostname
844+
- hostname
845+
seaweedfs:
846+
description: used to configure the internal saweedfs data storage service
847+
type: object
848+
properties:
849+
volume-size:
850+
description: volume size in GB, default to 60GB
851+
type: integer
852+
default-bucket-quota:
853+
description: default bucket quota, default to 1024MB
854+
type: integer
855+
nuvolaris:
856+
description: used to configure the MINIO nuvolaris user used for non administrative purposes
857+
type: object
858+
properties:
859+
user:
860+
type: string
861+
password:
862+
type: string
863+
required:
864+
- user
865+
- password
866+
ingress:
867+
description: configuration option for global minio ingresses exposure
868+
type: object
869+
properties:
870+
s3-enabled:
871+
description: boolean flag to activate SEAWEEDFS S3 compatible ingress. Default to false
872+
type: boolean
873+
s3-hostname:
874+
description: ingress hostname to be used if true (normally s3.<apihost>)
875+
type: string
876+
console-enabled:
877+
description: boolean flag to expose SEAWEEDFS Filer UI
878+
type: boolean
879+
console-hostname:
880+
description: ingress hostname to be used (nora=mally filer.<apihost>)
881+
type: string
882+
required:
883+
- s3-enabled
884+
- console-enabled
885+
required:
886+
- volume-size
887+
- nuvolaris
839888
status:
840889
x-kubernetes-preserve-unknown-fields: true
841890
# type: object

deploy/redis/redis-set.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ spec:
3737
restartPolicy: Always
3838
containers:
3939
- name: redis
40-
image: bitnami/valkey:7.2.5
40+
image: bitnamisecure/valkey:latest
4141
command: ["/bin/sh","-c","redis-server /redis-master/redis.conf"]
4242
env:
4343
- name: MASTER
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
---
18+
apiVersion: v1
19+
kind: PersistentVolumeClaim
20+
metadata:
21+
name: seaweedfs-pvc
22+
namespace: nuvolaris
23+
spec:
24+
accessModes:
25+
- ReadWriteOnce
26+
resources:
27+
requests:
28+
storage: 30Gi
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
---
18+
apiVersion: apps/v1
19+
kind: StatefulSet
20+
metadata:
21+
name: seaweedfs
22+
namespace: nuvolaris
23+
spec:
24+
serviceName: "seaweedfs"
25+
replicas: 1
26+
selector:
27+
matchLabels:
28+
app: seaweedfs
29+
template:
30+
metadata:
31+
labels:
32+
app: seaweedfs
33+
spec:
34+
containers:
35+
- name: seaweedfs
36+
image: chrislusf/seaweedfs:3.97
37+
ports:
38+
- containerPort: 9000 # S3
39+
- containerPort: 9090 # Filer
40+
- containerPort: 9333 # Master
41+
command: ["weed"]
42+
args:
43+
- "server"
44+
- "-s3"
45+
- "-s3.port=9000"
46+
- "-filer"
47+
- "-filer.port=9090"
48+
- "-master.port=9333"
49+
- "-dir=/data"
50+
- "-volume.max=0"
51+
- "-master.volumeSizeLimitMB=1024"
52+
volumeMounts:
53+
- name: seaweedfs-data
54+
mountPath: /data
55+
volumes:
56+
- name: seaweedfs-data
57+
persistentVolumeClaim:
58+
claimName: seaweedfs-pvc
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
---
18+
apiVersion: v1
19+
kind: Service
20+
metadata:
21+
name: seaweedfs
22+
namespace: nuvolaris
23+
spec:
24+
type: NodePort
25+
ports:
26+
- name: s3-api
27+
port: 9000
28+
targetPort: 9000
29+
nodePort: 32090
30+
protocol: TCP
31+
- name: filer
32+
port: 9090
33+
targetPort: 9090
34+
nodePort: 32091
35+
protocol: TCP
36+
- name: master
37+
port: 9333
38+
targetPort: 9333
39+
nodePort: 32093
40+
protocol: TCP
41+
selector:
42+
app: seaweedfs

nuvolaris/kopf_util.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ def check_minio_ingresses(response: dict, item: dict):
7373
if(item['new']):
7474
response["minio-ingresses"]="update"
7575

76+
def check_seaweedfs_ingresses(response: dict, item: dict):
77+
"""
78+
Forces an update of seaweed-ingresses if needed
79+
"""
80+
if(item['path']=='spec.seaweedfs.ingress.s3-enabled' or item['path']=='spec.seaweedfs.ingress.console-enabled'):
81+
if(item['new']):
82+
response["seaweedfs-ingresses"]="update"
83+
7684
def check_registry_ingresses(response: dict, item: dict):
7785
"""
7886
Forces an update of registry-ingress if needed
@@ -100,9 +108,11 @@ def evaluate_differences(response: dict, differences: list):
100108
check_component(response, d,"spec.components.etcd","etcd")
101109
check_component(response, d,"spec.components.milvus","milvus")
102110
check_component(response, d,"spec.components.registry","registry")
111+
check_component(response, d,"spec.components.seaweedfs","seaweedfs")
103112
openwhisk(response, d)
104113
endpoint(response, d)
105114
check_minio_ingresses(response, d)
115+
check_seaweedfs_ingresses(response, d)
106116

107117
def detect_component_changes(kopf_diff):
108118
"""

nuvolaris/main.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import nuvolaris.etcd as etcd
4343
import nuvolaris.milvus_standalone as milvus
4444
import nuvolaris.registry_deploy as registry
45+
import nuvolaris.seaweedfs_deploy as seaweedfs
4546

4647
@kopf.on.startup()
4748
def configure(settings: kopf.OperatorSettings, **_):
@@ -84,6 +85,10 @@ def whisk_create(spec, name, **kwargs):
8485
"etcd":"?" #Etcdd configuration
8586
}
8687

88+
if cfg.get('components.minio') and cfg.get('components.seaweedfs'):
89+
state['controller']= "NotValid"
90+
raise kopf.PermanentError("Storage support for MINIO and SEAWEEDFS could not be activated simultaneously.")
91+
8792
runtime = cfg.get('nuvolaris.kube')
8893
logging.info(f"kubernetes engine in use={runtime}")
8994

@@ -93,7 +98,7 @@ def whisk_create(spec, name, **kwargs):
9398
state['preloader']= "on"
9499
logging.info(msg)
95100
except:
96-
logging.exception("could not create runtime preloader batach")
101+
logging.exception("could not create runtime preloader batch")
97102
state['preloader']= "error"
98103
else:
99104
state['preloader']= "off"
@@ -165,6 +170,13 @@ def whisk_create(spec, name, **kwargs):
165170
else:
166171
state['minio'] = "off"
167172

173+
if cfg.get('components.seaweedfs'):
174+
msg = seaweedfs.create(owner)
175+
logging.info(msg)
176+
state['seaweedfs'] = "on"
177+
else:
178+
state['seaweedfs'] = "off"
179+
168180
if cfg.get('components.static'):
169181
msg = static.create(owner)
170182
logging.info(msg)
@@ -332,6 +344,10 @@ def whisk_delete(spec, **kwargs):
332344
msg = minio.delete()
333345
logging.info(msg)
334346

347+
if cfg.get("components.seaweedfs"):
348+
msg = seaweedfs.delete()
349+
logging.info(msg)
350+
335351
if cfg.get('components.postgres'):
336352
msg = postgres.delete()
337353
logging.info(msg)

nuvolaris/milvus_standalone.py

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from nuvolaris.milvus_admin_client import MilvusAdminClient
3030
from nuvolaris.user_config import UserConfig
3131
from nuvolaris.user_metadata import UserMetadata
32+
from nuvolaris.seaweedfs_util import SeaweedfsClient
3233

3334

3435
def patchEntries(data: dict):
@@ -105,7 +106,7 @@ def create(owner=None):
105106
r"{.items[?(@.metadata.labels.app\.kubernetes\.io\/instance == 'nuvolaris-milvus')].metadata.name}")
106107

107108
milvus_api_host = cfg.get("milvus.host", "MILVUS_API_HOST", "nuvolaris-milvus")
108-
milvus_api_port = cfg.get("milvus.host", "MILVUS_API_PORT", "19530")
109+
milvus_api_port = cfg.get("milvus.port", "MILVUS_API_PORT", "19530")
109110

110111
logging.info("*** waiting for milvus api to be available")
111112
util.wait_for_http(f"http://{milvus_api_host}:{milvus_api_port}", up_statuses=[200,401], timeout=30)
@@ -117,14 +118,11 @@ def create(owner=None):
117118
return res
118119

119120

120-
def create_milvus_accounts(data: dict):
121+
def create_minio_milvus_account(data: dict):
121122
""""
122-
Creates technical accounts for ETCD and MINIO
123+
Creates technical accounts for MINIO
123124
"""
124125
try:
125-
# currently we use the ETCD root password, so we skip the ETCD user creation.
126-
# res = util.check(etcd.create_etcd_user(data['milvus_etcd_username'],data['milvus_etcd_password'],data['milvus_etcd_prefix']),"create_etcd_milvus_user",True)
127-
128126
minioClient = mutil.MinioClient()
129127
bucket_policy_names = []
130128
bucket_policy_names.append(f"{data['milvus_bucket_name']}/*")
@@ -135,8 +133,33 @@ def create_milvus_accounts(data: dict):
135133
return util.check(minioClient.assign_rw_bucket_policy_to_user(data["milvus_s3_username"], bucket_policy_names),
136134
"assign_milvus_s3_bucket_policy", res)
137135
except Exception as ex:
138-
logging.error("Could not create milvus ETCD and MINIO accounts", ex)
139-
return False
136+
logging.error("Could not create milvus MINIO accounts", ex)
137+
return False
138+
139+
def create_seaweedfs_milvus_account(data: dict):
140+
""""
141+
Creates technical accounts for SEAWEEDFS
142+
"""
143+
try:
144+
seaweedfsClient = SeaweedfsClient()
145+
res = util.check(seaweedfsClient.make_bucket(data["milvus_bucket_name"],data["milvus_bucket_quota"]),"make_milvus_bucket",True)
146+
return util.check(seaweedfsClient.add_user(data["milvus_s3_username"],data["milvus_s3_username"],data["milvus_s3_password"],data["milvus_bucket_name"]),"add_milvus_user",res)
147+
except Exception as ex:
148+
logging.error("Could not create milvus SEAWEEDFS accounts", ex)
149+
return False
150+
151+
def create_milvus_accounts(data: dict):
152+
""""
153+
Creates technical accounts for ETCD and MINIO
154+
"""
155+
# currently we use the ETCD root password, so we skip the ETCD user creation.
156+
# res = util.check(etcd.create_etcd_user(data['milvus_etcd_username'],data['milvus_etcd_password'],data['milvus_etcd_prefix']),"create_etcd_milvus_user",True)
157+
158+
if cfg.get('components.minio'):
159+
return create_minio_milvus_account(data)
160+
161+
if cfg.get('components.seaweedfs'):
162+
return create_seaweedfs_milvus_account(data)
140163

141164

142165
def create_default_milvus_database(data):

0 commit comments

Comments
 (0)