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

CSS-4442 Adds nginx relation to the juju-jimm-k8s charm. #950

Merged

Conversation

alesstimec
Copy link
Collaborator

Description

K8s charm now has two separate relations:

  • traefik_ingress, which can be used to relate to traefik
  • ingress, which can be used to relate to nginx-ingress-integrator

Engineering checklist

Check only items that apply

  • Documentation updated
  • Covered by unit tests
  • Covered by integration tests

Test instructions

Notes for code reviewers

@alesstimec alesstimec force-pushed the juju-jimm-k8s-nginx-relation branch from d9b6a99 to c9144bf Compare June 6, 2023 12:54
If Vault is not present, we cannot create a JWKS service and JIMM would panic starting
the JWKS rotator.
@alesstimec alesstimec changed the title Adds nginx relation to the juju-jimm-k8s charm. CSS-4442 Adds nginx relation to the juju-jimm-k8s charm. Jun 6, 2023
@alesstimec alesstimec force-pushed the juju-jimm-k8s-nginx-relation branch from c9144bf to 7180912 Compare June 6, 2023 14:13
Copy link
Contributor

@kian99 kian99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm but can we change the line length to 120? It looks like a lot of mechanical changes have been made because we're adhering to something like line-length=99

@@ -55,6 +55,7 @@ commands =
[testenv:unit]
description = Run unit tests
deps =
ipdb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally remove this or comment it out, with a explanation as to why it's there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's for debugging python

@@ -27,6 +27,7 @@
DatabaseEvent,
DatabaseRequires,
)
from charms.nginx_ingress_integrator.v0.ingress import IngressRequires
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be the bearer of more changes, but it's recommended with the nginx_ingress_charm to use the new nginx-route rather than the ingress relation. Though to be honest, this is just meant to be a band-aid fix till we can use traefik so I think it's fine as is.

except RelationNotReadyError:
event.defer()
self.nginx_ingress.update_config({
"service-hostname": self.config.get("dns-name", ""),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's confusing that here we get the dns-name from config and then two lines below we get it from the function. A comment explaining the difference would be helpful. I assume it is because the nginx ingress would always be the external DNS but JIMM can accept a local cluster DNS?

@@ -60,3 +60,6 @@ options:
private-key:
type: string
description: The private part of JIMM's macaroon bakery keypair.
dns-name:
type: string
description: Public DNS hostname that JIMM is being served from.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't necessarily have to be public right? Just any old DNS that resolves to JIMM?

OPENFGA_STORE_ID = "openfga-store-id"
OPENFGA_TOKEN = "openfga-token"
OPENFGA_ADDRESS = "openfga-address"
OPENFGA_PORT = "openfga-port"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, we didn't need these

Returns:
A boolean representing whether the relation is ready to be used or not.
"""
return bool(self._get_relation())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New line

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

touché

class JimmOperatorCharm(CharmBase):
"""JIMM Operator Charm."""

def __init__(self, *args):
super().__init__(*args)

self._state = State(self.app, lambda: self.model.get_relation("jimm"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, it's clever, so all we need to do is interact with _state now and not care about the peer data explicitly. Much cleaner

Copy link
Contributor

@ale8k ale8k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but like Kian said a lot of line length changes and formatting made it a little difficult to review

@alesstimec alesstimec force-pushed the juju-jimm-k8s-nginx-relation branch from 7d0ff8f to e2814d3 Compare June 7, 2023 11:29
Copy link
Contributor

@kian99 kian99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Thanks for the line change!

)

# Nginx ingress relation
require_nginx_route(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing that still confuses me about this new relation is how will the service_hostname change if you change your config value. But perhaps it doesn't.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently the nginx route docs do not describe how this is done.. so i expect config value for the dns-name will just have to be provided at deploy time

K8s charm now has two separate relations:
- traefik_ingress, which can be used to relate to traefik
- ingress, which can be used to relate to nginx-ingress-integrator
@alesstimec alesstimec force-pushed the juju-jimm-k8s-nginx-relation branch from 228193b to 61a3558 Compare June 7, 2023 13:16
@alesstimec alesstimec merged commit d2e8a43 into canonical:feature-rebac Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants