K-EXPLORER: delete clusterrole when dashboard shell pod is deleted

refer to #cnrancher/pandaria/issues/2179
This commit is contained in:
niusmallnan 2022-08-09 09:11:45 +08:00
parent 591cb7816f
commit d493afc3db
2 changed files with 3 additions and 2 deletions

View File

@ -28,7 +28,7 @@ var (
)
const (
shellPodImage = "rancher/shell:v0.1.6"
shellPodImage = "rancher/shell:v0.1.18-rc8"
shellPodNS = "kube-system"
)

View File

@ -42,7 +42,8 @@ func (s *shell) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
defer func() {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()
_ = client.CoreV1().Pods(pod.Namespace).Delete(ctx, pod.Name, metav1.DeleteOptions{})
client.CoreV1().Pods(pod.Namespace).Delete(ctx, pod.Name, metav1.DeleteOptions{})
s.impersonator.DeleteRole(ctx, *pod)
}()
s.proxyRequest(rw, req, pod, client)
}