Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added <POD_IP> #263

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion b.multi_container_pods.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ kubectl delete po busybox
Easiest way to do it is create a pod with a single container and save its definition in a YAML file:

```bash
kubectl run web --image=nginx --restart=Never --port=80 --dry-run=client -o yaml > pod-init.yaml
kubectl run box --image=nginx --restart=Never --port=80 --dry-run=client -o yaml > pod-init.yaml
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, where does box come from?

```

Copy/paste the container related values, so your final YAML should contain the volume and the initContainer:
Expand Down
5 changes: 5 additions & 0 deletions c.pod_design.md
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,11 @@ kubectl create cronjob busybox --image=busybox --schedule="*/1 * * * *" -- /bin/
</details>

### See its logs and delete it
```bash
kubectl get po # copy the container just created
kubectl logs <container> # you will see the date and message
kubectl delete cj busybox --force #cj stands for cronjob and --force to delete immediately
```

<details><summary>show</summary>
<p>
Expand Down
6 changes: 3 additions & 3 deletions f.services.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ kubectl label deployment foo --overwrite app=foo
```bash
kubectl get pods -l app=foo -o wide # 'wide' will show pod IPs
kubectl run busybox --image=busybox --restart=Never -it --rm -- sh
wget -O- POD_IP:8080 # do not try with pod name, will not work
# try hitting all IPs to confirm that hostname is different
wget -O- <POD_IP>:8080 # do not try with pod name, will not work
# try hitting all IPs generated after running 1st command to confirm that hostname is different
exit
# or
kubectl get po -o wide -l app=foo | awk '{print $6}' | grep -v IP | xargs -L1 -I '{}' kubectl run --rm -ti tmp --restart=Never --image=busybox -- wget -O- http://\{\}:8080
Expand Down Expand Up @@ -170,7 +170,7 @@ kubectl get endpoints foo # you will see the IPs of the three replica pods, list
kubectl get svc # get the foo service ClusterIP
kubectl run busybox --image=busybox -it --rm --restart=Never -- sh
wget -O- foo:6262 # DNS works! run it many times, you'll see different pods responding
wget -O- SERVICE_CLUSTER_IP:6262 # ClusterIP works as well
wget -O- <SERVICE_CLUSTER_IP>:6262 # ClusterIP works as well
# you can also kubectl logs on deployment pods to see the container logs
kubectl delete svc foo
kubectl delete deploy foo
Expand Down