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

vdk-server: fix ingress settings #3101

Merged
merged 3 commits into from
Feb 13, 2024
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
8 changes: 7 additions & 1 deletion projects/vdk-plugins/vdk-server/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
description="Versatile Data Kit SDK plugin that facilitates the installation of a local Control Service.",
long_description=pathlib.Path("README.md").read_text(),
long_description_content_type="text/markdown",
install_requires=["vdk-core", "click-spinner", "docker", "kubernetes"],
install_requires=[
"vdk-core",
"click-spinner",
"docker",
"kubernetes",
"vdk-plugin-control-cli",
],
package_dir={"": "src"},
packages=setuptools.find_namespace_packages(where="src"),
include_package_data=True,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2021-2024 VMware, Inc.
# SPDX-License-Identifier: Apache-2.0

ingress:
hosts:
- name: "localhost"
paths:
- path: /data-jobs
serviceName: "{{ .Release.Name }}-svc"
servicePort: 8092
- path: /
serviceName: "{{ .Release.Name }}-ui"
servicePort: 8091
26 changes: 16 additions & 10 deletions projects/vdk-plugins/vdk-server/src/vdk/plugin/server/installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class Installer:
git_server_repository_name = "vdk-git-repo"

def __init__(self):
self.git_server_image = "gogs/gogs:0.12"
self.registry_image = "registry:2"
self.__current_directory = self.__get_current_directory()

def install(self):
Expand Down Expand Up @@ -163,7 +165,7 @@ def __create_docker_registry_container(self):
# Create the Docker registry container
# docker run -d --restart=always -p "127.0.0.1:${docker_registry_port}:5000" --name "${docker_registry_name}" registry:2
docker_client.containers.run(
"registry:2",
self.registry_image,
detach=True,
restart_policy={"Name": "always"},
name=self.docker_registry_container_name,
Expand Down Expand Up @@ -243,7 +245,7 @@ def __create_git_server_container(self):
else:
# docker run --name=vdk-git-server -p 10022:22 -p 10080:3000 -p 10081:80 gogs/gogs:0.12
docker_client.containers.run(
"gogs/gogs:0.12",
self.git_server_image,
detach=True,
name=self.git_server_container_name,
ports={"22/tcp": "10022", "3000/tcp": "10080", "80/tcp": "10081"},
Expand Down Expand Up @@ -612,20 +614,22 @@ def __install_helm_chart(self):
if result.returncode != 0:
stderr_as_str = result.stderr.decode("utf-8")
log.error(f"Stderr output: {stderr_as_str}")
exit(result.returncode)
sys.exit(result.returncode)
result = subprocess.run(["helm", "repo", "update"], capture_output=True)
if result.returncode != 0:
stderr_as_str = result.stderr.decode("utf-8")
log.error(f"Stderr output: {stderr_as_str}")
exit(result.returncode)
sys.exit(result.returncode)
helm_command = self.__helm_install_command(git_server_ip)
log.debug(f"Running helm command: {helm_command}")
result = subprocess.run(
self.__helm_install_command(git_server_ip),
helm_command,
capture_output=True,
)
if result.returncode != 0:
stderr_as_str = result.stderr.decode("utf-8")
log.error(f"Stderr output: {stderr_as_str}")
exit(result.returncode)
sys.exit(result.returncode)
else:
log.info("Control Service installed successfully")
except Exception as ex:
Expand Down Expand Up @@ -680,9 +684,9 @@ def __helm_install_command(self, git_server_ip):
"--set",
"deploymentDockerRegistryType=generic",
"--set",
f"deploymentDockerRepository={self.docker_registry_container_name}:5000",
f"deploymentDockerRepository={self.docker_registry_container_name}:{self.__docker_registry_port}",
"--set",
"proxyRepositoryURL=localhost:5000",
f"proxyRepositoryURL=localhost:{self.__docker_registry_port}",
"--set",
f"deploymentGitUrl={git_server_ip}/{self.git_server_admin_user}/{self.git_server_repository_name}.git",
"--set",
Expand All @@ -705,6 +709,8 @@ def __helm_install_command(self, git_server_ip):
"datajobTemplate.template.spec.successfulJobsHistoryLimit=5",
"--set",
"datajobTemplate.template.spec.failedJobsHistoryLimit=5",
"-f",
self.__current_directory.joinpath("helm-values.yaml"),
]

def __uninstall_helm_chart(self):
Expand Down Expand Up @@ -786,7 +792,7 @@ def __finalize_configuration():
write_default_rest_api_url("http://localhost:8092")
except Exception as ex:
log.error(f"Failed to finalize installation. {str(ex)}")
exit(1)
sys.exit(1)
log.info("Done")

@staticmethod
Expand All @@ -796,7 +802,7 @@ def __cleanup_configuration():
reset_default_rest_api_url()
except Exception as ex:
log.error(f"Failed to clean up. {str(ex)}")
exit(1)
sys.exit(1)
log.info("Done")

@staticmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,25 @@
name="server",
help="Installs (and runs) or uninstalls a local Control Service."
"""
TODO: Add description
This command facilitates the management of the local VDK Control Service Server.
It's designed to simplify the setup process for development and testing environments.
For production deployment of VDK Control Service see
https://github.com/vmware/versatile-data-kit/wiki/Versatile-Data-Kit-Control-Service

Examples:

\b
# Install the VDK Control Service Server. It can then be acess at http://localhost:8092.
# It will set default API url to http://localhost:8092 as well for vdk CLI.
vdk server --install

\b
# Check status (is it installed and running)
vdk server --status

\b Uninstall and remove the VDK Control Service Server.
vdk server --uninstall

""",
)
@click.option(
Expand Down