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

Web: Define fetch kube resource web api endpoint #46741

Merged
merged 2 commits into from
Oct 4, 2024

Conversation

kimlisa
Copy link
Contributor

@kimlisa kimlisa commented Sep 18, 2024

part of #46742

Opens a new web api endpoint where we can fetch kube sub resources such as namespaces, pods, secrets, etc (we are currently only utilizing namespace for now though)

Added all the boilerplate code like adding types etc.

@kimlisa kimlisa added no-changelog Indicates that a PR does not require a changelog entry backport/branch/v16 labels Sep 18, 2024
@@ -869,6 +869,7 @@ func (h *Handler) bindDefaultEndpoints() {
// Kube access handlers.
h.GET("/webapi/sites/:site/kubernetes", h.WithClusterAuth(h.clusterKubesGet))
h.GET("/webapi/sites/:site/pods", h.WithClusterAuth(h.clusterKubePodsGet))
h.GET("/webapi/sites/:site/kubernetes/resources", h.WithClusterAuth(h.clusterKubeResourcesGet))
Copy link
Contributor Author

@kimlisa kimlisa Sep 18, 2024

Choose a reason for hiding this comment

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

i added a generic endpoint to allow requesting any kube sub resources @tigrato

Copy link
Contributor

Choose a reason for hiding this comment

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

You can drop the h.GET("/webapi/sites/:site/pods", h.WithClusterAuth(h.clusterKubePodsGet)) endpoint.
It was never used and will be replaced by h.GET("/webapi/sites/:site/kubernetes/resources", h.WithClusterAuth(h.clusterKubeResourcesGet))

@@ -869,6 +869,7 @@ func (h *Handler) bindDefaultEndpoints() {
// Kube access handlers.
h.GET("/webapi/sites/:site/kubernetes", h.WithClusterAuth(h.clusterKubesGet))
h.GET("/webapi/sites/:site/pods", h.WithClusterAuth(h.clusterKubePodsGet))
h.GET("/webapi/sites/:site/kubernetes/resources", h.WithClusterAuth(h.clusterKubeResourcesGet))
Copy link
Contributor

Choose a reason for hiding this comment

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

You can drop the h.GET("/webapi/sites/:site/pods", h.WithClusterAuth(h.clusterKubePodsGet)) endpoint.
It was never used and will be replaced by h.GET("/webapi/sites/:site/kubernetes/resources", h.WithClusterAuth(h.clusterKubeResourcesGet))

return nil, trace.Wrap(err)
}

resp, err := listKubeResources(r.Context(), clt, r.URL.Query(), site.GetName(), r.URL.Query().Get("kind"))
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a validation on kind?

if kind==""{
return trace.BadParameter..
}

if !slices.Contains(types.KubernetesResources, kind){
return trace.BadParameter(kind is not valid, valid kinds %v, types.KubernetesResources)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, i also added a check for empty kube cluster since that's also required

Copy link
Contributor

@tigrato tigrato left a comment

Choose a reason for hiding this comment

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

From my side, all good.
Thanks @kimlisa

@kimlisa kimlisa force-pushed the lisa/kube-resource-endpoint branch 2 times, most recently from 080672b to c5e423b Compare September 30, 2024 18:52
@public-teleport-github-review-bot public-teleport-github-review-bot bot removed the request for review from kiosion October 3, 2024 12:34
@kimlisa kimlisa added this pull request to the merge queue Oct 4, 2024
Merged via the queue into master with commit a6c3742 Oct 4, 2024
43 checks passed
@kimlisa kimlisa deleted the lisa/kube-resource-endpoint branch October 4, 2024 22:20
@public-teleport-github-review-bot

@kimlisa See the table below for backport results.

Branch Result
branch/v16 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/branch/v16 no-changelog Indicates that a PR does not require a changelog entry size/md ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants