[7] Tworzymy Pods’y
3 sierpnia 2020Stworzymy Pods’y podobnie jak Kubernetes.
[1] Stwórz Pods’a i dodaj go do kontenera.
# stwórz pustego Pods'a # -p [bind port] -n [nazwa Pods'a] [root@lsr01vm ~]# podman pod create -p 8081:80 -n test_pod 051237d3bb93fbee7e21b8625440432d89399e9bfdc526e5e48e4aca866e4067 # pokaż Pods'y [root@lsr01vm ~]# podman pod ls POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID 051237d3bb93 test_pod Created 39 seconds ago 1 264af8c6273f # pokaż szczegółowe informacje o Pods'ach [root@lsr01vm ~]# podman pod inspect test_pod { "Config": { "id": "051237d3bb93fbee7e21b8625440432d89399e9bfdc526e5e48e4aca866e4067", "name": "test_pod", "hostname": "test_pod", "labels": { }, "cgroupParent": "machine.slice", "sharesCgroup": true, "sharesIpc": true, "sharesNet": true, "sharesUts": true, "infraConfig": { "makeInfraContainer": true, "infraPortBindings": [ { "hostPort": 8081, "containerPort": 80, "protocol": "tcp", "hostIP": "" } ] }, "created": "2020-07-30T18:27:08.384573574+02:00", "lockID": 20 }, "State": { "cgroupPath": "machine.slice/machine-libpod_pod_051237d3bb93fbee7e21b8625440432d89399e9bfdc526e5e48e4aca866e4067.slice", "infraContainerID": "264af8c6273f2c1e2b356da19114b887c889048fff0aebd3b6d3fd16f883b243" }, "Containers": [ { "id": "264af8c6273f2c1e2b356da19114b887c889048fff0aebd3b6d3fd16f883b243", "state": "configured" } ] } [root@lsr01vm ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE zicher.lab/nginx_server latest 1ea2f3d4afab 6 days ago 299 MB zicher.lab/centos_httpd latest 20386223ebaa 6 days ago 270 MB docker.io/library/registry 2 2d4f4b5309b1 5 weeks ago 26.8 MB docker.io/library/centos latest 831691599b88 6 weeks ago 223 MB k8s.gcr.io/pause 3.1 da86e6ba6ca1 2 years ago 749 kB # uruchom kontener i dodaj do niego Pods'a [root@lsr01vm ~]# podman run -dt --pod test_pod zicher.lab/nginx_server 6c3b386ee238ad197b67f0fd6f6704b888dc55693cb72b5f4d292648229876e9 [root@lsr01vm ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6c3b386ee238 zicher.lab/nginx_server:latest /usr/sbin/nginx -... 11 seconds ago Up 11 seconds ago 0.0.0.0:8081->80/tcp optimistic_ganguly 264af8c6273f k8s.gcr.io/pause:3.1 3 minutes ago Up 11 seconds ago 0.0.0.0:8081->80/tcp 051237d3bb93-infra 04b4e7f87156 docker.io/library/registry:2 /etc/docker/regis... 44 minutes ago Exited (1) 44 minutes ago 0.0.0.0:5000->5000/tcp exciting_montalcini 20b31c947490 docker.io/library/registry:2 /etc/docker/regis... 45 minutes ago Exited (1) 45 minutes ago 0.0.0.0:5000->5000/tcp priceless_mahavira 0b116693b262 zicher.lab/nginx_server:latest /usr/sbin/nginx -... 45 minutes ago Exited (0) 44 minutes ago 0.0.0.0:80->80/tcp elegant_solomon 313a5dccdf26 zicher.lab/nginx_server:latest /usr/sbin/nginx -... 46 minutes ago Created 0.0.0.0:80->80/tcp modest_einstein ec63571542d1 zicher.lab/nginx_server:latest /usr/sbin/nginx -... 48 minutes ago Created 0.0.0.0:80->80/tcp cool_chatterjee 8e71002345a1 docker.io/library/registry:2 /etc/docker/regis... 53 minutes ago Exited (1) 53 minutes ago 0.0.0.0:5000->5000/tcp mystifying_solomon 9fbd088237f3 docker.io/library/registry:2 /etc/docker/regis... 54 minutes ago Exited (1) 54 minutes ago 0.0.0.0:5000->5000/tcp determined_wilson 0c0d8936d3e8 docker.io/library/registry:2 /etc/docker/regis... About an hour ago Exited (1) About an hour ago 0.0.0.0:5000->5000/tcp determined_goodall fcfb707e847d docker.io/library/registry:2 /etc/docker/regis... About an hour ago Exited (1) About an hour ago 0.0.0.0:5000->5000/tcp fervent_jones c1e5fc667b9a docker.io/library/centos:latest /bin/bash About an hour ago Exited (0) About an hour ago dazzling_herschel 2ce953cba2fa docker.io/library/centos:latest /bin/bash About an hour ago Exited (0) About an hour ago mystifying_diffie f8a6a7761c70 docker.io/library/centos:latest /bin/bash About an hour ago Exited (0) About an hour ago kind_zhukovsky 5d32a924ed85 docker.io/library/centos:latest /bin/bash About an hour ago Exited (0) 46 minutes ago competent_kowalevski 635b1bdcf1c6 docker.io/library/registry:2 /etc/docker/regis... 2 hours ago Exited (1) 2 hours ago 0.0.0.0:5000->5000/tcp gifted_varahamihira c18ded5ea1ca docker.io/library/registry:2 /etc/docker/regis... 2 hours ago Exited (1) 2 hours ago 0.0.0.0:5000->5000/tcp nostalgic_herschel 1b3226629e36 docker.io/library/centos:latest /bin/bash 6 days ago Exited (0) 6 days ago recursing_vaughan 9c85c933377e zicher.lab/nginx_server:latest /usr/sbin/nginx -... 6 days ago Exited (0) 6 days ago 0.0.0.0:80->80/tcp competent_chatterjee 0385b11630c6 zicher.lab/centos_httpd:latest /usr/sbin/apachec... 6 days ago Exited (137) 6 days ago 0.0.0.0:8081->80/tcp fervent_edison 98b896c61406 zicher.lab/centos_httpd:latest /usr/bin/whereis ... 6 days ago Exited (0) 6 days ago funny_agnesi 27b604ee2a63 docker.io/library/centos:latest /bin/bash -c dnf ... 6 days ago Exited (0) 6 days ago busy_elbakyan # sprawdź dostęp [root@lsr01vm ~]# curl localhost:8081 Test DOCKERFILE w NGINX'ie # zatrzymaj Pods'a [root@lsr01vm ~]# podman pod stop test_pod 051237d3bb93fbee7e21b8625440432d89399e9bfdc526e5e48e4aca866e4067 # usuń Pods'a (usuwasz także contener) [root@lsr01vm ~]# podman pod rm test_pod --force 051237d3bb93fbee7e21b8625440432d89399e9bfdc526e5e48e4aca866e4067
[2] Jest możliwe stworzenie Pods’a i dodanie go do kontenera w jednej komendzie.
[root@lsr01vm ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE zicher.lab/nginx_server latest 1ea2f3d4afab 6 days ago 299 MB zicher.lab/centos_httpd latest 20386223ebaa 6 days ago 270 MB docker.io/library/registry 2 2d4f4b5309b1 5 weeks ago 26.8 MB docker.io/library/centos latest 831691599b88 6 weeks ago 223 MB k8s.gcr.io/pause 3.1 da86e6ba6ca1 2 years ago 749 kB # stwórz [test_pod2] Pods i uruchom go w kontenerze [root@lsr01vm ~]# podman run -dt --pod new:test_pod2 -p 80:80 -p 3306:3306 zicher.lab/nginx_server 25a301ab6fba18b1c8f9f0ed47438816bc6d23fbd1b2876fed4f2a715042a7b5 [root@lsr01vm ~]# podman pod ls POD ID NAME STATUS CREATED # OF CONTAINERS INFRA ID 2748d69f09cd test_pod2 Running 24 seconds ago 2 73391669bed6 [root@lsr01vm ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 25a301ab6fba zicher.lab/nginx_server:latest /usr/sbin/nginx -... 49 seconds ago Up 43 seconds ago 0.0.0.0:80->80/tcp priceless_joliot 73391669bed6 k8s.gcr.io/pause:3.1 50 seconds ago Up 46 seconds ago 0.0.0.0:80->80/tcp 2748d69f09cd-infra 04b4e7f87156 docker.io/library/registry:2 /etc/docker/regis... About an hour ago Exited (1) About an hour ago 0.0.0.0:5000->5000/tcp exciting_montalcini 20b31c947490 docker.io/library/registry:2 /etc/docker/regis... About an hour ago Exited (1) About an hour ago 0.0.0.0:5000->5000/tcp priceless_mahavira 0b116693b262 zicher.lab/nginx_server:latest /usr/sbin/nginx -... About an hour ago Exited (0) About an hour ago 0.0.0.0:80->80/tcp elegant_solomon 313a5dccdf26 zicher.lab/nginx_server:latest /usr/sbin/nginx -... About an hour ago Created 0.0.0.0:80->80/tcp modest_einstein ec63571542d1 zicher.lab/nginx_server:latest /usr/sbin/nginx -... About an hour ago Created 0.0.0.0:80->80/tcp cool_chatterjee 8e71002345a1 docker.io/library/registry:2 /etc/docker/regis... About an hour ago Exited (1) About an hour ago 0.0.0.0:5000->5000/tcp mystifying_solomon 9fbd088237f3 docker.io/library/registry:2 /etc/docker/regis... About an hour ago Exited (1) About an hour ago 0.0.0.0:5000->5000/tcp determined_wilson 0c0d8936d3e8 docker.io/library/registry:2 /etc/docker/regis... 2 hours ago Exited (1) 2 hours ago 0.0.0.0:5000->5000/tcp determined_goodall fcfb707e847d docker.io/library/registry:2 /etc/docker/regis... 2 hours ago Exited (1) 2 hours ago 0.0.0.0:5000->5000/tcp fervent_jones c1e5fc667b9a docker.io/library/centos:latest /bin/bash 2 hours ago Exited (0) 2 hours ago dazzling_herschel 2ce953cba2fa docker.io/library/centos:latest /bin/bash 2 hours ago Exited (0) 2 hours ago mystifying_diffie f8a6a7761c70 docker.io/library/centos:latest /bin/bash 2 hours ago Exited (0) 2 hours ago kind_zhukovsky 5d32a924ed85 docker.io/library/centos:latest /bin/bash 2 hours ago Exited (0) About an hour ago competent_kowalevski 635b1bdcf1c6 docker.io/library/registry:2 /etc/docker/regis... 2 hours ago Exited (1) 2 hours ago 0.0.0.0:5000->5000/tcp gifted_varahamihira c18ded5ea1ca docker.io/library/registry:2 /etc/docker/regis... 2 hours ago Exited (1) 2 hours ago 0.0.0.0:5000->5000/tcp nostalgic_herschel 1b3226629e36 docker.io/library/centos:latest /bin/bash 6 days ago Exited (0) 6 days ago recursing_vaughan 9c85c933377e zicher.lab/nginx_server:latest /usr/sbin/nginx -... 6 days ago Exited (0) 6 days ago 0.0.0.0:80->80/tcp competent_chatterjee 0385b11630c6 zicher.lab/centos_httpd:latest /usr/sbin/apachec... 6 days ago Exited (137) 6 days ago 0.0.0.0:8081->80/tcp fervent_edison 98b896c61406 zicher.lab/centos_httpd:latest /usr/bin/whereis ... 6 days ago Exited (0) 6 days ago funny_agnesi 27b604ee2a63 docker.io/library/centos:latest /bin/bash -c dnf ... 6 days ago Exited (0) 6 days ago busy_elbakyan [root@lsr01vm ~]# podman run -dt --pod test_pod2 -e MYSQL_ROOT_PASSWORD=Password mariadb Trying to pull registry.access.redhat.com/mariadb... name unknown: Repo not found Trying to pull registry.redhat.io/mariadb... unable to retrieve auth token: invalid username/password: unauthorized: Please login to the Red Hat Registry using your Customer Portal credentials. Further instructions can be found here: https://access.redhat.com/RegistryAuthentication Trying to pull docker.io/library/mariadb... Getting image source signatures Copying blob e7cb79d19722 done Copying blob 78ed0160f03e done Copying blob a122e9306ac4 done Copying blob b7f616834fd0 done Copying blob 3ff22d22a855 done Copying blob 323d0d660b6a done Copying blob caf1e694359b done Copying blob a41772aadb3d done Copying blob 04f5e4f6ead3 done Copying blob 673e89352b19 done Copying blob c3811aa2fa0a done Copying blob 655ad574d3c7 done Copying blob 90ae536d75f0 done Copying config 8075b7694a done Writing manifest to image destination Storing signatures e63dafba1a1b1083c35a89364a789b4ce805457d53303c8dc105ba7ab5f495d5 [root@lsr01vm ~]# podman ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 008130d2292e docker.io/library/mariadb:latest mysqld 36 seconds ago Up 34 seconds ago 0.0.0.0:80->80/tcp musing_curran 1f79bfee7063 zicher.lab/nginx_server:latest /usr/sbin/nginx -... 3 minutes ago Created 0.0.0.0:80->80/tcp practical_edison 168f00c702f2 k8s.gcr.io/pause:3.1 3 minutes ago Up 35 seconds ago 0.0.0.0:80->80/tcp c8b4c6435e8d-infra 9324444730df zicher.lab/nginx_server:latest /usr/sbin/nginx -... 6 minutes ago Exited (0) 2 minutes ago 0.0.0.0:80->80/tcp distracted_kilby # musisz mieć zainstalowany [mariadb] [root@lsr01vm ~]# mysql -u root -p -h lsr01vm.zicher.lab -e "show variables like 'hostname';" Enter password: # wpisujesz ustawione wcześniej hasło +---------------+-----------+ | Variable_name | Value | +---------------+-----------+ | hostname | test_pod2 | +---------------+-----------+