Skip to content

Commit 203ad6d

Browse files
authored
Merge pull request #26062 from notchairmk/cheatsheet_deploy_svc
Update cheatsheet: add interacting with Deployments and Services
2 parents b7a3e4c + 535743e commit 203ad6d

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
@@ -320,6 +320,18 @@ kubectl top pod POD_NAME --containers # Show metrics for a given p
320320
kubectl top pod POD_NAME --sort-by=cpu # Show metrics for a given pod and sort it by 'cpu' or 'memory'
321321
```
322322

323+
## Interacting with Deployments and Services
324+
```bash
325+
kubectl logs deploy/my-deployment # dump Pod logs for a Deployment (single-container case)
326+
kubectl logs deploy/my-deployment -c my-container # dump Pod logs for a Deployment (multi-container case)
327+
328+
kubectl port-forward svc/my-service 5000 # listen on local port 5000 and forward to port 5000 on Service backend
329+
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>
330+
331+
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>
332+
kubectl exec deploy/my-deployment -- ls # run command in first Pod and first container in Deployment (single- or multi-container cases)
333+
```
334+
323335
## Interacting with Nodes and cluster
324336

325337
```bash

0 commit comments

Comments
 (0)