티스토리 뷰

오픈 렌즈에서는 ssh 키 없이 노드에 접근할 수 있습니다 이는 nsenter 명령어를 이용하여 키 없이 노드에 접근할 수 있습니다.

 

https://github.com/lensapp/lens/blob/5670312c474eb5b6d506a3793863707a7df76775/src/main/node-shell-session.ts#L57-L87

 

GitHub - lensapp/lens: Lens - The way the world runs Kubernetes

Lens - The way the world runs Kubernetes. Contribute to lensapp/lens development by creating an account on GitHub.

github.com

 

소스코드는 이곳에서 확인할 수 있습니다. 해당 pod 는 다음의 코드를 이용하여 생성할 수 있습니다 파드를 생성하고, bash 명령어로 접근하면 노드에 root 계정으로 접근할 수 있습니다.

 

namesapce와 접근하고자 하는 노드의 이름을 nodeName에 입력하고 생성하면 됩니다.

 

apiVersion: v1
kind: Pod
metadata:
name: node-shell
namespace: test-namespace
spec:
volumes:
- name: kube-api-access-l47gj
projected:
sources:
- serviceAccountToken:
expirationSeconds: 3607
path: token
- configMap:
name: kube-root-ca.crt
items:
- key: ca.crt
path: ca.crt
- downwardAPI:
items:
- path: namespace
fieldRef:
apiVersion: v1
fieldPath: metadata.namespace
defaultMode: 420
containers:
- name: shell
image: docker.io/alpine:3.16.0
command:
- nsenter
args:
- '-t'
- '1'
- '-m'
- '-u'
- '-i'
- '-n'
- sleep
- '14000'
resources: {}
volumeMounts:
- name: kube-api-access-l47gj
readOnly: true
mountPath: /var/run/secrets/kubernetes.io/serviceaccount
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
restartPolicy: Never
terminationGracePeriodSeconds: 0
dnsPolicy: ClusterFirst
serviceAccountName: default
nodeName: 접근하고자하는-서버명
hostNetwork: true
hostPID: true
hostIPC: true
securityContext: {}
schedulerName: default-scheduler
tolerations:
- operator: Exists
priorityClassName: system-node-critical
priority: 2000001000
enableServiceLinks: true
preemptionPolicy: PreemptLowerPriority
view raw node-shell.yaml hosted with ❤ by GitHub

 

반응형
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
글 보관함