Skip to content

Conversation

stuggi
Copy link
Contributor

@stuggi stuggi commented Jul 4, 2023

Adds an OverridSpec to the Route which allows to customize metadata.Annotations, metadata.Labels and spec of a route. The override values get merged into the object definition created by the operator. This allows e.g. to add custom labels, configure the route via annotations as in [1], or set TLS parameters.

[1] https://docs.openshift.com/container-platform/4.13/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

Jira: OSP-21715
Jira: OSP-26299

@stuggi
Copy link
Contributor Author

stuggi commented Jul 4, 2023

need to add more tests

@stuggi
Copy link
Contributor Author

stuggi commented Jul 4, 2023

example on service operator usage in openstack-k8s-operators/keystone-operator#269

Copy link
Contributor

@bshephar bshephar left a comment

Choose a reason for hiding this comment

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

I like the approach, it makes the interface within lib-common much more flexible. It does however put some of the complexity burden back on to the user. As they need to understand how to set these options in their yaml files. But, ultimately the added extensibility and maintainability of this is nice.

I'm not sure if we need to literally copy the entire RouteSpec though. Could we maybe import and just set Spec to RouteSpec?

Spec *Spec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
}

// EmbeddedLabelsAnnotations is an embedded subset of the fields included in k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta.
Copy link
Contributor

Choose a reason for hiding this comment

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

Without reading this comment, it wasn't immediately obvious to me what the "Embedded" nature of this field would be. Would it possibly make more sense to call it MetadataLabelsAnnotations to better represent the fact that it's a v1.ObjectMeta subset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, could rename it

@stuggi
Copy link
Contributor Author

stuggi commented Jul 5, 2023

I like the approach, it makes the interface within lib-common much more flexible. It does however put some of the complexity burden back on to the user. As they need to understand how to set these options in their yaml files. But, ultimately the added extensibility and maintainability of this is nice.

I'm not sure if we need to literally copy the entire RouteSpec though. Could we maybe import and just set Spec to RouteSpec?

to be able to override a subset of the spec, we have to make sure that all parameters in the override spec are optional and not required as in the original spec definition. thats why we can not just use it.

@bshephar
Copy link
Contributor

bshephar commented Jul 5, 2023

I like the approach, it makes the interface within lib-common much more flexible. It does however put some of the complexity burden back on to the user. As they need to understand how to set these options in their yaml files. But, ultimately the added extensibility and maintainability of this is nice.
I'm not sure if we need to literally copy the entire RouteSpec though. Could we maybe import and just set Spec to RouteSpec?

to be able to override a subset of the spec, we have to make sure that all parameters in the override spec are optional and not required as in the original spec definition. thats why we can not just use it.

Right yeah, sorry I see Gibi mentioned the same thing and you responded to his comment. Thanks for the clarification.

@stuggi stuggi force-pushed the route_override branch 3 times, most recently from 44c2e9d to 7450e90 Compare July 11, 2023 14:06
@stuggi stuggi requested review from abays and dprince July 12, 2023 14:54
@stuggi stuggi force-pushed the route_override branch 4 times, most recently from 595e29d to 928f97b Compare July 13, 2023 09:13
Copy link
Contributor

@gibizer gibizer 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 to me. Extra thanks for the documentation and the test coverage.

@stuggi
Copy link
Contributor Author

stuggi commented Jul 13, 2023

/hold

// kind is allowed. Use 'weight' field to emphasize one over others.
// Copy of RouteTargetReference in https://github.com/openshift/api/blob/master/route/v1/types.go,
// parameters set to be optional, have omitempty, and no default.
type TargetReference struct {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also had to create a copy of RouteTargetReference setting omitempty and removing defaults. Otherwise the defaulting would have overwritten values set by the operator

Copy link
Contributor

@abays abays left a comment

Choose a reason for hiding this comment

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

/lgtm

stuggi added a commit to stuggi/keystone-operator that referenced this pull request Jul 14, 2023
Allows to customize the service route vie the `spec.Override.Route`.
This allows e.g. to add custom labels, configure the route via
annotations as in [1], or set TLS parameters.

~~~
apiVersion: keystone.openstack.org/v1beta1
kind: KeystoneAPI
metadata:
  name: keystone
  namespace: openstack
spec:
  ...
  override:
    routeOverride:
      metadata:
        annotations:
          haproxy.router.openshift.io/timeout: "60"
        labels:
          mylabel: boo
~~~

[1] https://docs.openshift.com/container-platform/4.13/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

Depends-On: openstack-k8s-operators/lib-common#293

Jira: OSP-21715
Jira: OSP-26299
@stuggi
Copy link
Contributor Author

stuggi commented Jul 14, 2023

/hold not landing before dev-preview

stuggi added a commit to stuggi/lib-common that referenced this pull request Jul 14, 2023
Allows register https endpoints when certificate is provided via
the endpoint override.

Depends-On: openstack-k8s-operators#293

Jira: OSP-26299
stuggi added a commit to stuggi/placement-operator that referenced this pull request Jul 14, 2023
Allows to customize the service route vie the `spec.Override.Route`.
This allows e.g. to add custom labels, configure the route via
annotations as in [1], or set TLS parameters.

~~~
apiVersion: keystone.openstack.org/v1beta1
kind: KeystoneAPI
metadata:
  name: keystone
  namespace: openstack
spec:
  ...
  override:
    routeOverride:
      metadata:
        annotations:
          haproxy.router.openshift.io/timeout: "60"
        labels:
          mylabel: boo
~~~

[1] https://docs.openshift.com/container-platform/4.13/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

Depends-On: openstack-k8s-operators/lib-common#293

Jira: OSP-21715
Jira: OSP-26299
stuggi added a commit to stuggi/placement-operator that referenced this pull request Jul 14, 2023
Allows to customize the service route vie the `spec.Override.Route`.
This allows e.g. to add custom labels, configure the route via
annotations as in [1], or set TLS parameters.

~~~
apiVersion: keystone.openstack.org/v1beta1
kind: KeystoneAPI
metadata:
  name: keystone
  namespace: openstack
spec:
  ...
  override:
    routeOverride:
      metadata:
        annotations:
          haproxy.router.openshift.io/timeout: "60"
        labels:
          mylabel: boo
~~~

[1] https://docs.openshift.com/container-platform/4.13/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

Depends-On: openstack-k8s-operators/lib-common#293

Jira: OSP-21715
Jira: OSP-26299
stuggi added a commit to stuggi/lib-common that referenced this pull request Jul 14, 2023
Allows register https endpoints when certificate is provided via
the endpoint override.

Depends-On: openstack-k8s-operators#293

Jira: OSP-26299
stuggi added a commit to stuggi/lib-common that referenced this pull request Jul 14, 2023
Allows register https endpoints when certificate is provided via
the endpoint override.

Depends-On: openstack-k8s-operators#293

Jira: OSP-26299
stuggi added a commit to stuggi/placement-operator that referenced this pull request Jul 14, 2023
Allows to customize the service route vie the `spec.Override.Route`.
This allows e.g. to add custom labels, configure the route via
annotations as in [1], or set TLS parameters.

~~~
apiVersion: keystone.openstack.org/v1beta1
kind: KeystoneAPI
metadata:
  name: keystone
  namespace: openstack
spec:
  ...
  override:
    routeOverride:
      metadata:
        annotations:
          haproxy.router.openshift.io/timeout: "60"
        labels:
          mylabel: boo
~~~

[1] https://docs.openshift.com/container-platform/4.13/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

Depends-On: openstack-k8s-operators/lib-common#293

Jira: OSP-21715
Jira: OSP-26299
stuggi added a commit to stuggi/placement-operator that referenced this pull request Jul 17, 2023
Allows to customize the service route vie the `spec.Override.Route`.
This allows e.g. to add custom labels, configure the route via
annotations as in [1], or set TLS parameters.

~~~
apiVersion: keystone.openstack.org/v1beta1
kind: KeystoneAPI
metadata:
  name: keystone
  namespace: openstack
spec:
  ...
  override:
    routeOverride:
      metadata:
        annotations:
          haproxy.router.openshift.io/timeout: "60"
        labels:
          mylabel: boo
~~~

[1] https://docs.openshift.com/container-platform/4.13/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

Depends-On: openstack-k8s-operators/lib-common#293

Jira: OSP-21715
Jira: OSP-26299
stuggi added a commit to stuggi/placement-operator that referenced this pull request Jul 17, 2023
Allows to customize the service route vie the `spec.Override.Route`.
This allows e.g. to add custom labels, configure the route via
annotations as in [1], or set TLS parameters.

~~~
apiVersion: keystone.openstack.org/v1beta1
kind: KeystoneAPI
metadata:
  name: keystone
  namespace: openstack
spec:
  ...
  override:
    routeOverride:
      metadata:
        annotations:
          haproxy.router.openshift.io/timeout: "60"
        labels:
          mylabel: boo
~~~

[1] https://docs.openshift.com/container-platform/4.13/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

Depends-On: openstack-k8s-operators/lib-common#293

Jira: OSP-21715
Jira: OSP-26299
stuggi added a commit to stuggi/placement-operator that referenced this pull request Jul 17, 2023
Allows to customize the service route vie the `spec.Override.Route`.
This allows e.g. to add custom labels, configure the route via
annotations as in [1], or set TLS parameters.

~~~
apiVersion: keystone.openstack.org/v1beta1
kind: KeystoneAPI
metadata:
  name: keystone
  namespace: openstack
spec:
  ...
  override:
    routeOverride:
      metadata:
        annotations:
          haproxy.router.openshift.io/timeout: "60"
        labels:
          mylabel: boo
~~~

[1] https://docs.openshift.com/container-platform/4.13/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

Depends-On: openstack-k8s-operators/lib-common#293

Jira: OSP-21715
Jira: OSP-26299
stuggi added a commit to stuggi/keystone-operator that referenced this pull request Jul 20, 2023
Allows to customize the service route vie the `spec.Override.Route`.
This allows e.g. to add custom labels, configure the route via
annotations as in [1], or set TLS parameters.

~~~
apiVersion: keystone.openstack.org/v1beta1
kind: KeystoneAPI
metadata:
  name: keystone
  namespace: openstack
spec:
  ...
  override:
    routeOverride:
      metadata:
        annotations:
          haproxy.router.openshift.io/timeout: "60"
        labels:
          mylabel: boo
~~~

[1] https://docs.openshift.com/container-platform/4.13/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

Depends-On: openstack-k8s-operators/lib-common#293

Jira: OSP-21715
Jira: OSP-26299
stuggi added a commit to stuggi/placement-operator that referenced this pull request Jul 20, 2023
Allows to customize the service route vie the `spec.Override.Route`.
This allows e.g. to add custom labels, configure the route via
annotations as in [1], or set TLS parameters.

~~~
apiVersion: keystone.openstack.org/v1beta1
kind: KeystoneAPI
metadata:
  name: keystone
  namespace: openstack
spec:
  ...
  override:
    routeOverride:
      metadata:
        annotations:
          haproxy.router.openshift.io/timeout: "60"
        labels:
          mylabel: boo
~~~

[1] https://docs.openshift.com/container-platform/4.13/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

Depends-On: openstack-k8s-operators/lib-common#293

Jira: OSP-21715
Jira: OSP-26299
@stuggi
Copy link
Contributor Author

stuggi commented Jul 26, 2023

rebased

@stuggi
Copy link
Contributor Author

stuggi commented Jul 26, 2023

/hold

Adds an OverridSpec to the Route which allows to customize
metadata.Annotations, metadata.Labels and spec of a route. The
override values get merged into the object definition created by
the operator. This allows e.g. to add custom labels, configure
the route via annotations as in [1], or set TLS parameters.

[1] https://docs.openshift.com/container-platform/4.13/networking/routes/route-configuration.html#nw-route-specific-annotations_route-configuration

Jira: OSP-21715
Jira: OSP-26299
@stuggi
Copy link
Contributor Author

stuggi commented Jul 26, 2023

/unhold

@stuggi
Copy link
Contributor Author

stuggi commented Jul 26, 2023

@gibizer @abays @bshephar are we good to merge this now that lib-common is tagged for 0.1.0?

@gibizer
Copy link
Contributor

gibizer commented Jul 27, 2023

@gibizer @abays @bshephar are we good to merge this now that lib-common is tagged for 0.1.0?

I'm OK to land this now. My comments were answered and we tagged lib-common. This PR does not create a backward incompatible changes for our service operators so if we need to fix something else in lib-common for the dev preview we can do that on main still after this PR.

Copy link
Contributor

@abays abays left a comment

Choose a reason for hiding this comment

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

/lgtm

@abays abays merged commit 36c6d81 into openstack-k8s-operators:main Jul 28, 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