Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Seaweed FS to devspace/k8s #8119

Merged
merged 7 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 60 additions & 4 deletions packages/grid/devspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,18 @@ deployments:
manifests:
- "k8s/manifests/traefik-domain.yaml"

seaweedfs-config:
kubectl:
manifests:
- "k8s/manifests/seaweedfs.yaml"

proxy:
helm:
upgradeArgs:
- --dependency-update
chart:
name: component-chart
repo: https://charts.devspace.sh
version: "0.9.0"
values:
containers:
- image: "${DOCKER_IMAGE_TRAEFIK}:${TRAEFIK_VERSION}"
Expand Down Expand Up @@ -120,7 +124,6 @@ deployments:
chart:
name: component-chart
repo: https://charts.devspace.sh
version: "0.9.0"
values:
containers:
- image: "${CONTAINER_REGISTRY}/${DOCKER_IMAGE_BACKEND}:${VERSION}"
Expand Down Expand Up @@ -188,14 +191,14 @@ deployments:
name: "backend"
ports:
- port: "${HTTP_PORT}"

mongo:
helm:
upgradeArgs:
- --dependency-update
chart:
name: component-chart
repo: https://charts.devspace.sh
version: "0.9.0"
values:
containers:
- image: "${MONGO_IMAGE}:${MONGO_VERSION}"
Expand All @@ -218,14 +221,63 @@ deployments:
ports:
- port: "27017"

seaweedfs:
helm:
upgradeArgs:
- --dependency-update
chart:
name: component-chart
repo: https://charts.devspace.sh
values:
containers:
- image: "${DOCKER_IMAGE_SEAWEEDFS}:${SEAWEEDFS_VERSION}"
command:
- sh
- /etc/seaweedfs/start.sh
env:
- name: S3_VOLUME_SIZE_MB
value: "${S3_VOLUME_SIZE_MB}"
- name: S3_ROOT_USER
value: "${S3_ROOT_USER}"
- name: S3_ROOT_PWD
value: "${S3_ROOT_PWD}"
- name: S3_PORT
value: "${S3_PORT}"
volumeMounts:
- containerPath: /etc/seaweedfs/filer.toml
volume:
name: seaweedfs-config
subPath: /filer.toml
readOnly: false
- containerPath: /etc/seaweedfs/start.sh
volume:
name: seaweedfs-config
subPath: /start.sh
readOnly: false
- containerPath: /data/blob
volume:
name: seaweedfs-data
subPath: /
readOnly: false
volumes:
- name: seaweedfs-data
size: "5Gi"
- name: seaweedfs-config
configMap:
name: seaweedfs-config
service:
name: seaweedfs
ports:
- port: "8888" # filer
- port: "8333" # S3
Comment on lines +271 to +272
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let me know if we need to expose these ports, else I can move them under "dev"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can leave these to under dev only.


frontend:
helm:
upgradeArgs:
- --dependency-update
chart:
name: component-chart
repo: https://charts.devspace.sh
version: "0.9.0"
values:
containers:
- image: "${CONTAINER_REGISTRY}/${DOCKER_IMAGE_FRONTEND}:${VERSION}"
Expand All @@ -248,6 +300,10 @@ dev:
imageSelector: "${MONGO_IMAGE}:${MONGO_VERSION}"
ports:
- port: "27017"
seaweedfs:
imageSelector: "${DOCKER_IMAGE_SEAWEEDFS}:${SEAWEEDFS_VERSION}"
ports:
- port: "9333" # admin
backend:
imageSelector: "${CONTAINER_REGISTRY}/${DOCKER_IMAGE_BACKEND}"
env:
Expand Down
32 changes: 22 additions & 10 deletions packages/grid/helm/helm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
# third party
import yaml


# Preserve those beautiful multi-line strings with |
# https://stackoverflow.com/a/33300001
def str_presenter(dumper: Any, data: Any) -> Any:
if len(data.splitlines()) > 1: # check for multiline string
return dumper.represent_scalar("tag:yaml.org,2002:str", data, style="|")
return dumper.represent_scalar("tag:yaml.org,2002:str", data)


yaml.add_representer(str, str_presenter)
yaml.representer.SafeRepresenter.add_representer(str, str_presenter)

template_variables = {
"STACK_API_KEY": "secrets.syft",
"DEFAULT_ROOT_EMAIL": "secrets.syft",
Expand Down Expand Up @@ -105,7 +117,11 @@ def main() -> None:
)
input_data = "---\n" + "\n".join(lines[first_index - 1 :])
except StopIteration:
print("No line starting with 'apiVersion' found in the input.")
print("helm.py error: No line starting with 'apiVersion' found in the input.")
print("------------------------------")
print("Got input text:")
print(text)
print("------------------------------")
return

helm_chart_template_dir = f"{helm_dir}/syft/templates"
Expand Down Expand Up @@ -135,17 +151,13 @@ def main() -> None:
os.makedirs(output_dir, exist_ok=True)

# Parse yaml to find metadata.name
yaml_content = yaml.safe_load("\n".join(lines[1:])) # exclude source_line
yaml_content = yaml.safe_load("\n".join(lines)) # exclude source_line
fix_devspace_yaml(yaml_content)
name = yaml_content.get("metadata", {}).get("name")
kind = yaml_content.get("kind", "").lower()
if name:
# Create new file with name or append if it already exists
new_file = os.path.join(output_dir, f"{name}.yaml")
if os.path.exists(new_file):
mode = "a" # append if file exists
else:
mode = "w" # write if new file

new_file = os.path.join(output_dir, f"{name}-{kind}.yaml")
yaml_dump = yaml.dump(yaml_content)
yaml_dump = (
yaml_dump.replace("'{{", "{{")
Expand All @@ -154,8 +166,8 @@ def main() -> None:
.replace("}}''", "}}")
)

with open(new_file, mode) as f:
f.write("---\n" + yaml_dump) # add document separator
with open(new_file, "w") as f:
f.write(yaml_dump) # add document separator


if __name__ == "__main__":
Expand Down
Loading