[istio] Add interactive istioctl debug via d8 network istio - #454
[istio] Add interactive istioctl debug via d8 network istio#454skurbatov wants to merge 5 commits into
Conversation
Signed-off-by: Sergey Kurbatov <sergey.kurbatov@flant.com>
Signed-off-by: Sergey Kurbatov <sergey.kurbatov@flant.com>
Glitchy-Sheep
left a comment
There was a problem hiding this comment.
Reviewed the new d8 network istio command. 6 inline comments below: the first four are confirmed by mechanism (signal handling vs cleanup, one-shot mode, KUBECONFIG list, concurrent sessions), the last two depend on the cluster setup (RBAC scope for istioctl, image pull / PSS) and are worth checking on a real DKP cluster.
Signed-off-by: Sergey Kurbatov <sergey.kurbatov@flant.com>
Signed-off-by: Sergey Kurbatov <sergey.kurbatov@flant.com>
Glitchy-Sheep
left a comment
There was a problem hiding this comment.
Re-checked the second iteration against the branch head (70679bc): the signal/context handling, the one-shot mode removal, the $KUBECONFIG list handling, the per-run pod naming with terminal-only cleanup, and the d8-istio read-only RBAC all look good. The remaining two points (minimal RBAC set, no imagePullSecrets) are accepted as-is, consistent with how d8 kubectl debug uses the same image. Build, vet and tests pass locally, CI is green. LGTM.
Summary
d8 network istiostarts an interactive istioctl debug session: it applies the namespaced RBAC, pulls the platform debug image, and attaches to a one-shot pod — the same workflow operators previously ran by hand withd8 k.Problem
podsget/list,pods/portforwardcreate), thend8 k run --rm -itwith--overridesfor the SAd8-system/debug-containeron every run--rmcleanup were easy to get wrong; none of this lived underd8 networkFix
d8 network istionext tocni-migrationd8-system/debug-container(data.image) unless--imageis setistioctl-debugin--namespace, and Role/RoleBindingistioctl-debugin--target-namespace(defaults to--namespace)istioctl-debug(restartPolicy: Never, stdin/TTY, default commandbash), waits until Running, attaches, deletes the pod on exit; RBAC is left in place for reuseErrImagePull/ImagePullBackOff/CrashLoopBackOffBefore / After
Before: apply three RBAC manifests,
IMG="$(d8 k -n d8-system get cm debug-container -o jsonpath='{.data.image}')", thend8 k run istioctl-debug --rm -it --overrides=... -- bash.After:
d8 network istio -n <debug-namespace> --target-namespace <target-namespace>— same SA/Role/RoleBinding and the same debug pod, without the manual kubectl steps.Tests
TestEnsureRBACCreatesObjects— SA in the debug namespace, Role rules and RoleBinding subject/ref in the target namespaceTestEnsureRBACIsIdempotentAndUpdatesRules— second apply restores Role rules if they were clearedTestResolveDebugImage—--imageoverride, ConfigMap lookup, missing CM / emptyimagekeyTestBuildDebugPod— SA, automount token, Never restart, stdin/TTYTestCreateDebugPodReplacesLeftover— leftover pod is replacedTestWaitForPodRunning/TestWaitForPodRunningImagePullError— Running vs terminal wait reasonTestNewCommandFlags—namespace,target-namespace,image,kubeconfig,contextNotes
Interactive attach is not covered by the fake clientset tests; end-to-end attach against a live cluster was not run in this environment.