[go: nahoru, domu]

Skip to content

zalopay-oss/mocker-k1s

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Mocker v1.0.0

Playful container engine created by 500 lines bash script

Demo

asciicast

Install on Centos

Tested with AWS Linux ami-0f2eac25772cd4e36

curl https://raw.githubusercontent.com/zalopay-oss/mocker-k1s/main/mocker/install.sh | bash

Basic usage

Demo mocker file

$ cat golang1.Mockerfile
RUN wget https://github.com/dinhanhhuy/go-backend/releases/download/1.0.0/go-backend-linux-amd64
RUN chmod +x go-backend-linux-amd64
RUN echo 'this is go-backend 1000' > /root/.mocker/layer/builder_space/index.html
RUN ls -la
RUN ls -la

Build image from Mockerfile

$ mocker build img1 golang1.Mockerfile
...
932ace9337a30e1f58841718c2624870
[INFO]: buding RUN chmod +x go-backend-linux-amd64
[INFO]: buding RUN echo 'this is go-backend 1000' > /root/.mocker/layer/builder_space/index.html
[INFO]: buding RUN ls -la
[INFO]: buding RUN ls -la
[INFO]: buding CMD ID=go-backend-1 WORK_DIR=/root/workspace /root/workspace/go-backend-linux-amd64
/root/.mocker/layer
|-- 2d15f0c52caa33fd679b2fdc8f14f642
|   |-- go-backend-linux-amd64
|   `-- index.html
|-- 90cb403239851d091015e1e2d98f489b
|   |-- entry.sh
|   |-- go-backend-linux-amd64
|   `-- index.html
|-- 932ace9337a30e1f58841718c2624870
|   `-- go-backend-linux-amd64
|-- ba8675a9a669696c12076f6c0b879a7d
|   |-- go-backend-linux-amd64
|   `-- index.html
|-- ddf58290b0367f3f695074b6ecde8985
|   `-- go-backend-linux-amd64
|-- f4d1ea5912242d002cc06053b6220342
|   |-- go-backend-linux-amd64
|   `-- index.html
`-- img1 -> 90cb403239851d091015e1e2d98f489b
 __________________________
< Build image img1 success >
 --------------------------
        \   ^__^
         \  (><)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

List all images

$ mocker images
/root/.mocker/layer
|-- 2d15f0c52caa33fd679b2fdc8f14f642
|   |-- go-backend-linux-amd64
|   `-- index.html
|-- 90cb403239851d091015e1e2d98f489b
|   |-- entry.sh
|   |-- go-backend-linux-amd64
|   `-- index.html
|-- 932ace9337a30e1f58841718c2624870
|   `-- go-backend-linux-amd64
|-- ba8675a9a669696c12076f6c0b879a7d
|   |-- go-backend-linux-amd64
|   `-- index.html
|-- ddf58290b0367f3f695074b6ecde8985
|   `-- go-backend-linux-amd64
|-- f4d1ea5912242d002cc06053b6220342
|   |-- go-backend-linux-amd64
|   `-- index.html
`-- img1 -> 90cb403239851d091015e1e2d98f489b

Run new container with isolate network

$ mocker run backend img1
ip backend, ip 10.0.0.5, pid 3832
 ___________________________________
< Success create backend, ip: 10.0.0.5 >
 -----------------------------------
        \   ^__^
         \  (oO)\_______
            (__)\       )\/\
                ||----w |
                ||     ||

List container

$ mocker ps
backend 10.0.0.5

Test connection

container backend running at 10.0.0.5:10000

$ curl 10.0.0.5:10000
this is go-backend 1000

Verify the host dont listen on 10000

$ netstat -lnpt | grep 10000
# exit 1

Execute to pod and check for network

$ mocker exec backend
______________
< exec backend >
 -------------
        \   ^__^
         \  (..)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
[root@ip-172-31-20-239 /]# netstat -lnpt | grep 10000
tcp6       0      0 :::10000                :::*                    LISTEN      5/go-backend-linux-

About

Create your docker and kubernetes engine

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages