vantage6 5.0.0a36__py3-none-any.whl → 5.0.0a38__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of vantage6 might be problematic. Click here for more details.

Files changed (80) hide show
  1. vantage6/cli/algorithm/generate_algorithm_json.py +0 -1
  2. vantage6/cli/algostore/attach.py +28 -3
  3. vantage6/cli/algostore/list.py +2 -2
  4. vantage6/cli/algostore/new.py +3 -2
  5. vantage6/cli/algostore/start.py +25 -6
  6. vantage6/cli/algostore/stop.py +3 -0
  7. vantage6/cli/algostore/version.py +62 -0
  8. vantage6/cli/auth/attach.py +1 -1
  9. vantage6/cli/auth/list.py +2 -2
  10. vantage6/cli/auth/new.py +3 -2
  11. vantage6/cli/auth/remove.py +58 -0
  12. vantage6/cli/auth/start.py +27 -9
  13. vantage6/cli/auth/stop.py +3 -0
  14. vantage6/cli/cli.py +21 -0
  15. vantage6/cli/common/attach.py +114 -0
  16. vantage6/cli/common/decorator.py +25 -4
  17. vantage6/cli/common/list.py +68 -0
  18. vantage6/cli/common/new.py +27 -7
  19. vantage6/cli/common/remove.py +18 -0
  20. vantage6/cli/common/start.py +48 -40
  21. vantage6/cli/common/stop.py +16 -4
  22. vantage6/cli/common/utils.py +65 -74
  23. vantage6/cli/common/version.py +82 -0
  24. vantage6/cli/config.py +10 -2
  25. vantage6/cli/{configuration_wizard.py → configuration_create.py} +22 -14
  26. vantage6/cli/configuration_manager.py +70 -21
  27. vantage6/cli/context/__init__.py +10 -5
  28. vantage6/cli/context/algorithm_store.py +13 -7
  29. vantage6/cli/context/auth.py +23 -5
  30. vantage6/cli/context/node.py +25 -8
  31. vantage6/cli/context/server.py +18 -6
  32. vantage6/cli/globals.py +1 -0
  33. vantage6/cli/node/attach.py +27 -3
  34. vantage6/cli/node/common/__init__.py +26 -10
  35. vantage6/cli/node/common/task_cleanup.py +153 -0
  36. vantage6/cli/node/list.py +3 -44
  37. vantage6/cli/node/new.py +13 -6
  38. vantage6/cli/node/set_api_key.py +1 -1
  39. vantage6/cli/node/start.py +30 -7
  40. vantage6/cli/node/stop.py +151 -7
  41. vantage6/cli/node/version.py +96 -33
  42. vantage6/cli/sandbox/config/base.py +109 -0
  43. vantage6/cli/sandbox/config/core.py +300 -0
  44. vantage6/cli/sandbox/config/node.py +311 -0
  45. vantage6/cli/sandbox/data/km_dataset.csv +2401 -0
  46. vantage6/cli/sandbox/data/olympic_athletes_2016.csv +2425 -0
  47. vantage6/cli/sandbox/new.py +207 -0
  48. vantage6/cli/sandbox/populate/__init__.py +173 -0
  49. vantage6/cli/sandbox/populate/helpers/connect_store.py +203 -0
  50. vantage6/cli/sandbox/populate/helpers/delete_fixtures.py +67 -0
  51. vantage6/cli/sandbox/populate/helpers/load_fixtures.py +476 -0
  52. vantage6/cli/sandbox/populate/helpers/utils.py +35 -0
  53. vantage6/cli/sandbox/remove.py +155 -0
  54. vantage6/cli/sandbox/start.py +349 -0
  55. vantage6/cli/sandbox/stop.py +106 -0
  56. vantage6/cli/server/attach.py +28 -3
  57. vantage6/cli/server/common/__init__.py +5 -6
  58. vantage6/cli/server/import_.py +137 -119
  59. vantage6/cli/server/list.py +2 -2
  60. vantage6/cli/server/new.py +5 -3
  61. vantage6/cli/server/start.py +21 -4
  62. vantage6/cli/server/stop.py +2 -0
  63. vantage6/cli/server/version.py +31 -18
  64. vantage6/cli/template/algo_store_config.j2 +3 -0
  65. vantage6/cli/template/auth_config.j2 +24 -1
  66. vantage6/cli/template/node_config.j2 +2 -0
  67. vantage6/cli/template/server_config.j2 +10 -7
  68. vantage6/cli/use/context.py +8 -1
  69. vantage6/cli/use/namespace.py +10 -7
  70. vantage6/cli/utils.py +33 -1
  71. vantage6/cli/utils_kubernetes.py +270 -0
  72. {vantage6-5.0.0a36.dist-info → vantage6-5.0.0a38.dist-info}/METADATA +4 -4
  73. vantage6-5.0.0a38.dist-info/RECORD +102 -0
  74. vantage6/cli/rabbitmq/__init__.py +0 -0
  75. vantage6/cli/rabbitmq/definitions.py +0 -26
  76. vantage6/cli/rabbitmq/queue_manager.py +0 -220
  77. vantage6/cli/rabbitmq/rabbitmq.config +0 -8
  78. vantage6-5.0.0a36.dist-info/RECORD +0 -86
  79. {vantage6-5.0.0a36.dist-info → vantage6-5.0.0a38.dist-info}/WHEEL +0 -0
  80. {vantage6-5.0.0a36.dist-info → vantage6-5.0.0a38.dist-info}/entry_points.txt +0 -0
@@ -1,26 +1,19 @@
1
- import os
2
- from threading import Thread
3
-
4
1
  import click
5
- import docker
6
- from sqlalchemy.engine.url import make_url
2
+ import requests
3
+ import yaml
7
4
 
8
- from vantage6.common import info, warning
9
- from vantage6.common.docker.addons import check_docker_running, pull_image
5
+ from vantage6.common import error, info
10
6
  from vantage6.common.globals import (
11
- APPNAME,
12
- DEFAULT_DOCKER_REGISTRY,
13
- DEFAULT_SERVER_IMAGE,
14
7
  InstanceType,
15
8
  )
16
9
 
10
+ from vantage6.client import UserClient
11
+
12
+ from vantage6.cli import __version__
17
13
  from vantage6.cli.common.decorator import click_insert_context
18
- from vantage6.cli.common.utils import print_log_worker
19
14
  from vantage6.cli.context.server import ServerContext
20
- from vantage6.cli.utils import check_config_name_allowed
21
15
 
22
16
 
23
- # TODO this method has a lot of duplicated code from `start`
24
17
  @click.command()
25
18
  @click.argument("file", type=click.Path(exists=True))
26
19
  @click.option(
@@ -29,121 +22,146 @@ from vantage6.cli.utils import check_config_name_allowed
29
22
  default=False,
30
23
  help="Drop all existing data before importing",
31
24
  )
32
- @click.option("-i", "--image", default=None, help="Node Docker image to use")
33
- @click.option(
34
- "--mount-src",
35
- default="",
36
- help="Override vantage6 source code in container with the source code in this path",
37
- )
38
- @click.option(
39
- "--keep/--auto-remove",
40
- default=False,
41
- help="Keep image after finishing. Useful for debugging",
42
- )
43
- @click.option("--wait", default=False, help="Wait for the import to finish")
44
25
  @click_insert_context(type_=InstanceType.SERVER)
45
- def cli_server_import(
46
- ctx: ServerContext,
47
- file: str,
48
- drop_all: bool,
49
- image: str | None,
50
- mount_src: str,
51
- keep: bool,
52
- wait: bool,
53
- ) -> None:
26
+ def cli_server_import(ctx: ServerContext, file: str, drop_all: bool) -> None:
54
27
  """
55
- Import vantage6 resources into a server instance.
28
+ Import vantage6 resources into a server instance from a yaml FILE.
56
29
 
57
- This allows you to create organizations, collaborations, users, tasks, etc
58
- from a yaml file.
30
+ This allows you to create organizations, collaborations, users, tasks, etc. from a
31
+ yaml FILE. This method expects the server configuration file to be located on the
32
+ same machine as this method is invoked from.
59
33
 
60
- The FILE_ argument should be a path to a yaml file containing the vantage6
61
- formatted data to import.
34
+ This import assigns the root role to all users, which contains all permissions. So
35
+ use this with caution.
36
+
37
+ The FILE argument should be a path to a yaml file containing the vantage6 formatted
38
+ data to import.
62
39
  """
63
- # will print an error if not
64
- check_docker_running()
40
+ info("Validating server version: ")
41
+ info(f"{ctx.config['server']['baseUrl']}{ctx.config['server']['apiPath']}/version")
42
+ response = requests.get(
43
+ f"{ctx.config['server']['baseUrl']}{ctx.config['server']['apiPath']}/version"
44
+ )
45
+ if response.status_code != 200:
46
+ error("Unable to get server version")
47
+ return
48
+
49
+ body = response.json()
50
+ if "version" not in body:
51
+ error("Server gave a valid response but did not include the version")
52
+ return
53
+
54
+ # Compare it to this package version
55
+ server_version = body["version"]
56
+ if server_version != __version__:
57
+ error(
58
+ f"You are using CLI version {__version__} but the server is running "
59
+ f"version {server_version}. Please use the same version of the CLI and "
60
+ "server."
61
+ )
62
+ return
63
+
64
+ info("Loading and validating import file")
65
+ with open(file, "r") as f:
66
+ import_data = yaml.safe_load(f)
67
+ # TODO: validate import file
68
+
69
+ client = UserClient(
70
+ server_url=f"{ctx.config['server']['baseUrl']}{ctx.config['server']['apiPath']}",
71
+ auth_url=ctx.config["ui"]["keycloakPublicUrl"],
72
+ auth_realm=ctx.config["ui"]["keycloakRealm"],
73
+ auth_client=ctx.config["ui"]["keycloakClient"],
74
+ log_level="info",
75
+ )
76
+
77
+ info("Authenticate using admin credentials (opens browser for login)")
78
+ client.authenticate()
65
79
 
66
- info("Starting server...")
67
- info("Finding Docker daemon.")
68
- docker_client = docker.from_env()
80
+ # TODO: validate that the user has the correct permissions to import data
69
81
 
70
- # check if name is allowed for docker volume, else exit
71
- check_config_name_allowed(ctx.name)
82
+ if drop_all:
83
+ info("Dropping all existing data")
84
+ _drop_all(client)
72
85
 
73
- # pull latest Docker image
74
- if image is None:
75
- image = ctx.config.get(
76
- "image", f"{DEFAULT_DOCKER_REGISTRY}/{DEFAULT_SERVER_IMAGE}"
86
+ info("Collecting root role and rule")
87
+ root_role_id = client.role.list(name="Root", include_root=True)["data"][0]["id"]
88
+
89
+ info("Importing organizations")
90
+ organizations = []
91
+ for organization in import_data["organizations"]:
92
+ org = client.organization.create(
93
+ name=organization["name"],
94
+ address1=organization["address1"] or "",
95
+ address2=organization["address2"] or "",
96
+ zipcode=organization["zipcode"] or "",
97
+ country=organization["country"] or "",
98
+ domain=organization["domain"] or "",
77
99
  )
78
- info(f"Pulling latest server image '{image}'.")
79
- pull_image(docker_client, image)
80
-
81
- info("Creating mounts")
82
- mounts = [
83
- docker.types.Mount("/mnt/config.yaml", str(ctx.config_file), type="bind"),
84
- docker.types.Mount("/mnt/import.yaml", str(file), type="bind"),
85
- ]
86
-
87
- # FIXME: code duplication with cli_server_start()
88
- # try to mount database
89
- uri = ctx.config["uri"]
90
- url = make_url(uri)
91
- environment_vars = None
92
-
93
- if mount_src:
94
- mount_src = os.path.abspath(mount_src)
95
- mounts.append(docker.types.Mount("/vantage6", mount_src, type="bind"))
96
-
97
- # If host is None, we're dealing with a file-based DB, like SQLite
98
- if url.host is None:
99
- db_path = url.database
100
-
101
- if not os.path.isabs(db_path):
102
- # We're dealing with a relative path here -> make it absolute
103
- db_path = ctx.data_dir / url.database
104
-
105
- # basename = os.path.basename(db_path)
106
- dirname = os.path.dirname(db_path)
107
- os.makedirs(dirname, exist_ok=True)
108
-
109
- # we're mounting the entire folder that contains the database
110
- mounts.append(docker.types.Mount("/mnt/database/", dirname, type="bind"))
111
-
112
- environment_vars = {
113
- # ServerGlobals.DB_URI_ENV_VAR.value: f"sqlite:////mnt/database/{basename}"
114
- }
115
-
116
- else:
117
- warning(
118
- f"Database could not be transferred, make sure {url.host} "
119
- "is reachable from the Docker container"
100
+ organizations.append(org)
101
+
102
+ info(f"Importing users for organization {org['name']}")
103
+ for user in organization.get("users", []):
104
+ client.user.create(
105
+ username=user["username"],
106
+ password=user["password"],
107
+ organization=org["id"],
108
+ roles=[root_role_id],
109
+ )
110
+
111
+ info("Importing collaborations")
112
+ all_nodes = []
113
+ for collaboration in import_data["collaborations"]:
114
+ # Collecting organization ids
115
+ organization_ids = []
116
+ for participant in collaboration["participants"]:
117
+ for org in organizations:
118
+ if org["name"] == participant["name"]:
119
+ organization_ids.append(org["id"])
120
+
121
+ col = client.collaboration.create(
122
+ name=collaboration["name"],
123
+ organizations=organization_ids,
124
+ encrypted=collaboration.get("encrypted", False),
120
125
  )
121
- info("Consider using the docker-compose method to start a server")
122
-
123
- drop_all_ = "--drop-all" if drop_all else ""
124
- cmd = f"vserver-local import -c /mnt/config.yaml {drop_all_} /mnt/import.yaml"
125
-
126
- info(cmd)
127
-
128
- info("Run Docker container")
129
- container = docker_client.containers.run(
130
- image,
131
- command=cmd,
132
- mounts=mounts,
133
- detach=True,
134
- labels={
135
- f"{APPNAME}-type": InstanceType.SERVER.value,
136
- "name": ctx.config_file_name,
137
- },
138
- environment=environment_vars,
139
- auto_remove=not keep,
140
- tty=True,
141
- )
142
- logs = container.logs(stream=True, stdout=True)
143
- Thread(target=print_log_worker, args=(logs,), daemon=False).start()
144
126
 
145
- info(f"Success! container id = {container.id}")
127
+ info("Registering nodes for collaboration")
128
+ for participant in collaboration["participants"]:
129
+ for org in organizations:
130
+ if org["name"] == participant["name"]:
131
+ node = client.node.create(
132
+ name=f"{collaboration['name']}-{org['name'].replace(' ', '-')}-node",
133
+ organization=org["id"],
134
+ collaboration=col["id"],
135
+ )
136
+ all_nodes.append(node)
146
137
 
147
- if wait:
148
- container.wait()
149
- info("Container finished!")
138
+ return all_nodes
139
+
140
+
141
+ def _drop_all(client: UserClient) -> None:
142
+ """
143
+ Drop all existing data from the server.
144
+ """
145
+ while nodes := client.node.list()["data"]:
146
+ for node in nodes:
147
+ info(f"Deleting node {node['name']}")
148
+ client.node.delete(node["id"])
149
+
150
+ while collaborations := client.collaboration.list(scope="global")["data"]:
151
+ for collaboration in collaborations:
152
+ info(f"Deleting collaboration {collaboration['name']}")
153
+ client.collaboration.delete(collaboration["id"], delete_dependents=True)
154
+
155
+ # TODO: For some reason, the `delete_dependents` parameter is not working for users,
156
+ # so we delete them here first.
157
+ while users := [u for u in client.user.list()["data"] if u["username"] != "admin"]:
158
+ for user in users:
159
+ info(f"Deleting user {user['username']}")
160
+ client.user.delete(user["id"])
161
+
162
+ while orgs := [
163
+ o for o in client.organization.list()["data"] if o["name"] != "root"
164
+ ]:
165
+ for org in orgs:
166
+ info(f"Deleting organization {org['name']}")
167
+ client.organization.delete(org["id"], delete_dependents=True)
@@ -2,7 +2,7 @@ import click
2
2
 
3
3
  from vantage6.common.globals import InstanceType
4
4
 
5
- from vantage6.cli.common.utils import get_server_configuration_list
5
+ from vantage6.cli.common.list import get_configuration_list
6
6
 
7
7
 
8
8
  @click.command()
@@ -10,4 +10,4 @@ def cli_server_configuration_list() -> None:
10
10
  """
11
11
  Print the available server configurations.
12
12
  """
13
- get_server_configuration_list(InstanceType.SERVER)
13
+ get_configuration_list(InstanceType.SERVER)
@@ -9,7 +9,7 @@ from vantage6.common.globals import (
9
9
 
10
10
  from vantage6.cli.common.new import new
11
11
  from vantage6.cli.config import CliConfig
12
- from vantage6.cli.configuration_wizard import add_common_server_config
12
+ from vantage6.cli.configuration_create import add_common_server_config
13
13
  from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
14
14
 
15
15
 
@@ -57,7 +57,8 @@ def cli_server_new(
57
57
  # print("awefawef")
58
58
 
59
59
  new(
60
- questionnaire_function=server_configuration_questionaire,
60
+ config_producing_func=server_configuration_questionaire,
61
+ config_producing_func_args=(name,),
61
62
  name=name,
62
63
  system_folders=system_folders,
63
64
  namespace=namespace,
@@ -92,7 +93,8 @@ def server_configuration_questionaire(instance_name: str) -> dict[str, Any]:
92
93
  }
93
94
  config["server"]["dev"] = {
94
95
  "host_uri": "host.docker.internal",
95
- "store_in_local_cluster": True,
96
+ # TODO v5+ adapt to name space and service name etc, check from sandbox
97
+ "store_address": "http://vantage6-store-store.service.default.svc.cluster.local",
96
98
  }
97
99
 
98
100
  # TODO v5+ these should be removed, latest should usually be used so question is
@@ -3,6 +3,7 @@ import click
3
3
  from vantage6.common import info
4
4
  from vantage6.common.globals import InstanceType, Ports
5
5
 
6
+ from vantage6.cli.common.attach import attach_logs
6
7
  from vantage6.cli.common.decorator import click_insert_context
7
8
  from vantage6.cli.common.start import (
8
9
  helm_install,
@@ -10,11 +11,11 @@ from vantage6.cli.common.start import (
10
11
  start_port_forward,
11
12
  )
12
13
  from vantage6.cli.common.utils import (
13
- attach_logs,
14
14
  create_directory_if_not_exists,
15
+ select_context_and_namespace,
15
16
  )
16
17
  from vantage6.cli.context.server import ServerContext
17
- from vantage6.cli.globals import ChartName
18
+ from vantage6.cli.globals import ChartName, InfraComponentName
18
19
 
19
20
 
20
21
  @click.command()
@@ -32,6 +33,7 @@ from vantage6.cli.globals import ChartName
32
33
  default=False,
33
34
  help="Print server logs to the console after start",
34
35
  )
36
+ @click.option("--local-chart-dir", default=None, help="Local chart directory to use")
35
37
  @click_insert_context(
36
38
  type_=InstanceType.SERVER, include_name=True, include_system_folders=True
37
39
  )
@@ -45,13 +47,18 @@ def cli_server_start(
45
47
  port: int,
46
48
  ui_port: int,
47
49
  attach: bool,
50
+ local_chart_dir: str | None,
48
51
  ) -> None:
49
52
  """
50
53
  Start the server.
51
54
  """
52
55
  info("Starting server...")
56
+ prestart_checks(ctx, InstanceType.SERVER, name, system_folders)
53
57
 
54
- prestart_checks(ctx, InstanceType.SERVER, name, system_folders, context, namespace)
58
+ context, namespace = select_context_and_namespace(
59
+ context=context,
60
+ namespace=namespace,
61
+ )
55
62
 
56
63
  create_directory_if_not_exists(ctx.log_dir)
57
64
 
@@ -61,11 +68,13 @@ def cli_server_start(
61
68
  values_file=ctx.config_file,
62
69
  context=context,
63
70
  namespace=namespace,
71
+ local_chart_dir=local_chart_dir,
64
72
  )
65
73
 
66
74
  # port forward for server
67
75
  info("Port forwarding for server")
68
76
  start_port_forward(
77
+ # TODO: make this dynamic
69
78
  service_name=f"{ctx.helm_release_name}-vantage6-server-service",
70
79
  service_port=ctx.config["server"].get("port", Ports.DEV_SERVER.value),
71
80
  port=port or ctx.config["server"].get("port", Ports.DEV_SERVER.value),
@@ -86,4 +95,12 @@ def cli_server_start(
86
95
  )
87
96
 
88
97
  if attach:
89
- attach_logs("app=vantage6-server", "component=vantage6-server")
98
+ attach_logs(
99
+ name,
100
+ instance_type=InstanceType.SERVER,
101
+ infra_component=InfraComponentName.SERVER,
102
+ system_folders=system_folders,
103
+ context=context,
104
+ namespace=namespace,
105
+ is_sandbox=ctx.is_sandbox,
106
+ )
@@ -32,6 +32,7 @@ def cli_server_stop(
32
32
  namespace: str,
33
33
  system_folders: bool,
34
34
  all_servers: bool,
35
+ is_sandbox: bool = False,
35
36
  ):
36
37
  """
37
38
  Stop an running server.
@@ -45,6 +46,7 @@ def cli_server_stop(
45
46
  namespace=namespace,
46
47
  context=context,
47
48
  system_folders=system_folders,
49
+ is_sandbox=is_sandbox,
48
50
  )
49
51
 
50
52
 
@@ -1,12 +1,11 @@
1
1
  import click
2
- import docker
2
+ import requests
3
3
 
4
- from vantage6.common import error
5
- from vantage6.common.docker.addons import check_docker_running
4
+ from vantage6.common import error, info
6
5
  from vantage6.common.globals import InstanceType
7
6
 
8
7
  from vantage6.cli import __version__
9
- from vantage6.cli.common.utils import get_running_servers, get_server_name
8
+ from vantage6.cli.common.version import get_and_select_ctx
10
9
  from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
11
10
 
12
11
 
@@ -16,22 +15,36 @@ from vantage6.cli.globals import DEFAULT_SERVER_SYSTEM_FOLDERS
16
15
  @click.option(
17
16
  "--user", "system_folders", flag_value=False, default=DEFAULT_SERVER_SYSTEM_FOLDERS
18
17
  )
19
- def cli_server_version(name: str, system_folders: bool) -> None:
18
+ @click.option("--context", default=None, help="Kubernetes context to use")
19
+ @click.option("--namespace", default=None, help="Kubernetes namespace to use")
20
+ @click.option(
21
+ "--sandbox", "is_sandbox", flag_value=True, help="Is this a sandbox environment?"
22
+ )
23
+ def cli_server_version(
24
+ name: str, system_folders: bool, context: str, namespace: str, is_sandbox: bool
25
+ ) -> None:
20
26
  """
21
27
  Print the version of the vantage6 server.
22
28
  """
23
- check_docker_running()
24
- client = docker.from_env()
25
-
26
- running_server_names = get_running_servers(client, InstanceType.SERVER)
27
-
28
- name = get_server_name(
29
- name, system_folders, running_server_names, InstanceType.SERVER
29
+ ctx = get_and_select_ctx(
30
+ InstanceType.SERVER, name, system_folders, context, namespace, is_sandbox
30
31
  )
32
+ server_config = ctx.config.get("server", {})
33
+ base_url = server_config.get("baseUrl", "")
34
+ api_path = server_config.get("apiPath", "")
35
+ if not base_url:
36
+ error("No base URL found in server configuration.")
37
+ return
38
+ if not api_path:
39
+ error("No API path found in server configuration.")
40
+ return
41
+
42
+ response = requests.get(f"{base_url}{api_path}/version")
43
+ if response.status_code != 200:
44
+ error("Failed to get server version.")
45
+ return
46
+ server_version = response.json().get("version", "")
31
47
 
32
- if name in running_server_names:
33
- container = client.containers.get(name)
34
- version = container.exec_run(cmd="vserver-local version", stdout=True)
35
- click.echo({"server": version.output.decode("utf-8"), "cli": __version__})
36
- else:
37
- error(f"Server {name} is not running! Cannot provide version...")
48
+ info("")
49
+ info(f"Server version: {server_version}")
50
+ info(f"CLI version: {__version__}")
@@ -102,6 +102,9 @@ store:
102
102
  port: 7602
103
103
  {% endif %}
104
104
 
105
+ # The port to expose the store on in the cluster
106
+ port: {{ store.port | default(7602) }}
107
+
105
108
  logging:
106
109
  # Controls the logging output level. Could be one of the following
107
110
  # levels: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET
@@ -111,8 +111,13 @@ keycloak:
111
111
  # clientSessionMaxLifespan to higher values to effectively lengthen the session.
112
112
  ssoSessionIdleTimeout: {{ keycloak.ssoSessionIdleTimeout | default(1800) }}
113
113
 
114
- # password policy configuration. If you prefer not to have a
114
+ # password policy configuration. If you prefer not to have a password policy,
115
+ # you can set this to an empty string.
116
+ {% if keycloak.production %}
115
117
  passwordPolicy: "length(8) and upperCase(1) and lowerCase(1) and digits(1) and specialChars(1)"
118
+ {% else %}
119
+ passwordPolicy: ""
120
+ {% endif %}
116
121
 
117
122
  # do not allow users to edit their username - this would lead to problems with
118
123
  # syncing the user between keycloak and vantage6 server/store. This setting
@@ -152,16 +157,34 @@ keycloak:
152
157
  # assigned admin permissions on initial startup.
153
158
  - username: {{ keycloak.adminUser | default('admin') }}
154
159
  enabled: true
160
+ {% if not keycloak.production %}
161
+ email: admin@vantage6.org
162
+ firstName: Admin
163
+ lastName: Admin
164
+ {% endif %}
155
165
  credentials:
156
166
  - type: password
167
+ {% if keycloak.production %}
157
168
  value: {{ keycloak.adminPassword | default('Admin123!') }}
169
+ {% else %}
170
+ value: {{ keycloak.adminPassword | default('admin') }}
171
+ {% endif %}
158
172
  requiredActions:
159
173
  {% if keycloak.production %}
174
+ # this requires all users to update their password on first login and
175
+ # configure two-factor authentication
160
176
  - CONFIGURE_TOTP
161
177
  - UPDATE_PASSWORD
178
+ {% elif keycloak.no_password_update_required%}
179
+ # enable configure OTP only if you want to use two-factor authentication
180
+ # - CONFIGURE_TOTP
181
+ # enable password update if you want every user to have to change their
182
+ # password on first login
183
+ # - UPDATE_PASSWORD
162
184
  {% else %}
163
185
  # enable configure OTP only if you want to use two-factor authentication
164
186
  # - CONFIGURE_TOTP
187
+ # this requires all users to update their password on first login
165
188
  - UPDATE_PASSWORD
166
189
  {% endif %}
167
190
  # create a service account user for the backend admin client. The
@@ -79,6 +79,8 @@ node:
79
79
  name: engineio.server
80
80
  - level: warning
81
81
  name: sqlalchemy.engine
82
+ - level: warning
83
+ name: kubernetes.client.rest
82
84
  {% endif %}
83
85
 
84
86
  {% if node.encryption is defined %}
@@ -96,9 +96,9 @@ server:
96
96
  {% if server.dev is defined %}
97
97
  dev:
98
98
  host_uri: {{ server.dev.host_uri | default('host.docker.internal') }}
99
- # This should be set to true if you are running the algorithm store in the same
100
- # cluster and namespace as the server
101
- store_in_local_cluster: {{ server.dev.store_in_local_cluster | default(false) }}
99
+ # store address of the algorithm store. This can be provided to the server for
100
+ # a custom address of the local algorithm store within the k8s cluster.
101
+ store_address: {{ server.dev.store_address | default('http://vantage6-store-store.service.default.svc.cluster.local') }}
102
102
  {% endif %}
103
103
 
104
104
  # If you want to couple algorithm stores to the server on startup, you can add them here.
@@ -109,11 +109,13 @@ server:
109
109
  {% for store in server.algorithm_stores %}
110
110
  - name: {{ store.name }}
111
111
  url: {{ store.url }}
112
+ api_path: {{ store.api_path }}
112
113
  {% endfor %}
113
114
  {% else %}
114
115
  # algorithm_stores:
115
- # - name: local store
116
+ # - name: Local store
116
117
  # url: http://localhost:7602/api
118
+ # api_path: /api
117
119
  {% endif %}
118
120
 
119
121
  # Cleanup settings: This is used to cleanup the database from old results.
@@ -180,6 +182,7 @@ server:
180
182
  # - http://localhost:7600
181
183
  {% endif %}
182
184
 
185
+
183
186
  rabbitmq:
184
187
  # The image of the RabbitMQ server
185
188
  image:
@@ -226,7 +229,7 @@ database:
226
229
  # The name of the database
227
230
  name: {{ database.name | default('vantage6') }}
228
231
 
229
- #hostpath of the database mount
232
+ # hostpath of the database mount
230
233
  volumePath: {{ database.volumePath }}
231
234
 
232
235
  # The name of the k8s node where the database is running
@@ -238,7 +241,7 @@ ui:
238
241
  # The image of the UI
239
242
  image: {{ ui.image | default('harbor2.vantage6.ai/infrastructure/ui:latest') }}
240
243
  # Service port for the UI
241
- port: 7600
244
+ port: {{ ui.port | default(7600) }}
242
245
  # keycloak realm
243
246
  keycloakRealm: {{ ui.keycloakRealm | default('vantage6') }}
244
247
  # keycloak client
@@ -253,4 +256,4 @@ ui:
253
256
  # Community algorithm store URL.
254
257
  communityStoreUrl: {{ ui.communityStoreUrl | default('https://store.cotopaxi.vantage6.ai') }}
255
258
  # Community algorithm store API path
256
- communityStoreApiPath: {{ ui.communityStoreApiPath | default('/api') }}
259
+ communityStoreApiPath: {{ ui.communityStoreApiPath | default('/api') }}
@@ -1,11 +1,12 @@
1
1
  import click
2
2
  import questionary
3
- from kubernetes import config
3
+ from kubernetes import client, config
4
4
 
5
5
  from vantage6.common import error
6
6
 
7
7
  from vantage6.cli.config import CliConfig
8
8
  from vantage6.cli.utils import switch_context_and_namespace
9
+ from vantage6.cli.utils_kubernetes import configure_kubernetes_client_for_microk8s
9
10
 
10
11
 
11
12
  @click.command()
@@ -14,6 +15,12 @@ def cli_use_context(context: str):
14
15
  """
15
16
  Set which Kubernetes context to use.
16
17
  """
18
+ # Configure for MicroK8s if needed
19
+ config.load_kube_config()
20
+ cfg = client.Configuration.get_default_copy()
21
+ configure_kubernetes_client_for_microk8s(cfg)
22
+ client.Configuration.set_default(cfg)
23
+
17
24
  # Get available contexts
18
25
  contexts, active_context = config.list_kube_config_contexts()
19
26
  context_names = [ctx["name"] for ctx in contexts]