728x90
SMALL
Kubernetes에서 kubectl 명령어는 다양한 첫 번째 매개변수와 두 번째 매개변수를 지원합니다. 각각에 대해 자세히 설명하겠습니다.
1. 첫 번째 매개변수 (액션)
- kubectl 명령어에서 첫 번째 매개변수는 실행할 액션을 나타냅니다. get과 create 외에도 다음과 같은 액션들이 있습니다
- get
- -o wide 를 붙여 자세히 보기
- create
- -f {filename}, -n {namespace}
- namespace 옵션 설정하지 않을 경우, ‘default’ namespace 에 생성된다
- kubectl create -f nginx.yaml -n my-namespace
- -f {filename}, -n {namespace}
- apply: 파일이나 디렉토리에서 리소스를 적용합니다.
- delete: 하나 이상의 리소스를 삭제합니다.
- describe: 특정 리소스의 세부 정보를 표시합니다.
- 생성 중에 쓸 경우 진행 상태 확인 가능
- edit: 특정 리소스를 편집합니다.
- logs: 파드의 로그를 가져옵니다.
- scale: 배포 또는 복제 컨트롤러의 레플리카 수를 조정합니다.
- exec: 특정 파드에서 명령을 실행합니다.
- port-forward: 특정 파드에 대한 포트 포워딩을 설정합니다.
- rollout: 배포의 롤아웃 상태를 관리합니다.
- set: 설정을 변경합니다 (예: 이미지 업데이트).
- top: 리소스 사용량을 표시합니다 (노드, 파드).
- version: 클라이언트와 서버의 버전을 표시합니다.
- get
2. 두 번째 매개변수 (리소스 타입)
- kubectl 명령어에서 두 번째 매개변수는 리소스 타입을 나타냅니다. namespace와 pods 외에도 다음과 같은 리소스 타입들이 있습니다
- namespaces:
- pods:
- nodes: 클러스터의 노드 목록을 가져옵니다.
- services: 클러스터의 서비스 목록을 가져옵니다.
- deployments: 클러스터의 배포 목록을 가져옵니다.
- 예시
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-deploy
spec:
selector:
matchLabels:
app: webui
replicas: 3
template:
metadata:
labels:
app: webui
spec:
containers:
- image: nginx:1.14
name: web
ports:
- containerPort: 80
- replicasets: 클러스터의 ReplicaSet 목록을 가져옵니다.
- pod 의 개수를 보장
- configmaps: 클러스터의 ConfigMap 목록을 가져옵니다.
- secrets: 클러스터의 비밀(Secrets) 목록을 가져옵니다.
- daemonsets: 클러스터의 DaemonSet 목록을 가져옵니다.
- statefulsets: 클러스터의 StatefulSet 목록을 가져옵니다.
- jobs: 클러스터의 Job 목록을 가져옵니다.
- cronjobs: 클러스터의 CronJob 목록을 가져옵니다.
- ingresses: 클러스터의 Ingress 목록을 가져옵니다.
- persistentvolumes: 클러스터의 PersistentVolume 목록을 가져옵니다.
- persistentvolumeclaims: 클러스터의 PersistentVolumeClaim 목록을 가져옵니다.
- roles: 클러스터의 Role 목록을 가져옵니다.
- rolebindings: 클러스터의 RoleBinding 목록을 가져옵니다.
- clusterroles: 클러스터의 ClusterRole 목록을 가져옵니다.
- clusterrolebindings: 클러스터의 ClusterRoleBinding 목록을 가져옵니다.
첫 번째 매개변수 예시
kubectl apply -f deployment.yaml # 파일에서 리소스를 적용
kubectl delete pod my-pod # 특정 파드를 삭제
kubectl describe node my-node # 특정 노드의 세부 정보 표시
kubectl logs my-pod # 특정 파드의 로그 가져오기
kubectl scale deployment my-deployment --replicas=3 # 배포의 레플리카 수 조정
두 번째 매개변수 예시
kubectl get nodes # 노드 목록 가져오기
kubectl get services # 서비스 목록 가져오기
kubectl get deployments # 배포 목록 가져오기
kubectl get configmaps # ConfigMap 목록 가져오기
kubectl get secrets # 비밀 목록 가져오기
kubectl get daemonsets # DaemonSet 목록 가져오기
kubectl get statefulsets # StatefulSet 목록 가져오기
LIST
'🔹Kubernetes' 카테고리의 다른 글
Kubernetes 설정 파일 제거 (0) | 2025.02.01 |
---|---|
Service 정의 (0) | 2025.01.27 |
Pod 정의 (0) | 2025.01.27 |
[Kubernetes] CentOS 7 Master-Worker 설치 방법 (0) | 2024.07.25 |
[Kubernetes] Controller 소개 (0) | 2024.03.07 |