-
Notifications
You must be signed in to change notification settings - Fork 339
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
Remove namespace from core Entity #458
Conversation
1e299c9
to
70753fd
Compare
75c43c5
to
7c908c5
Compare
7c908c5
to
afc9cde
Compare
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.
Let's also document migration path
pkg/plugins/resources/k8s/native/api/v1alpha1/mesh_types_test.go
Outdated
Show resolved
Hide resolved
}, | ||
}, | ||
}), | ||
Entry("TrafficRoutes should be ordered by namespace to consistently pick between two equally specific routes", testCase{ |
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.
Let's bring this test back.
It's very interesting to see how ordering will work on k8s
now.
I'm afraid that it doesn't make any sense from a user perspective. That is not ok and should be taken into account.
Maybe, it's more practical to choose namespace.name
convention (or namespace:name
like Marco once suggested)
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.
Namespace now is in name and we've already got test for ordering the name. Ordering will work with name first and then namespace if it's present in the name.
Is this that important anyways? I think the only situation it will matter to user is when there are equal number of tags. We will soon change the ordering to take into account the modification date.
pkg/util/k8s/name_converter.go
Outdated
) | ||
|
||
func CoreNameToK8sName(coreName string) (string, string, error) { | ||
parts := strings.Split(coreName, ".") |
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.
Let's use strings.LastIndex()
instead. I think, it will make the intention more clear
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 don't think I understand how to apply the LastIndex()
here. Can you provide what you have in mind?
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.
idx := strings.LastIndex(coreName, ".")
if idx == -1 {
return "", "", errors.New(`name must include namespace after the dot, ex. "name.namespace"`)
}
if idx == len(coreName) - 1 {
return "", "", errors.New("namespace must be non-empty")
}
return coreName[:idx], coreName[idx + 1:], nil
}, | ||
}, | ||
}), | ||
Entry("ProxyTemplates in different Namespaces", testCase{ |
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.
Let's bring this test back.
It's very interesting to see how ordering will work on k8s
now.
I'm afraid that it doesn't make any sense from a user perspective. That is not ok and should be taken into account.
Maybe, it's more practical to choose namespace.name
convention (or namespace:name
like Marco once suggested)
pkg/util/k8s/name_converter.go
Outdated
) | ||
|
||
func CoreNameToK8sName(coreName string) (string, string, error) { | ||
parts := strings.Split(coreName, ".") |
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.
idx := strings.LastIndex(coreName, ".")
if idx == -1 {
return "", "", errors.New(`name must include namespace after the dot, ex. "name.namespace"`)
}
if idx == len(coreName) - 1 {
return "", "", errors.New("namespace must be non-empty")
}
return coreName[:idx], coreName[idx + 1:], nil
Summary
The idea is that our core model should not know anything about K8S namespace. To achieve that, we embed namespace into name. For example our name from core entity:
sample.demo
indicates that on k8s the name issample
and namespace isdemo
.Postgres
In postgres we've got separate column for namespace. For now I left the column. We should solve the problem of migrations (especially since we plan to add new column which is creation/modify date).
Mesh
Mesh is now a Cluster scoped object on K8S. Meaning it does not belong to any namespace.
Changes from user perspective
kumactl output will look like following