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

feat: better registry handling ✨ #712

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"python.testing.pytestArgs": [
"operator"
"client"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
Expand Down
5 changes: 4 additions & 1 deletion client/gefyra/api/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,10 @@ def install(
from gefyra.configuration import ClientConfiguration

config = ClientConfiguration(
kube_config_file=kubeconfig, kube_context=kubecontext, ignore_docker=True
kube_config_file=kubeconfig,
kube_context=kubecontext,
ignore_docker=True,
registry_url=kwargs.get("registry_url", ""),
liquidiert marked this conversation as resolved.
Show resolved Hide resolved
)
if preset:
presetoptions = LB_PRESETS.get(preset) # type: ignore
Expand Down
2 changes: 1 addition & 1 deletion client/gefyra/api/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def update(
"containers": [
{
"name": "gefyra",
"image": f"quay.io/gefyra/operator:{version}",
"image": config.OPERATOR_IMAGE,
}
]
}
Expand Down
4 changes: 3 additions & 1 deletion client/gefyra/api/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,9 @@ def status(connection_name: str = "") -> GefyraStatus:
client = _get_client_status(config)
except urllib3.exceptions.MaxRetryError as e:
raise ClientConfigurationError(
f"Cannot reach cluster on {e.pool.host}:{e.pool.port}"
f"Cannot reach cluster on {e.pool.host}:{e.pool.port}\n"
f"Used kubeconfig: {config.KUBE_CONFIG_FILE} from Gefyra connection {connection_name}\n"
f"Please delete the connection and create a new one. Use: gefyra connection remove {connection_name}"
)

if client.connection:
Expand Down
5 changes: 3 additions & 2 deletions client/gefyra/cli/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ def install(ctx, component, preset, apply, wait, **kwargs):
from alive_progress import alive_bar
from gefyra import api

if not all(kwargs.values()):
kwargs = {}
# filter out empty kwargs
kwargs = {k: v for k, v in kwargs.items() if v}

if wait and not apply:
raise click.BadOptionUsage(
option_name="wait", message="Cannot wait without '--apply'"
Expand Down
7 changes: 4 additions & 3 deletions client/gefyra/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
from gefyra.cli.utils import AliasedGroup


@click.group(
cls=AliasedGroup,
)
@click.group(cls=AliasedGroup)
@click.option(
"--kubeconfig",
help="Path to the kubeconfig file to use instead of loading the default",
Expand All @@ -32,6 +30,7 @@ def cli(ctx: click.Context, kubeconfig, context, debug):
import logging
from gefyra.cli.telemetry import CliTelemetry

# Set up logging based on the debug flag
if debug:
logger = logging.getLogger()
handler = logging.StreamHandler()
Expand All @@ -43,12 +42,14 @@ def cli(ctx: click.Context, kubeconfig, context, debug):
logging.getLogger("gefyra").setLevel(logging.DEBUG)
else:
logging.getLogger("gefyra").setLevel(logging.ERROR)

ctx.ensure_object(dict)

try:
ctx.obj["telemetry"] = CliTelemetry()
except Exception: # pragma: no cover
ctx.obj["telemetry"] = False
ctx.obj["debug"] = debug
ctx.obj["kubeconfig"] = kubeconfig
ctx.obj["context"] = context

Expand Down
2 changes: 1 addition & 1 deletion client/gefyra/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def parser_process(value, state):

def multi_options(options):
map_to_types = dict(
array=str,
array=list,
number=float,
string=str,
)
Expand Down
4 changes: 2 additions & 2 deletions client/gefyra/misc/comps/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def data(params: "GefyraInstallOptions") -> list[dict]:
"containers": [
{
"name": "gefyra",
"image": f"quay.io/gefyra/operator:{params.version}",
"image": f"{params.registry_url}/operator:{params.version}",
"imagePullPolicy": "IfNotPresent",
"ports": [{"containerPort": 9443}],
"env": [
Expand Down Expand Up @@ -88,7 +88,7 @@ def data(params: "GefyraInstallOptions") -> list[dict]:
"containers": [
{
"name": "gefyra",
"image": f"quay.io/gefyra/operator:{params.version}",
"image": f"{params.registry_url}/operator:{params.version}",
"imagePullPolicy": "IfNotPresent",
"ports": [{"containerPort": 9443}],
"env": [
Expand Down
9 changes: 8 additions & 1 deletion client/gefyra/misc/comps/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ def data(params: "GefyraInstallOptions") -> list[dict]:
)
if params.service_annotations:
try:
stowaway_annotations.update(params.service_annotations)
for annotation in params.service_annotations:
try:
# handle cli params as key=value
key, value = annotation[0].split("=")
stowaway_annotations[key] = value
except ValueError:
# handle preset values
stowaway_annotations.update(params.service_annotations)
except IndexError:
raise ValueError(
f"Invalid service-annotations format. Please use the form key=value."
Expand Down
6 changes: 6 additions & 0 deletions client/gefyra/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ class GefyraInstallOptions:
type="array",
),
)
registry_url: str = field(
default_factory=lambda: "quay.io/gefyra",
metadata=dict(
help="The registry URL for the images (default: quay.io/gefyra)",
),
)


@dataclass
Expand Down
Loading