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

Add communication between pods #131

Merged
merged 2 commits into from
Nov 3, 2023
Merged
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
52 changes: 50 additions & 2 deletions podman/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ $ podman play kube ./test-svc.yaml
```
NOTE: Necessary to specify dockerhub registry cleary with `registry.hub.docker.com/library/` for nginx image.

Know avaiable options
Know available options
---------------------

`podman pod` seems like `kubectl` for pod operation and the avaiable options are:
`podman pod` seems like `kubectl` for pod operation and the available options are:

```
$ podman pod --help
Expand Down Expand Up @@ -112,3 +112,51 @@ Commercial support is available at
</body>
</html>
root@test-svc:/#
```

Network communication between pods
----------------------------------

Need to specify the same network when deploying pods:
```
$ podman play kube --network podman ./shell.yaml
$ podman play kube --network podman ./pods-and-svc.yaml
```
Check IP address of nginx pod:
```
$ podman ps | grep nginx
4675e132974a registry.hub.docker.com/library/nginx:latest nginx -g daemon o... 39 minutes ago Up 39 minutes ago test-svc-nginx
$ podman inspect test-svc-nginx | jq -r ".[0].NetworkSettings.Networks.podman.IPAddress"
10.88.0.3
$
```
Access to nginx from a different container:
```
$ podman ps | grep bash
3c1758a60d3b docker.io/library/ubuntu:22.04 41 minutes ago Up 41 minutes ago test-shell-bash
$
$ podman exec -it 3c1758a60d3b curl 10.88.0.3
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
```
9 changes: 9 additions & 0 deletions podman/shell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Pod
metadata:
name: test-shell
spec:
containers:
- name: bash
image: ubuntu:22.04
command: ["sleep", "3600"]
Loading