Skip to content

Instantly share code, notes, and snippets.

@dmitry-mightydevops
Created April 29, 2023 17:42
Show Gist options
  • Save dmitry-mightydevops/8478f7d03bdc10b934c19cb005421111 to your computer and use it in GitHub Desktop.
Save dmitry-mightydevops/8478f7d03bdc10b934c19cb005421111 to your computer and use it in GitHub Desktop.
get inside aws eks node
usage:
node_shell ip-10-110-9-37.us-west-2.compute.internal
script:
#!/bin/sh
set -x
node=${1}
nodeName=$(kubectl get node ${node} -o template --template='{{index .metadata.labels "kubernetes.io/hostname"}}')
nodeSelector='"nodeSelector": { "kubernetes.io/hostname": "'${nodeName:?}'" },'
podName=${USER}-nsenter-${node}
kubectl run ${podName:?} --restart=Never -it --rm --image overriden --overrides '
{
"spec": {
"hostPID": true,
"hostNetwork": true,
'"${nodeSelector?}"'
"tolerations": [{
"operator": "Exists"
}],
"containers": [
{
"name": "nsenter",
"image": "alexeiled/nsenter:2.34",
"command": [
"/nsenter", "--all", "--target=1", "--", "su", "-"
],
"stdin": true,
"tty": true,
"securityContext": {
"privileged": true
},
"resources": {
"requests": {
"cpu": "10m"
}
}
}
]
}
}' --attach "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment