Compare commits
6 Commits
refactor-w
...
master
Author | SHA1 | Date | |
---|---|---|---|
6e034f26c3 | |||
f01049df74 | |||
0a45462205 | |||
9dc7b76d11 | |||
10e5c885f6 | |||
ceb08124f0 |
53
README.md
53
README.md
@ -1,5 +1,5 @@
|
|||||||
# lxc_manager_node
|
# lxc_manager_node
|
||||||
This has been tested on **clean** install of ubuntu 14.04 64bit.
|
This has been tested on **clean** install of ubuntu 16.04 64bit.
|
||||||
|
|
||||||
## install
|
## install
|
||||||
Update you system to the newest packages and reboot. You may need to do this several times:
|
Update you system to the newest packages and reboot. You may need to do this several times:
|
||||||
@ -18,9 +18,13 @@ Now you can install the packages we need:
|
|||||||
sudo add-apt-repository ppa:ubuntu-lxc/stable
|
sudo add-apt-repository ppa:ubuntu-lxc/stable
|
||||||
sudo add-apt-repository ppa:ubuntu-lxc/cgmanager-stable
|
sudo add-apt-repository ppa:ubuntu-lxc/cgmanager-stable
|
||||||
sudo apt-get update && sudo apt-get upgrade
|
sudo apt-get update && sudo apt-get upgrade
|
||||||
sudo apt-get install git nodejs npm lxc redis-server btrfs-tools
|
sudo apt-get install git nodejs npm lxc btrfs-tools lxctl lxc-templates uidmap libpam-cgfs
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### may need this
|
||||||
|
https://discuss.linuxcontainers.org/t/failed-creating-cgroups/272/10 looking more into it.
|
||||||
|
|
||||||
|
|
||||||
remap `nodejs` to `node`:
|
remap `nodejs` to `node`:
|
||||||
```bash
|
```bash
|
||||||
sudo ln -s /usr/bin/nodejs /usr/bin/node
|
sudo ln -s /usr/bin/nodejs /usr/bin/node
|
||||||
@ -73,7 +77,52 @@ If everything worked you can stop and delete the container
|
|||||||
lxc-stop -n test-ubuntu
|
lxc-stop -n test-ubuntu
|
||||||
lxc-destroy -n test-ubuntu
|
lxc-destroy -n test-ubuntu
|
||||||
```
|
```
|
||||||
|
## Open resty config file
|
||||||
|
```lua
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
resolver 10.0.3.1; # use LXC dns
|
||||||
|
|
||||||
|
set $target '';
|
||||||
|
access_by_lua '
|
||||||
|
function mysplit(inputstr, sep)
|
||||||
|
-- http://stackoverflow.com/a/7615129/3140931
|
||||||
|
if sep == nil then
|
||||||
|
sep = "%s"
|
||||||
|
end
|
||||||
|
local t={} ; i=0
|
||||||
|
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
|
||||||
|
t[i] = str
|
||||||
|
i = i + 1
|
||||||
|
end
|
||||||
|
return t,i
|
||||||
|
end
|
||||||
|
|
||||||
|
host, hostLen = mysplit(ngx.var.host, ".")
|
||||||
|
|
||||||
|
if hostLen == 1 then
|
||||||
|
ngx.var.target = host[0]..":15000"
|
||||||
|
elseif hostLen == 6 then
|
||||||
|
ngx.var.target = host[1]..":"..host[0]
|
||||||
|
elseif hostLen == 5 then
|
||||||
|
ngx.var.target = host[0]..":15000"
|
||||||
|
else
|
||||||
|
return ngx.exit(599)
|
||||||
|
end
|
||||||
|
';
|
||||||
|
|
||||||
|
proxy_pass http://$target;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $remote_addr;
|
||||||
|
proxy_set_header Host $host;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "upgrade";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
# auto start
|
# auto start
|
||||||
## crontab
|
## crontab
|
||||||
|
18
guest_setup.sh
Normal file
18
guest_setup.sh
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
apt update;
|
||||||
|
apt upgrade -y;
|
||||||
|
|
||||||
|
wget https://github.com/wmantly/crunner/blob/master/crunner?raw=true -O /usr/local/bin/crunner;
|
||||||
|
chmod +x /usr/local/bin/crunner;
|
||||||
|
|
||||||
|
apt install git nano wget python3-dev python3-pip;
|
||||||
|
|
||||||
|
echo "
|
||||||
|
#!/bin/bash;
|
||||||
|
export NODE_PATH='/usr/local/lib/node_modules:$NODE_PATH';
|
||||||
|
export TERM=xterm-256color;
|
||||||
|
cd ~;
|
||||||
|
crunner &;
|
||||||
|
exit 0;
|
||||||
|
" > /opt/bytedev.sh
|
||||||
|
|
||||||
|
|
41
host_setup.sh
Normal file
41
host_setup.sh
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
echo "Update the base system\n";
|
||||||
|
apt update;
|
||||||
|
apt upgrade -y;
|
||||||
|
|
||||||
|
echo "\n\n\nInstall stuff\n";
|
||||||
|
|
||||||
|
add-apt-repository -y ppa:ubuntu-lxc/stable;
|
||||||
|
apt update;
|
||||||
|
apt upgrade -y;
|
||||||
|
apt install -y git lxc btrfs-tools lxctl lxc-templates uidmap libpam-cgfs libpcre3-dev libssl-dev perl make build-essential curl;
|
||||||
|
|
||||||
|
echo "\n\n\ninstalling open resty\n";
|
||||||
|
|
||||||
|
# import our GPG key:
|
||||||
|
wget -qO - https://openresty.org/package/pubkey.gpg | sudo apt-key add -;
|
||||||
|
|
||||||
|
# for installing the add-apt-repository command
|
||||||
|
# (you can remove this package and its dependencies later):
|
||||||
|
apt-get -y install software-properties-common;
|
||||||
|
|
||||||
|
# add the our official APT repository:
|
||||||
|
add-apt-repository -y "deb http://openresty.org/package/ubuntu $(lsb_release -sc) main";
|
||||||
|
|
||||||
|
# to update the APT index:
|
||||||
|
apt-get update;
|
||||||
|
|
||||||
|
apt-get install -y openresty;
|
||||||
|
|
||||||
|
# TODO!
|
||||||
|
# Add the proxy config file
|
||||||
|
|
||||||
|
echo "\n\n\nSet up virt user\n";
|
||||||
|
|
||||||
|
|
||||||
|
adduser virt --gecos "" --disabled-password;
|
||||||
|
echo "virt:1lovebyte" | chpasswd;
|
||||||
|
|
||||||
|
echo "virt veth lxcbr0 1024" | tee -a /etc/lxc/lxc-usernet;
|
||||||
|
|
||||||
|
# TODO!
|
||||||
|
# added default base config for LXC runners.
|
Loading…
x
Reference in New Issue
Block a user