-
Notifications
You must be signed in to change notification settings - Fork 11
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
Expose Minio Console and API via Ingress #42
base: main
Are you sure you want to change the base?
Changes from 3 commits
b1c0342
c80317e
b343d15
770885c
1b59dea
cac7a4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,8 @@ def main(self, event): | |
secret_key = self.model.config["secret-key"] or self._stored.secret_key | ||
self._send_info(interfaces, secret_key) | ||
|
||
self._configure_ingress(interfaces) | ||
|
||
self.model.unit.status = MaintenanceStatus("Setting pod spec") | ||
self.model.pod.set_spec( | ||
{ | ||
|
@@ -169,6 +171,25 @@ def _with_console_address(self, minio_args): | |
console_port = str(self.model.config["console-port"]) | ||
return [*minio_args, "--console-address", ":" + console_port] | ||
|
||
def _configure_ingress(self, interfaces): | ||
if interfaces["ingress"]: | ||
interfaces["ingress"].send_data( | ||
{ | ||
"prefix": "/", | ||
"rewrite": "/", | ||
"service": f"{self.model.app.name}-console", | ||
"port": self.model.config["console-port"], | ||
} | ||
) | ||
interfaces["ingress"].send_data( | ||
{ | ||
"prefix": "/", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure either. I didn't consider it because the ports are different, but it doesnt serve it on the same port I would assume There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the only external facing thing is the |
||
"rewrite": "/", | ||
"service": f"{self.model.app.name}", | ||
"port": self.model.config["port"], | ||
} | ||
) | ||
|
||
|
||
def _gen_pass() -> str: | ||
return "".join(choices(ascii_uppercase + digits, k=30)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -309,3 +309,65 @@ def test_minio_console_port_args(harness): | |
"--console-address", | ||
":9999", | ||
] | ||
|
||
def test_install_with_all_inputs(harness): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test can work as a general "can I successfully invoke pod_spec" test, but I think we are missing something to actually check whether this charm has published what we expect to the relation. For example, like here |
||
harness.set_leader(True) | ||
harness.add_oci_resource( | ||
"oci-image", | ||
{ | ||
"registrypath": "ci-test", | ||
"username": "", | ||
"password": "", | ||
}, | ||
) | ||
harness.update_config( | ||
{ | ||
"secret-key": "test-secret-key", | ||
"access-key": "test-access-key", | ||
"mode": "gateway", | ||
"gateway-storage-service": "azure", | ||
} | ||
) | ||
|
||
# object storage | ||
os_rel_id = harness.add_relation("object-storage", "foobar") | ||
harness.add_relation_unit(os_rel_id, "foobar/0") | ||
harness.update_relation_data( | ||
os_rel_id, | ||
"foobar", | ||
{"_supported_versions": yaml.dump(["v1"])}, | ||
) | ||
|
||
# ingress | ||
ingress_relation_name = "ingress" | ||
relation_version_data = {"_supported_versions": "- v1"} | ||
ingress_rel_id = harness.add_relation( | ||
ingress_relation_name, f"{ingress_relation_name}-subscriber" | ||
) | ||
harness.add_relation_unit(ingress_rel_id, f"{ingress_relation_name}-subscriber/0") | ||
harness.update_relation_data( | ||
ingress_rel_id, f"{ingress_relation_name}-subscriber", relation_version_data | ||
) | ||
|
||
harness.begin_with_initial_hooks() | ||
|
||
pod_spec = harness.get_pod_spec() | ||
yaml.safe_dump(pod_spec) | ||
assert harness.charm.model.unit.status == ActiveStatus() | ||
|
||
charm_name = harness.model.app.name | ||
secrets = pod_spec[0]["kubernetesResources"]["secrets"] | ||
env_config = pod_spec[0]["containers"][0]["envConfig"] | ||
|
||
pod_spec_secrets = pod_spec[0]["kubernetesResources"]["secrets"] | ||
pod_spec_secret_key = pod_spec_secrets[0]["data"]["MINIO_SECRET_KEY"] | ||
pod_spec_access_key = pod_spec_secrets[0]["data"]["MINIO_ACCESS_KEY"] | ||
|
||
assert b64decode(pod_spec_secret_key).decode("utf-8") == "test-secret-key" | ||
assert b64decode(pod_spec_access_key).decode("utf-8") == "test-access-key" | ||
assert pod_spec[0]["containers"][0]["args"] == [ | ||
"gateway", | ||
"azure", | ||
"--console-address", | ||
":9001", | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This'll define the endpoint that we claim on the ingress, as written we've claimed the root (or really,
http://INGRESS_URL/
). It probably makes the most sense that this be configurable via a config option. The config option could accept anything that would be valid in a URL (a good default value could be/minio
).