-
Notifications
You must be signed in to change notification settings - Fork 344
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
Migrate Ingress from API extensions/v1beta1 to networking.k8s.io/v1beta1 #1039
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1039 +/- ##
==========================================
+ Coverage 64.23% 64.69% +0.45%
==========================================
Files 83 86 +3
Lines 6627 7013 +386
==========================================
+ Hits 4257 4537 +280
- Misses 2229 2313 +84
- Partials 141 163 +22
Continue to review full report at Codecov.
|
437b3ca
to
62157d9
Compare
pkg/ingress/query.go
Outdated
@@ -3,7 +3,7 @@ package ingress | |||
import ( | |||
"fmt" | |||
|
|||
extv1beta1 "k8s.io/api/extensions/v1beta1" | |||
extv1beta1 "k8s.io/api/networking/v1beta1" |
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.
nit: extv1beta1
-> netv1beta1
?
pkg/ingress/query.go
Outdated
@@ -49,7 +49,7 @@ func (i *QueryIngress) Get() *extv1beta1.Ingress { | |||
return &extv1beta1.Ingress{ | |||
TypeMeta: metav1.TypeMeta{ | |||
Kind: "Ingress", | |||
APIVersion: "extensions/v1beta1", | |||
APIVersion: "networking/v1beta1", |
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.
I think this should be networking.k8s.io/v1beta1
, as shown in https://kubernetes.io/docs/concepts/services-networking/ingress/#the-ingress-resource.
62157d9
to
86e4b5d
Compare
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
86e4b5d
to
ad6a743
Compare
7935411
to
14fd011
Compare
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
14fd011
to
f5bc0eb
Compare
Q: should be |
About the role, I'm still not sure if we need to remove or may be have two versions, for your question about disabling the ingress, yes, the idea is to detect the platform and use the properly API. I added some code that does that, I still need to update the ingress code (and may be the tests). |
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Not sure if this is a good solution for use both APIs I'm using the new Ingress type for all ingress code, but changed to old API just at the time of consuming it. (on create, delete, update etc..) |
@rubenvp8510 sounds like a reasonable approach to me. |
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
I added tests to this. Not sure what should we do with roles, We can create the roles now because both APIs are present in the actual k8s versions, but once k8s removes the Should we leave it as it is for now? or create two |
@rubenvp8510 I think, as this is for supporting older versions of k8s, then having a separate |
If the old API groups are noop in the new cluster versions (which I think they are) we can keep it in the single file. It's easier to maintain and easier to deploy for users. |
According to this post, k8s 1.22 will stop serving the deprecated API (ingress) - so we still have a bit of time until that happens. So it should be fine to include both in the same file for now as @pavolloffay suggests. However we would need to check if it is a noop, once 1.22 is out. Or do a test by trying to include a non-existent api. |
Definitely, will be easier to maintain, an is the option I would prefer, the only remain question is if it will work on 1.22. |
@rubenvp8510 Agree, but we have plenty of time before 1.22 is available, so for now we can have the two versions included. |
Yes, just may be we would want to file a ticket to don't forget this? Also I'm not very confident about tests I did here., those might could start failing when the old API won't be available (or does nothing (noop)). So Do you have any suggestions? |
+1 on a ticket to remove it in 1.22 We can have an e2e test that checks that the API is available. |
@kevinearls Could you give this PR a test? |
pkg/ingress/ingress.go
Outdated
if viper.Get("ingress-api") == ExtensionAPI { | ||
extIngressList := c.fromNetToExt(*obj) | ||
err := c.client.Update(ctx, &extIngressList, opts...) | ||
if err != nil { |
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.
Not necessary, could just return c.client.Update...
pkg/ingress/ingress.go
Outdated
if viper.Get("ingress-api") == ExtensionAPI { | ||
extIngressList := c.fromNetToExt(*obj) | ||
err := c.client.Delete(ctx, &extIngressList, opts...) | ||
if err != nil { |
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.
Same comment as above.
pkg/ingress/ingress.go
Outdated
if viper.Get("ingress-api") == ExtensionAPI { | ||
extIngressList := c.fromNetToExt(*obj) | ||
err := c.client.Create(ctx, &extIngressList, opts...) | ||
if err != nil { |
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.
Same as above.
pkg/ingress/ingress_test.go
Outdated
assert.NoError(t, err) | ||
assert.Equal(t, 1, len(extIngressList.Items)) | ||
|
||
// Should return 0 (not using extension API) |
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.
Should this say "not using networking API"?
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.
LGTM, Just minor comments. It would be good to test this though in a real cluster.
pkg/autodetect/main.go
Outdated
@@ -6,6 +6,8 @@ import ( | |||
"sync" | |||
"time" | |||
|
|||
"github.com/jaegertracing/jaeger-operator/pkg/ingress" |
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.
it should go to group import 3
pkg/ingress/ingress.go
Outdated
|
||
// List is a wrap function that calls k8s client List with extend or networking API. | ||
func (c *Client) List(ctx context.Context, list *netv1beta.IngressList, opts ...client.ListOption) error { | ||
if viper.Get("ingress-api") == ExtensionAPI { |
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 could be at client init time. I guess nobody will enable extensions API dynamically
}, | ||
ObjectMeta: ingress.ObjectMeta, | ||
Spec: netv1beta.IngressSpec{ | ||
Backend: &netv1beta.IngressBackend{ |
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.
Whet if backend is not defined? In the fromNetToExt
ingress.Spec.Backend
is checked to see if nil.
@rubenvp8510 @objectiser Tests have passed on an OCP 4.4 cluster |
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
@rubenvp8510 I ran into one small problem when running on OCP. I get the following log messages every 5 seconds time="2020-05-14T15:29:25Z" level=info msg="Auto-detected ingress api" ingress-api=networking |
@kevinearls I think this is due this logs: I can remove those log lines or change the detection to another place. |
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
pkg/ingress/ingress.go
Outdated
func NewIngressClient(client client.Client, reader client.Reader) *Client { | ||
usedAPI := NetworkingAPI | ||
if viper.Get("ingress-api") != nil { | ||
usedAPI = viper.Get("ingress-api").(string) |
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.
there is viper.GetString()
so the type assertion is not needed
@kevinearls @pavolloffay @objectiser I changed the detection place and address the comments. Thanks |
92eaa82
to
50999d0
Compare
Signed-off-by: Ruben Vargas <ruben.vp8510@gmail.com>
Signed-off-by: Ruben Vargas ruben.vp8510@gmail.com