# super.yaml
apiVersion: v1
kind: Pod
metadata:
labels:
run: nsenter-v0l86q
name: nsenter-v0l86q
namespace: default
spec:
nodeSelect: node2
containers:
- command:
- nsenter
- --target
- "1"
- --mount
- --uts
- --ipc
- --net
- --pid
- --
- bash
- -l
image: alpine:latest
imagePullPolicy: IfNotPresent
name: nsenter
securityContext:
privileged: true
stdin: true
stdinOnce: true
tty: true
hostNetwork: true
hostPID: true
restartPolicy: Never
tolerations:
- key: CriticalAddonsOnly
operator: Exists
- effect: NoExecute
operator: Exists
参考地址:
https://developer.aliyun.com/article/1436645
经过实践,确实有效。适合以下场景:
只有k8s 集群部署pod权限,但是想控制或者管理某个node.
操作步骤:
1、kubeclt apply -f super.yaml
2、kubectl exec -it nsenter-v0l86q -n default -- /bin/bash
进入容器内部后,就是进入node2服务器,用户是root.
如果想永久保留权限,则开启ssh(具体操作谷歌搜索),然后再添加root权限的
用户
3、此后就不需要通过k8s就看可以ssh 进入node2服务器