-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,6 +81,25 @@ func (h *Handler) clusterKubePodsGet(w http.ResponseWriter, r *http.Request, p h | |
}, nil | ||
} | ||
|
||
// clusterKubeResourcesGet returns supported requested kubernetes subresources eg: pods, namespaces, secrets etc. | ||
func (h *Handler) clusterKubeResourcesGet(w http.ResponseWriter, r *http.Request, p httprouter.Params, sctx *SessionContext, site reversetunnelclient.RemoteSite) (interface{}, error) { | ||
clt, err := sctx.NewKubernetesServiceClient(r.Context(), h.cfg.ProxyWebAddr.Addr) | ||
if err != nil { | ||
return nil, trace.Wrap(err) | ||
} | ||
|
||
resp, err := listKubeResources(r.Context(), clt, r.URL.Query(), site.GetName(), r.URL.Query().Get("kind")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we add a validation on kind? if kind==""{ if !slices.Contains(types.KubernetesResources, kind){ There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
if err != nil { | ||
return nil, trace.Wrap(err) | ||
} | ||
|
||
return listResourcesGetResponse{ | ||
Items: ui.MakeKubeResources(resp.Resources, r.URL.Query().Get("kubeCluster")), | ||
StartKey: resp.NextKey, | ||
TotalCount: int(resp.TotalCount), | ||
}, nil | ||
} | ||
|
||
// clusterDatabasesGet returns a list of db servers in a form the UI can present. | ||
func (h *Handler) clusterDatabasesGet(w http.ResponseWriter, r *http.Request, p httprouter.Params, sctx *SessionContext, site reversetunnelclient.RemoteSite) (interface{}, error) { | ||
clt, err := sctx.GetUserClient(r.Context(), site) | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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))