|
1 | 1 | ---
|
2 | 2 | title: 명령줄 도구 (kubectl)
|
3 | 3 | content_type: reference
|
4 |
| -weight: 60 |
| 4 | +weight: 110 |
5 | 5 | no_list: true
|
6 | 6 | card:
|
7 | 7 | name: reference
|
@@ -101,7 +101,13 @@ kubectl은 자신이 클러스터 내부에서 실행되고 있다고 가정한
|
101 | 101 | kubectl은 해당 서비스어카운트의 네임스페이스(파드의 네임스페이스와 동일하다)를 인식하고 해당 네임스페이스에 대해 동작한다.
|
102 | 102 | 이는 클러스터 외부에서 실행되었을 때와는 다른데,
|
103 | 103 | kubectl이 클러스터 외부에서 실행되었으며 네임스페이스가 명시되지 않은 경우
|
104 |
| -kubectl은 `default` 네임스페이스에 대해 동작한다. |
| 104 | +kubectl 명령어는 클라이언트 구성에서 현재 컨텍스트(current context)에 |
| 105 | +설정된 네임스페이스에 대해 동작한다. |
| 106 | +kubectl이 동작하는 기본 네임스페이스를 변경하려면 아래의 명령어를 실행한다. |
| 107 | + |
| 108 | +```shell |
| 109 | +kubectl config set-context --current --namespace=<namespace-name> |
| 110 | +``` |
105 | 111 |
|
106 | 112 | ## 명령어
|
107 | 113 |
|
@@ -130,6 +136,7 @@ kubectl은 `default` 네임스페이스에 대해 동작한다.
|
130 | 136 | `diff` | `kubectl diff -f FILENAME [flags]`| 라이브 구성에 대해 파일이나 표준입력의 차이점을 출력한다.
|
131 | 137 | `drain` | `kubectl drain NODE [options]` | 유지 보수를 준비 중인 노드를 드레인한다.
|
132 | 138 | `edit` | <code>kubectl edit (-f FILENAME | TYPE NAME | TYPE/NAME) [flags]</code> | 기본 편집기를 사용하여 서버에서 하나 이상의 리소스 정의를 편집하고 업데이트한다.
|
| 139 | +`events` | `kubectl events` | List events |
133 | 140 | `exec` | `kubectl exec POD [-c CONTAINER] [-i] [-t] [flags] [-- COMMAND [args...]]` | 파드의 컨테이너에 대해 명령을 실행한다.
|
134 | 141 | `explain` | `kubectl explain [--recursive=false] [flags]` | 파드, 노드, 서비스 등의 다양한 리소스에 대한 문서를 출력한다.
|
135 | 142 | `expose` | <code>kubectl expose (-f FILENAME | TYPE NAME | TYPE/NAME) [--port=port] [--protocol=TCP|UDP] [--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type] [flags]</code> | 레플리케이션 컨트롤러, 서비스 또는 파드를 새로운 쿠버네티스 서비스로 노출한다.
|
@@ -159,66 +166,66 @@ kubectl은 `default` 네임스페이스에 대해 동작한다.
|
159 | 166 |
|
160 | 167 | 다음 표에는 지원되는 모든 리소스 타입과 해당 약어가 나열되어 있다.
|
161 | 168 |
|
162 |
| -(이 출력은 `kubectl api-resources` 에서 확인할 수 있으며, 쿠버네티스 1.19.1 에서의 출력을 기준으로 한다.) |
| 169 | +(이 출력은 `kubectl api-resources` 에서 확인할 수 있으며, 쿠버네티스 1.25.0 에서의 출력을 기준으로 한다.) |
163 | 170 |
|
164 |
| -| NAME | SHORTNAMES | APIGROUP | NAMESPACED | KIND | |
| 171 | +| NAME | SHORTNAMES | APIVERSION | NAMESPACED | KIND | |
165 | 172 | |---|---|---|---|---|
|
166 |
| -| `bindings` | | | true | Binding | |
167 |
| -| `componentstatuses` | `cs` | | false | ComponentStatus | |
168 |
| -| `configmaps` | `cm` | | true | ConfigMap | |
169 |
| -| `endpoints` | `ep` | | true | Endpoints | |
170 |
| -| `events` | `ev` | | true | Event | |
171 |
| -| `limitranges` | `limits` | | true | LimitRange | |
172 |
| -| `namespaces` | `ns` | | false | Namespace | |
173 |
| -| `nodes` | `no` | | false | Node | |
174 |
| -| `persistentvolumeclaims` | `pvc` | | true | PersistentVolumeClaim | |
175 |
| -| `persistentvolumes` | `pv` | | false | PersistentVolume | |
176 |
| -| `pods` | `po` | | true | Pod | |
177 |
| -| `podtemplates` | | | true | PodTemplate | |
178 |
| -| `replicationcontrollers` | `rc` | | true | ReplicationController | |
179 |
| -| `resourcequotas` | `quota` | | true | ResourceQuota | |
180 |
| -| `secrets` | | | true | Secret | |
181 |
| -| `serviceaccounts` | `sa` | | true | ServiceAccount | |
182 |
| -| `services` | `svc` | | true | Service | |
183 |
| -| `mutatingwebhookconfigurations` | | admissionregistration.k8s.io | false | MutatingWebhookConfiguration | |
184 |
| -| `validatingwebhookconfigurations` | | admissionregistration.k8s.io | false | ValidatingWebhookConfiguration | |
185 |
| -| `customresourcedefinitions` | `crd,crds` | apiextensions.k8s.io | false | CustomResourceDefinition | |
186 |
| -| `apiservices` | | apiregistration.k8s.io | false | APIService | |
187 |
| -| `controllerrevisions` | | apps | true | ControllerRevision | |
188 |
| -| `daemonsets` | `ds` | apps | true | DaemonSet | |
189 |
| -| `deployments` | `deploy` | apps | true | Deployment | |
190 |
| -| `replicasets` | `rs` | apps | true | ReplicaSet | |
191 |
| -| `statefulsets` | `sts` | apps | true | StatefulSet | |
192 |
| -| `tokenreviews` | | authentication.k8s.io | false | TokenReview | |
193 |
| -| `localsubjectaccessreviews` | | authorization.k8s.io | true | LocalSubjectAccessReview | |
194 |
| -| `selfsubjectaccessreviews` | | authorization.k8s.io | false | SelfSubjectAccessReview | |
195 |
| -| `selfsubjectrulesreviews` | | authorization.k8s.io | false | SelfSubjectRulesReview | |
196 |
| -| `subjectaccessreviews` | | authorization.k8s.io | false | SubjectAccessReview | |
197 |
| -| `horizontalpodautoscalers` | `hpa` | autoscaling | true | HorizontalPodAutoscaler | |
198 |
| -| `cronjobs` | `cj` | batch | true | CronJob | |
199 |
| -| `jobs` | | batch | true | Job | |
200 |
| -| `certificatesigningrequests` | `csr` | certificates.k8s.io | false | CertificateSigningRequest | |
201 |
| -| `leases` | | coordination.k8s.io | true | Lease | |
202 |
| -| `endpointslices` | | discovery.k8s.io | true | EndpointSlice | |
203 |
| -| `events` | `ev` | events.k8s.io | true | Event | |
204 |
| -| `ingresses` | `ing` | extensions | true | Ingress | |
205 |
| -| `flowschemas` | | flowcontrol.apiserver.k8s.io | false | FlowSchema | |
206 |
| -| `prioritylevelconfigurations` | | flowcontrol.apiserver.k8s.io | false | PriorityLevelConfiguration | |
207 |
| -| `ingressclasses` | | networking.k8s.io | false | IngressClass | |
208 |
| -| `ingresses` | `ing` | networking.k8s.io | true | Ingress | |
209 |
| -| `networkpolicies` | `netpol` | networking.k8s.io | true | NetworkPolicy | |
210 |
| -| `runtimeclasses` | | node.k8s.io | false | RuntimeClass | |
211 |
| -| `poddisruptionbudgets` | `pdb` | policy | true | PodDisruptionBudget | |
212 |
| -| `podsecuritypolicies` | `psp` | policy | false | PodSecurityPolicy | |
213 |
| -| `clusterrolebindings` | | rbac.authorization.k8s.io | false | ClusterRoleBinding | |
214 |
| -| `clusterroles` | | rbac.authorization.k8s.io | false | ClusterRole | |
215 |
| -| `rolebindings` | | rbac.authorization.k8s.io | true | RoleBinding | |
216 |
| -| `roles` | | rbac.authorization.k8s.io | true | Role | |
217 |
| -| `priorityclasses` | `pc` | scheduling.k8s.io | false | PriorityClass | |
218 |
| -| `csidrivers` | | storage.k8s.io | false | CSIDriver | |
219 |
| -| `csinodes` | | storage.k8s.io | false | CSINode | |
220 |
| -| `storageclasses` | `sc` | storage.k8s.io | false | StorageClass | |
221 |
| -| `volumeattachments` | | storage.k8s.io | false | VolumeAttachment | |
| 173 | +| `bindings` | | v1 | true | Binding | |
| 174 | +| `componentstatuses` | `cs` | v1 | false | ComponentStatus | |
| 175 | +| `configmaps` | `cm` | v1 | true | ConfigMap | |
| 176 | +| `endpoints` | `ep` | v1 | true | Endpoints | |
| 177 | +| `events` | `ev` | v1 | true | Event | |
| 178 | +| `limitranges` | `limits` | v1 | true | LimitRange | |
| 179 | +| `namespaces` | `ns` | v1 | false | Namespace | |
| 180 | +| `nodes` | `no` | v1 | false | Node | |
| 181 | +| `persistentvolumeclaims` | `pvc` | v1 | true | PersistentVolumeClaim | |
| 182 | +| `persistentvolumes` | `pv` | v1 | false | PersistentVolume | |
| 183 | +| `pods` | `po` | v1 | true | Pod | |
| 184 | +| `podtemplates` | | v1 | true | PodTemplate | |
| 185 | +| `replicationcontrollers` | `rc` | v1 | true | ReplicationController | |
| 186 | +| `resourcequotas` | `quota` | v1 | true | ResourceQuota | |
| 187 | +| `secrets` | | v1 | true | Secret | |
| 188 | +| `serviceaccounts` | `sa` | v1 | true | ServiceAccount | |
| 189 | +| `services` | `svc` | v1 | true | Service | |
| 190 | +| `mutatingwebhookconfigurations` | | admissionregistration.k8s.io/v1 | false | MutatingWebhookConfiguration | |
| 191 | +| `validatingwebhookconfigurations` | | admissionregistration.k8s.io/v1 | false | ValidatingWebhookConfiguration | |
| 192 | +| `customresourcedefinitions` | `crd,crds` | apiextensions.k8s.io/v1 | false | CustomResourceDefinition | |
| 193 | +| `apiservices` | | apiregistration.k8s.io/v1 | false | APIService | |
| 194 | +| `controllerrevisions` | | apps/v1 | true | ControllerRevision | |
| 195 | +| `daemonsets` | `ds` | apps/v1 | true | DaemonSet | |
| 196 | +| `deployments` | `deploy` | apps/v1 | true | Deployment | |
| 197 | +| `replicasets` | `rs` | apps/v1 | true | ReplicaSet | |
| 198 | +| `statefulsets` | `sts` | apps/v1 | true | StatefulSet | |
| 199 | +| `tokenreviews` | | authentication.k8s.io/v1 | false | TokenReview | |
| 200 | +| `localsubjectaccessreviews` | | authorization.k8s.io/v1 | true | LocalSubjectAccessReview | |
| 201 | +| `selfsubjectaccessreviews` | | authorization.k8s.io/v1 | false | SelfSubjectAccessReview | |
| 202 | +| `selfsubjectrulesreviews` | | authorization.k8s.io/v1 | false | SelfSubjectRulesReview | |
| 203 | +| `subjectaccessreviews` | | authorization.k8s.io/v1 | false | SubjectAccessReview | |
| 204 | +| `horizontalpodautoscalers` | `hpa` | autoscaling/v2 | true | HorizontalPodAutoscaler | |
| 205 | +| `cronjobs` | `cj` | batch/v1 | true | CronJob | |
| 206 | +| `jobs` | | batch/v1 | true | Job | |
| 207 | +| `certificatesigningrequests` | `csr` | certificates.k8s.io/v1 | false | CertificateSigningRequest | |
| 208 | +| `leases` | | coordination.k8s.io/v1 | true | Lease | |
| 209 | +| `endpointslices` | | discovery.k8s.io/v1 | true | EndpointSlice | |
| 210 | +| `events` | `ev` | events.k8s.io/v1 | true | Event | |
| 211 | +| `flowschemas` | | flowcontrol.apiserver.k8s.io/v1beta2 | false | FlowSchema | |
| 212 | +| `prioritylevelconfigurations` | | flowcontrol.apiserver.k8s.io/v1beta2 | false | PriorityLevelConfiguration | |
| 213 | +| `ingressclasses` | | networking.k8s.io/v1 | false | IngressClass | |
| 214 | +| `ingresses` | `ing` | networking.k8s.io/v1 | true | Ingress | |
| 215 | +| `networkpolicies` | `netpol` | networking.k8s.io/v1 | true | NetworkPolicy | |
| 216 | +| `runtimeclasses` | | node.k8s.io/v1 | false | RuntimeClass | |
| 217 | +| `poddisruptionbudgets` | `pdb` | policy/v1 | true | PodDisruptionBudget | |
| 218 | +| `podsecuritypolicies` | `psp` | policy/v1beta1 | false | PodSecurityPolicy | |
| 219 | +| `clusterrolebindings` | | rbac.authorization.k8s.io/v1 | false | ClusterRoleBinding | |
| 220 | +| `clusterroles` | | rbac.authorization.k8s.io/v1 | false | ClusterRole | |
| 221 | +| `rolebindings` | | rbac.authorization.k8s.io/v1 | true | RoleBinding | |
| 222 | +| `roles` | | rbac.authorization.k8s.io/v1 | true | Role | |
| 223 | +| `priorityclasses` | `pc` | scheduling.k8s.io/v1 | false | PriorityClass | |
| 224 | +| `csidrivers` | | storage.k8s.io/v1 | false | CSIDriver | |
| 225 | +| `csinodes` | | storage.k8s.io/v1 | false | CSINode | |
| 226 | +| `csistoragecapacities` | | storage.k8s.io/v1 | true | CSIStorageCapacity | |
| 227 | +| `storageclasses` | `sc` | storage.k8s.io/v1 | false | StorageClass | |
| 228 | +| `volumeattachments` | | storage.k8s.io/v1 | false | VolumeAttachment | |
222 | 229 |
|
223 | 230 | ## 출력 옵션
|
224 | 231 |
|
|
0 commit comments