-
Notifications
You must be signed in to change notification settings - Fork 40k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46879 from luxas/kubeadm_enable_node_authorizer
Automatic merge from submit-queue kubeadm: Enable the Node Authorizer/Admission plugin in v1.7 **What this PR does / why we need it**: This is similar to #46796, but for kubeadm. Basically it was a part of #46796, but there were some other upgradability and compability concerns for kubeadm I took care of while working today. Example: ```console $ kubeadm init --kubernetes-version v1.7.0-beta.0 [kubeadm] WARNING: kubeadm is in beta, please do not use it for production clusters. [init] Using Kubernetes version: v1.7.0-beta.0 [init] Using Authorization mode: [RBAC Node] ... $ sudo kubectl --kubeconfig=/etc/kubernetes/kubelet.conf get secret foo Error from server (Forbidden): User "system:node:thegopher" cannot get secrets in the namespace "default".: "no path found to object" (get secrets foo) $ echo '{"apiVersion":"v1","kind":"Node","metadata":{"name":"foo"}}' | sudo kubectl create -f - --kubeconfig=/etc/kubernetes/kubelet.conf Error from server (Forbidden): error when creating "STDIN": nodes "foo" is forbidden: node thegopher cannot modify node foo ``` **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: Depends on #46864 (uses that PR as a base, will rebase once it's merged) Please only review the second commit. Will also fix tests in a minute. **Release note**: ```release-note kubeadm: Enable the Node Authorizer/Admission plugin in v1.7 ``` @mikedanese @liggitt @pipejakob @roberthbailey @jbeda @timothysc
- Loading branch information
Showing
12 changed files
with
176 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
Copyright 2017 The Kubernetes Authors. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package cmd | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
|
||
"k8s.io/kubernetes/pkg/util/version" | ||
) | ||
|
||
func TestDefaultAuthorizationModes(t *testing.T) { | ||
var tests = []struct { | ||
authzModes []string | ||
version string | ||
expected []string | ||
}{ | ||
{[]string{"RBAC"}, "v1.6.0", []string{"RBAC"}}, | ||
{[]string{"RBAC", "ABAC"}, "v1.6.4", []string{"RBAC", "ABAC"}}, | ||
{[]string{"RBAC", "ABAC"}, "v1.7.0-beta.0", []string{"RBAC", "ABAC"}}, | ||
{[]string{"RBAC"}, "v1.7.0", []string{"Node", "RBAC"}}, | ||
{[]string{"RBAC", "Webhook"}, "v1.7.0-beta.1", []string{"Node", "RBAC", "Webhook"}}, | ||
{[]string{"RBAC", "Webhook", "Node"}, "v1.7.0", []string{"RBAC", "Webhook", "Node"}}, | ||
{[]string{"Node", "RBAC", "Webhook"}, "v1.7.0", []string{"Node", "RBAC", "Webhook"}}, | ||
} | ||
for _, rt := range tests { | ||
k8sVersion, err := version.ParseSemantic(rt.version) | ||
if err != nil { | ||
t.Fatalf("couldn't parse given version") | ||
} | ||
actual := defaultAuthorizationModes(rt.authzModes, k8sVersion) | ||
if strings.Join(actual, ",") != strings.Join(rt.expected, ",") { | ||
t.Errorf( | ||
"failed TestDefaultAuthorizationModes:\n\texpected: %s\n\t actual: %s", | ||
strings.Join(rt.expected, ","), | ||
strings.Join(actual, ","), | ||
) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.