francescotimperi commented on code in PR #73: URL: https://github.com/apache/openserverless-operator/pull/73#discussion_r2365714493
########## nuvolaris/seaweedfs_deploy.py: ########## @@ -0,0 +1,278 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# +import kopf, logging, time, os +import nuvolaris.kube as kube +import nuvolaris.kustomize as kus +import nuvolaris.config as cfg +import nuvolaris.util as util +import nuvolaris.openwhisk as openwhisk +import nuvolaris.seaweedfs_ingress as seaweedfs_ingress +import nuvolaris.operator_util as operator_util + +from nuvolaris.user_config import UserConfig +from nuvolaris.user_metadata import UserMetadata +from nuvolaris.seaweedfs_util import SeaweedfsClient + +def _get_seaweedfs_service(): + return util.get_service("{.items[?(@.spec.selector.app == 'seaweedfs')]}") + +def _add_seaweedfs_user_metadata(ucfg: UserConfig, user_metadata:UserMetadata): + """ + adds entries for seaweedfs connectivity S3_HOST, S3_PORT, S3_ACCESS_KEY, S3_SECRET_KEY + """ + + try: + seaweed_service = _get_seaweedfs_service() + if(seaweed_service): + seaweedfs_host = f"{seaweed_service['metadata']['name']}.{seaweed_service['metadata']['namespace']}.svc.cluster.local" + access_key = ucfg.get('namespace') + secret_key = ucfg.get("object-storage.password") + user_metadata.add_metadata("S3_PROVIDER","seaweedfs") + user_metadata.add_metadata("S3_HOST",seaweedfs_host) + user_metadata.add_metadata("S3_ACCESS_KEY",access_key) + user_metadata.add_metadata("S3_SECRET_KEY",secret_key) + + user_metadata.add_safely_from_cm("S3_API_URL", '{.metadata.annotations.s3_api_url}') + user_metadata.add_safely_from_cm("S3_CONSOLE_URL", '{.metadata.annotations.s3_console_url}') + + ports = list(seaweed_service['spec']['ports']) + for port in ports: + if(port['name']=='s3-api'): + user_metadata.add_metadata("S3_PORT",port['port']) + + return None + except Exception as e: + logging.error(f"failed to build SEAWEEDFS metadata for {ucfg.get('namespace')}: {e}") + return None + +def create(owner=None): + logging.info("*** configuring seaweedfs standalone") + + data = util.get_seaweedfs_config_data() + + tplp = ["pvc-attach.yaml"] Review Comment: @d4rkstar this is where the seaweeedFS PVC is patched to apply the configured size -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
