Skip to content

Commit 535743e

Browse files
committed
Update cheatsheet: add section for interacting with Deployments and Services
1 parent 28b3930 commit 535743e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

content/en/docs/reference/kubectl/cheatsheet.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,18 @@ kubectl top pod POD_NAME --containers # Show metrics for a given p
317317
kubectl top pod POD_NAME --sort-by=cpu # Show metrics for a given pod and sort it by 'cpu' or 'memory'
318318
```
319319

320+
## Interacting with Deployments and Services
321+
```bash
322+
kubectl logs deploy/my-deployment # dump Pod logs for a Deployment (single-container case)
323+
kubectl logs deploy/my-deployment -c my-container # dump Pod logs for a Deployment (multi-container case)
324+
325+
kubectl port-forward svc/my-service 5000 # listen on local port 5000 and forward to port 5000 on Service backend
326+
kubectl port-forward svc/my-service 5000:my-service-port # listen on local port 5000 and forward to Service target port with name <my-service-port>
327+
328+
kubectl port-forward deploy/my-deployment 5000:6000 # listen on local port 5000 and forward to port 6000 on a Pod created by <my-deployment>
329+
kubectl exec deploy/my-deployment -- ls # run command in first Pod and first container in Deployment (single- or multi-container cases)
330+
```
331+
320332
## Interacting with Nodes and cluster
321333

322334
```bash

0 commit comments

Comments
 (0)