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

Support deploying multiple ingresses #98

Closed
wants to merge 4 commits into from
Closed

Conversation

gregjones
Copy link
Contributor

@gregjones gregjones commented May 27, 2020

This adds support for deploying multiple ingresses with FIAAS, by
separating the ingresses specified in the config by their distinct
requirements for annotations. This is useful as it means for ingress
controllers that use annotations for configuration - this can be
determining which controller is used (public/private network,
or configuration that affects behaviour (whitelisting, HTTP-auth)
per host/path.

This closes #89

@gregjones
Copy link
Contributor Author

This will need fiaas/k8s#76

def _delete_unused(self, labels):
filter_labels = {
"app": Equality(labels["app"]),
"fiaas/deployment_id": Inequality(labels["fiaas/deployment_id"])
Copy link
Contributor

@xavileon xavileon May 27, 2020

Choose a reason for hiding this comment

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

I think this need another filter: "fiaas/deployment_id": Exists()

Otherwise, it will match all ingresses from the app that does not have a fiaas/deployment_id (e.g. custom ingresses for that app created off-band). This feature should make these extra ingresses not necessary, but still seems like better fall on the safe side?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, true. But passing a map with duplicate keys isn't possible :/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe like this? Not sure if it's the tidiest API: fiaas/k8s#80

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that solution is good. I thought about a map where the values may be lists, but I think the list of tuples better represents what the k8s API is.

@gregjones gregjones force-pushed the ingresseseseses branch 2 times, most recently from 8ed4bf1 to 4498364 Compare June 11, 2020 13:52
This adds support for deploying multiple ingresses with FIAAS, by
separating the ingresses specified in the config by their distinct
requirements for annotations. This is useful as it means for ingress
controllers that use annotations for configuration - this can be
determining which controller is used (public/private network,
or configuration that affects behaviour (whitelisting, HTTP-auth)
per host/path.
@gregjones gregjones marked this pull request as ready for review June 11, 2020 14:04
@gregjones gregjones requested a review from a team as a code owner June 11, 2020 14:04
unannotated_ingress = AnnotatedIngress(name=app_spec.name, ingress_items=[], annotations={})
ingresses_by_annotations = [unannotated_ingress]
for ingress_item in app_spec.ingresses:
LOG.info(ingress_item)
Copy link
Contributor

Choose a reason for hiding this comment

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

It was your intention to only log the item here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, no. Left over from debugging: removed in 98bd437

xavileon
xavileon previously approved these changes Jun 12, 2020
Copy link
Contributor

@xavileon xavileon left a comment

Choose a reason for hiding this comment

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

Maybe link to the initial issue as there were some design notes that may be interesting to keep?

Other than that, kudos for making the change backwards compatible and easy to understand. I really thought at the beginning this would be a major change, but it's not.

🏆

adriengentil
adriengentil previously approved these changes Jun 12, 2020
Copy link
Contributor

@adriengentil adriengentil left a comment

Choose a reason for hiding this comment

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

🥇

Add documentation for new feature
@gregjones gregjones dismissed stale reviews from adriengentil and xavileon via 2f0b0e8 June 17, 2020 08:49
@gregjones
Copy link
Contributor Author

I added some docs too for this, PTAL

Copy link
Member

@oyvindio oyvindio left a comment

Choose a reason for hiding this comment

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

I think this looks good! I've added a few comments inline, but it is mostly nitpicking.

custom_labels = merge_dicts(app_spec.labels.ingress, labels)

# Group app_spec.ingresses to separate those with annotations
AnnotatedIngress = namedtuple("AnnotatedIngress", ["name", "ingress_items", "annotations"])
Copy link
Member

Choose a reason for hiding this comment

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

Maybe extracting the grouping logic to a separate function would make this section read a little better?

# Group app_spec.ingresses to separate those with annotations
AnnotatedIngress = namedtuple("AnnotatedIngress", ["name", "ingress_items", "annotations"])
unannotated_ingress = AnnotatedIngress(name=app_spec.name, ingress_items=[], annotations={})
ingresses_by_annotations = [unannotated_ingress]
Copy link
Member

Choose a reason for hiding this comment

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

nit :The naming here confused me a bit; maybe something like all_ingresses or just ingresses would read better?

- path: /foo
annotations:
some/annotation: bar
```
Copy link
Member

Choose a reason for hiding this comment

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

The design document has some nice examples of how this feature works; do you think it makes sense to add some more of these examples here too?

@gregjones gregjones closed this Jun 29, 2020
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.

Support for multiple Ingresses
5 participants