티스토리 뷰
빅데이터/kubernetes
[k8s] k8s 노드에 ssh 키없이 접근 하는 방법(Lens의 node shell 파드 이용하는 방법)
hs_seo 2023. 6. 2. 21:56오픈 렌즈에서는 ssh 키 없이 노드에 접근할 수 있습니다 이는 nsenter 명령어를 이용하여 키 없이 노드에 접근할 수 있습니다.
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에 입력하고 생성하면 됩니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
반응형
'빅데이터 > kubernetes' 카테고리의 다른 글
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 하둡
- Hadoop
- Linux
- 백준
- ubuntu
- error
- 파이썬
- 정올
- 알고리즘
- 하이브
- HIVE
- bash
- SQL
- yarn
- emr
- java
- 오류
- airflow
- AWS
- 다이나믹
- nodejs
- S3
- mysql
- hbase
- HDFS
- SPARK
- Tez
- build
- Python
- oozie
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함