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

Ensure that build/charts/antrea/templates/antctl/clusterrole.yaml is up-to-date and stays up-to-date #5136

Closed
antoninbas opened this issue Jun 16, 2023 · 1 comment · Fixed by #5166
Assignees
Labels
area/component/antctl Issues or PRs releated to the command line interface component priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete.

Comments

@antoninbas
Copy link
Contributor

antoninbas commented Jun 16, 2023

I haven't updated build/charts/antrea/templates/antctl/clusterrole.yaml as it is already very out-of-date. For example it seems to me that getClusterInfo used for supportbundle really needs a lot of permissions that are currently missing:

func getClusterInfo(w io.Writer, k8sClient kubernetes.Interface) error {

I am not sure what we should do there (should we remove build/charts/antrea/templates/antctl/clusterrole.yaml altogether?).

I think we should either add a e2e test to actually validate each command can be executed correctly with an account bound to the clusterrole, or we should remove the clusterrole. But the latter means user can only use admin account to operate antctl, which may be a not good practice. I incline to the former.

Originally posted by @tnqn in #5135 (comment)

@antoninbas antoninbas added area/component/antctl Issues or PRs releated to the command line interface component priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. labels Jun 16, 2023
@antoninbas
Copy link
Contributor Author

antoninbas commented Jun 20, 2023

Some permissions are also incorrect. The Antrea monitoring CRDs don't have the correct name:

- controllerinfos
- agentinfos

It should be antreacontrollerinfos and antreaagentinfos.

(the API group is also wrong...)

@antoninbas antoninbas self-assigned this Jun 20, 2023
@antoninbas antoninbas added this to the Antrea v1.13 release milestone Jun 20, 2023
antoninbas added a commit to antoninbas/antrea that referenced this issue Jun 21, 2023
The ClusterRole definition was no longer up-to-date, with some incorrect
permissions and some missing permissions. As a consequence, it could not
be used to run some antctl commands, such as supportbundle.

We fix the permissions and modify the Antctl e2e tests so that they use
a Kubeconfig file generated for the antctl ServiceAccount, instead of
the admin Kubeconfig file. Hopefully, this will help keep the
ClusterRole definition up-to-date in the future.

A few other improvements were implemented in that process:

* antctl now uses the typed SystemBundle K8s clientset, instead of a raw
  REST client. This helps define the correct RBAC permissions for
  antctl. Previous permissions were indeed incorrect as they used the
  "post" verb (instead of the "create" verb), which is only correct for
  non-resource endpoints.
* supportbundle unit tests now use an in-memory filesystem, to avoid
  writing test outputs to the local machine.
* the antctl ClusterRole is giving access to a few extra endpoints
  ("/metrics", "/debug/pprof/*") to increse the usefulness of the antctl
  proxy command.

Fixes antrea-io#5136

Signed-off-by: Antonin Bas <[email protected]>
antoninbas added a commit to antoninbas/antrea that referenced this issue Jun 21, 2023
The ClusterRole definition was no longer up-to-date, with some incorrect
permissions and some missing permissions. As a consequence, it could not
be used to run some antctl commands, such as supportbundle.

We fix the permissions and modify the Antctl e2e tests so that they use
a Kubeconfig file generated for the antctl ServiceAccount, instead of
the admin Kubeconfig file. Hopefully, this will help keep the
ClusterRole definition up-to-date in the future.

A few other improvements were implemented in that process:

* antctl now uses the typed SystemBundle K8s clientset, instead of a raw
  REST client. This helps define the correct RBAC permissions for
  antctl. Previous permissions were indeed incorrect as they used the
  "post" verb (instead of the "create" verb), which is only correct for
  non-resource endpoints.
* supportbundle unit tests now use an in-memory filesystem, to avoid
  writing test outputs to the local machine.
* the antctl ClusterRole is giving access to a few extra endpoints
  ("/metrics", "/debug/pprof/*") to increse the usefulness of the antctl
  proxy command.

Fixes antrea-io#5136

Signed-off-by: Antonin Bas <[email protected]>
antoninbas added a commit to antoninbas/antrea that referenced this issue Jun 30, 2023
The ClusterRole definition was no longer up-to-date, with some incorrect
permissions and some missing permissions. As a consequence, it could not
be used to run some antctl commands, such as supportbundle.

We fix the permissions and modify the Antctl e2e tests so that they use
a Kubeconfig file generated for the antctl ServiceAccount, instead of
the admin Kubeconfig file. Hopefully, this will help keep the
ClusterRole definition up-to-date in the future.

A few other improvements were implemented in that process:

* antctl now uses the typed SystemBundle K8s clientset, instead of a raw
  REST client. This helps define the correct RBAC permissions for
  antctl. Previous permissions were indeed incorrect as they used the
  "post" verb (instead of the "create" verb), which is only correct for
  non-resource endpoints.
* supportbundle unit tests now use an in-memory filesystem, to avoid
  writing test outputs to the local machine.
* the antctl ClusterRole is giving access to a few extra endpoints
  ("/metrics", "/debug/pprof/*") to increse the usefulness of the antctl
  proxy command.

Fixes antrea-io#5136

Signed-off-by: Antonin Bas <[email protected]>
antoninbas added a commit to antoninbas/antrea that referenced this issue Jul 3, 2023
The ClusterRole definition was no longer up-to-date, with some incorrect
permissions and some missing permissions. As a consequence, it could not
be used to run some antctl commands, such as supportbundle.

We fix the permissions and modify the Antctl e2e tests so that they use
a Kubeconfig file generated for the antctl ServiceAccount, instead of
the admin Kubeconfig file. Hopefully, this will help keep the
ClusterRole definition up-to-date in the future.

A few other improvements were implemented in that process:

* antctl now uses the typed SystemBundle K8s clientset, instead of a raw
  REST client. This helps define the correct RBAC permissions for
  antctl. Previous permissions were indeed incorrect as they used the
  "post" verb (instead of the "create" verb), which is only correct for
  non-resource endpoints.
* supportbundle unit tests now use an in-memory filesystem, to avoid
  writing test outputs to the local machine.
* the antctl ClusterRole is giving access to a few extra endpoints
  ("/metrics", "/debug/pprof/*") to increse the usefulness of the antctl
  proxy command.

Fixes antrea-io#5136

Signed-off-by: Antonin Bas <[email protected]>
antoninbas added a commit that referenced this issue Jul 5, 2023
* Fix RBAC permissions for the Antctl ClusterRole

The ClusterRole definition was no longer up-to-date, with some incorrect
permissions and some missing permissions. As a consequence, it could not
be used to run some antctl commands, such as supportbundle.

We fix the permissions and modify the Antctl e2e tests so that they use
a Kubeconfig file generated for the antctl ServiceAccount, instead of
the admin Kubeconfig file. Hopefully, this will help keep the
ClusterRole definition up-to-date in the future.

A few other improvements were implemented in that process:

* antctl now uses the typed SystemBundle K8s clientset, instead of a raw
  REST client. This helps define the correct RBAC permissions for
  antctl. Previous permissions were indeed incorrect as they used the
  "post" verb (instead of the "create" verb), which is only correct for
  non-resource endpoints.
* supportbundle unit tests now use an in-memory filesystem, to avoid
  writing test outputs to the local machine.
* the antctl ClusterRole is giving access to a few extra endpoints
  ("/metrics", "/debug/pprof/*") to increse the usefulness of the antctl
  proxy command.

Fixes #5136

* Antctl test e2e improvements

* Don't use ~ (home dir) in antctl e2e tests with Kind

'~' is not expanded with docker exec

Signed-off-by: Antonin Bas <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/component/antctl Issues or PRs releated to the command line interface component priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant