Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit 9fde938

Browse files
committed
Support cluster-admin propagation and update docs
Rather than continuing to play whack-a-mole with the list of verbs HNC can propagate, this change allows it to perform all verbs on all resources. This is equivalent to `cluster-admin` so I've updated the docs accordingly (see also issue #1311). I also noticed that the docs referred to K8s v1.15, which is no longer supported, so I updated them to v1.16. Finally, this change adds the `HNC_FOCUS` makefile var, allowing you to say something like: ``` HNC_FOCUS=772 make test ``` which only runs the e2e tests with "772" in the title. Tested: All quickstart e2e tests pass. Updated the test for issue #772 and verified that it failed without the other changes in this commit, and passed with them.
1 parent aef17d3 commit 9fde938

File tree

6 files changed

+29
-30
lines changed

6 files changed

+29
-30
lines changed

incubator/hnc/Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,19 @@ kind-deploy:
257257
# Note the `-timeout 0` that's passed to the `go test` command - by default, a
258258
# Go test suite has a 10m timeout, and the flag disables that timeout (as of
259259
# July 2020, these tests take ~15m and that number is expected to grow).
260+
#
261+
# To focus on specific tests, use the HNC_FOCUS var as follows:
262+
#
263+
# HNC_FOCUS=772 make test-e2e # only runs the test for issue 772
264+
# HNC_FOCUS=Quickstart make test-e2e # Runs all tests in the "Quickstart" Describe block
260265
.PHONY: test-e2e
261266
test-e2e: exclude-system-namespaces
262267
go clean -testcache
268+
ifndef HNC_FOCUS
263269
go test -v -timeout 0 ./test/e2e/...
270+
else
271+
go test -v -timeout 0 ./test/e2e/... -args --ginkgo.focus ${HNC_FOCUS}
272+
endif
264273

265274
# This batch test will run e2e tests N times on the current cluster the user
266275
# deployed (either kind or a kubernetes cluster), e.g. "make test-e2e-batch N=10"

incubator/hnc/config/rbac/role.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,7 @@ rules:
1111
resources:
1212
- '*'
1313
verbs:
14-
- create
15-
- delete
16-
- deletecollection
17-
- get
18-
- impersonate
19-
- list
20-
- patch
21-
- update
22-
- watch
14+
- '*'
2315
- apiGroups:
2416
- ""
2517
resources:

incubator/hnc/docs/user-guide/faq.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,22 @@ we're not constantly on Slack.
1616

1717
## What are HNC's minimum requirements?
1818

19-
HNC technically requires Kubernetes 1.15 or higher, although we don't test on
19+
HNC technically requires Kubernetes 1.16 or higher, although we don't test on
2020
every version of Kubernetes. See the release notes for the version you're
2121
downloading for a full list of the K8s distributions on which that release has
2222
been tested.
2323

24-
By default, HNC's service account is given the equivalent of the [admin cluster
25-
role](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles),
26-
and therefore is able to propagate RoleBindings to that role, since (under the
27-
normal rules of RBAC) an account is not allowed to grant rolebindings to
28-
permission it does not have. For example, HNC is not able to propagate
29-
`cluster-admin` rolebindings.
30-
31-
You may modify HNC's own role bindings in the `hnc-system` namespace to grant it
32-
addition (or fewer) permissions if you wish. At a minimum, HNC must be able to
33-
access (create, read, list, watch, update and delete) all of its own CRs as well
34-
as namespaces, roles, and role bindings.
24+
By default, HNC's service account is given the ability to perform any verb on
25+
any resource. HNC does not need these permissions itself, but it does require
26+
them to be able to propagate RoleBindings with arbitrary permissions. This
27+
includes namespace RoleBindings to the [`cluster-admin` cluster
28+
role](https://kubernetes.io/docs/reference/access-authn-authz/rbac/#user-facing-roles).
29+
30+
You may modify HNC's own role bindings in the `hnc-system` namespace to restrict
31+
its permissions if you wish, but then it will be unable to propagate
32+
RoleBindings that include the missing permissions. At a minimum, HNC must be
33+
able to access (create, read, list, watch, update and delete) all of its own CRs
34+
as well as namespaces, roles, and role bindings.
3535

3636
## Is there a limit to how many levels of child namespaces you can have?
3737

incubator/hnc/docs/user-guide/how-to.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,8 @@ EOF
408408

409409
### Install or upgrade HNC on a cluster
410410

411-
We recommend installing HNC onto clusters running Kubernetes v1.15 or later.
412-
Earlier versions of Kubernetes are missing some admission controller features
413-
that leave us unable to validate certain dangerous operations such as deleting
414-
namespaces (see [#680](https://github.com/kubernetes-sigs/multi-tenancy/issues/680)).
411+
HNC requires Kubernetes v1.16 or later, since it relies on APIs (such as CRDs
412+
and webhooks) that were only introduced in v1.16.
415413

416414
There is no need to uninstall HNC before upgrading it unless specified in the
417415
release notes for that version.

incubator/hnc/internal/reconcilers/object.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ type ObjectReconciler struct {
9898
}
9999

100100
// HNC doesn't actually need all these permissions, but we *do* need to have them to be able to
101-
// propagate RoleBindings for them. These match the permissions required by the builtin `admin`
102-
// role, as seen in hack/test-issue-772.sh.
101+
// propagate RoleBindings for them. These match the permissions required by the builtin
102+
// `cluster-admin` role, as seen in issues #772 and #1311.
103103
//
104-
// +kubebuilder:rbac:groups=*,resources=*,verbs=get;list;watch;create;update;patch;delete;deletecollection;impersonate
104+
// +kubebuilder:rbac:groups=*,resources=*,verbs=*
105105

106106
// SyncNamespace can be called manually by the HierarchyConfigReconciler when the hierarchy changes.
107107
// It enqueues all the current objects in the namespace and local copies of the original objects

incubator/hnc/test/e2e/issues_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,13 @@ var _ = Describe("Issues", func() {
227227
RunShouldContain("Could not write from source namespace \""+nsParent+"\"", defTimeout, "kubectl get events -n", nsChild, "--field-selector reason=CannotUpdateObject")
228228
})
229229

230-
It("Should propogate admin rolebindings - issue #772", func() {
230+
It("Should propagate cluster-admin rolebindings - issue #772, #1311", func() {
231231
// set up
232232
CreateNamespace(nsParent)
233233
CreateNamespace(nsChild)
234234
MustRun("kubectl hns set", nsChild, "--parent", nsParent)
235235
// Creating admin rolebinding object
236-
MustRun("kubectl create rolebinding --clusterrole=admin --serviceaccount=default:default -n", nsParent, "foo")
236+
MustRun("kubectl create rolebinding --clusterrole=cluster-admin --serviceaccount=default:default -n", nsParent, "foo")
237237
// Object should exist in the child, and there should be no conditions
238238
MustRun("kubectl get rolebinding foo -n", nsChild, "-oyaml")
239239
})

0 commit comments

Comments
 (0)