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

Swap NetworkPolicy storage to networking.k8s.io/v1 #51955

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cluster/update-storage-objects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ declare -a resources=(
"rolebindings.rbac.authorization.k8s.io"
"clusterroles.rbac.authorization.k8s.io"
"clusterrolebindings.rbac.authorization.k8s.io"
"networkpolicies.networking.k8s.io"
)

# Find all the namespaces.
Expand Down
5 changes: 3 additions & 2 deletions cmd/kube-apiserver/app/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,11 +562,12 @@ func BuildStorageFactory(s *options.ServerRunOptions) (*serverstorage.DefaultSto
return nil, fmt.Errorf("error in initializing storage factory: %s", err)
}

// keep Deployments, NetworkPolicies, Daemonsets and ReplicaSets in extensions for backwards compatibility, we'll have to migrate at some point, eventually
storageFactory.AddCohabitatingResources(networking.Resource("networkpolicies"), extensions.Resource("networkpolicies"))
Copy link
Member

Choose a reason for hiding this comment

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

Do we want a comment to remove this during v1.9 devel?

Copy link
Member

Choose a reason for hiding this comment

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

Along with the extensions type completely?

Copy link
Member

@liggitt liggitt Sep 7, 2017

Choose a reason for hiding this comment

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

we shouldn't remove this until the extensions type is removed and the requirement to migrate is release-noted and available. should networkpolicies be added to update-storage-objects.sh?

Copy link
Contributor

Choose a reason for hiding this comment

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

I am nearly surprised that this change does not change the etcd prefix as well. But reading through

func (s *DefaultStorageFactory) ResourcePrefix(groupResource schema.GroupResource) string {
this makes sense.

Choose a reason for hiding this comment

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

@danwinship extensions and network ordering should be swapped here to look as follows

storageFactory.AddCohabitatingResources(extensions.Resource("networkpolicies"), networking.Resource("networkpolicies"))

We should also add a comment as mentioned by @thockin . DEPRECATED in 1.9, removed in 1.10 or something similar.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

extensions-first-then-networking is the way the code already is in 1.8. So this would make the PR a no-op (except for the changes to the tests).

Copy link
Member

Choose a reason for hiding this comment

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

@cmluciano this PR is switching to write to etcd in networking.k8s.io version, which is what we want

Choose a reason for hiding this comment

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

Ah, misread the comment


// keep Deployments, Daemonsets and ReplicaSets in extensions for backwards compatibility, we'll have to migrate at some point, eventually
storageFactory.AddCohabitatingResources(extensions.Resource("deployments"), apps.Resource("deployments"))
storageFactory.AddCohabitatingResources(extensions.Resource("daemonsets"), apps.Resource("daemonsets"))
storageFactory.AddCohabitatingResources(extensions.Resource("replicasets"), apps.Resource("replicasets"))
storageFactory.AddCohabitatingResources(extensions.Resource("networkpolicies"), networking.Resource("networkpolicies"))
for _, override := range s.Etcd.EtcdServersOverrides {
tokens := strings.Split(override, "#")
if len(tokens) != 2 {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/etcd/etcd_storage_path_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ var etcdStorageData = map[schema.GroupVersionResource]struct {
gvr("extensions", "v1beta1", "networkpolicies"): {
stub: `{"metadata": {"name": "np1"}, "spec": {"podSelector": {"matchLabels": {"e": "f"}}}}`,
expectedEtcdPath: "/registry/networkpolicies/etcdstoragepathtestnamespace/np1",
expectedGVK: gvkP("networking.k8s.io", "v1", "NetworkPolicy"),
},
gvr("extensions", "v1beta1", "deployments"): {
stub: `{"metadata": {"name": "deployment1"}, "spec": {"selector": {"matchLabels": {"f": "z"}}, "template": {"metadata": {"labels": {"f": "z"}}, "spec": {"containers": [{"image": "fedora:latest", "name": "container6"}]}}}}`,
Expand All @@ -278,7 +279,6 @@ var etcdStorageData = map[schema.GroupVersionResource]struct {
gvr("networking.k8s.io", "v1", "networkpolicies"): {
stub: `{"metadata": {"name": "np2"}, "spec": {"podSelector": {"matchLabels": {"e": "f"}}}}`,
expectedEtcdPath: "/registry/networkpolicies/etcdstoragepathtestnamespace/np2",
expectedGVK: gvkP("extensions", "v1beta1", "NetworkPolicy"),
},
// --

Expand Down