mirror of
https://github.com/lucky-sideburn/kubeinvaders.git
synced 2026-05-06 00:36:44 +00:00
improve Dockerfile e Vagrantfile
This commit is contained in:
17
Dockerfile
17
Dockerfile
@@ -11,9 +11,9 @@ RUN apt-get -y install --no-install-recommends wget gnupg ca-certificates jq ope
|
||||
RUN wget -O - https://openresty.org/package/pubkey.gpg | apt-key add -
|
||||
RUN codename=`grep -Po 'VERSION="[0-9]+ \(\K[^)]+' /etc/os-release` && echo "deb http://openresty.org/package/debian $codename openresty" | tee /etc/apt/sources.list.d/openresty.list
|
||||
RUN apt-get update
|
||||
RUN apt-get -y install openresty luarocks
|
||||
RUN chmod 777 /usr/local/openresty/nginx
|
||||
RUN apt-get -y install openresty luarocks libssl-dev git vim lua-json lua-socket
|
||||
RUN apt-get update --fix-missing
|
||||
RUN chmod 777 /usr/local/openresty/nginx
|
||||
RUN luarocks install luasec
|
||||
RUN luarocks install lunajson
|
||||
|
||||
@@ -27,7 +27,7 @@ COPY kube-linter/kube-linter-parser.sh /opt/kube-linter-parser.sh
|
||||
RUN chmod +x /opt/kube-linter-parser.sh
|
||||
|
||||
# Install game part
|
||||
COPY ./html5 /var/www/html
|
||||
COPY html5/ /var/www/html
|
||||
|
||||
# Install Redis
|
||||
RUN apt-get install redis -y
|
||||
@@ -35,13 +35,16 @@ COPY redis/redis.conf /etc/redis/redis.conf
|
||||
|
||||
# Configure Nginx
|
||||
RUN sed -i.bak 's/listen\(.*\)80;/listen 8081;/' /etc/nginx/conf.d/default.conf
|
||||
RUN mkdir /usr/local/openresty/nginx/conf/kubeinvaders
|
||||
|
||||
COPY nginx/nginx.conf /etc/nginx/nginx.conf
|
||||
COPY nginx/metrics.lua /tmp/metrics.lua
|
||||
COPY nginx/pod.lua /tmp/pod.lua
|
||||
COPY nginx/node.lua /tmp/node.lua
|
||||
COPY chaos-node/chaos-node.lua /tmp/chaos-node.lua
|
||||
|
||||
COPY scripts/metrics.lua /usr/local/openresty/nginx/conf/kubeinvaders/metrics.lua
|
||||
COPY scripts/pod.lua /usr/local/openresty/nginx/conf/kubeinvaders/pod.lua
|
||||
COPY scripts/node.lua /usr/local/openresty/nginx/conf/kubeinvaders/node.lua
|
||||
COPY scripts/chaos-node.lua /usr/local/openresty/nginx/conf/kubeinvaders/chaos-node.lua
|
||||
COPY scripts/chaos-containers.lua /usr/local/openresty/nginx/conf/kubeinvaders/chaos-containers.lua
|
||||
COPY scripts/config_kubeinv.lua /usr/local/openresty/lualib/config_kubeinv.lua
|
||||
COPY nginx/KubeInvaders.conf /etc/nginx/conf.d/KubeInvaders.conf
|
||||
RUN chmod g+rwx /var/cache/nginx /var/run /var/log/nginx /var/www/html /etc/nginx/conf.d
|
||||
|
||||
|
||||
57
Vagrantfile
vendored
57
Vagrantfile
vendored
@@ -7,9 +7,9 @@
|
||||
# you're doing.
|
||||
Vagrant.configure('2') do |config|
|
||||
|
||||
config.vm.network 'forwarded_port', guest: 80, host: 8080, host_ip: '127.0.0.1'
|
||||
|
||||
$script = <<-SCRIPT
|
||||
$k3s_server = <<-SCRIPT
|
||||
sed -i 's/PasswordAuthentication\ no/PasswordAuthentication\ yes/g' /etc/ssh/sshd_config
|
||||
systemctl restart sshd
|
||||
helm_url=https://get.helm.sh/helm-v3.5.3-linux-amd64.tar.gz
|
||||
which k3s || curl -sfL https://get.k3s.io | sh -
|
||||
which helm || (curl -o /home/vagrant/$(basename $helm_url) $helm_url -L --silent && \
|
||||
@@ -27,17 +27,54 @@ Vagrant.configure('2') do |config|
|
||||
kubectl get namespaces | grep kubeinvaders || kubectl create namespace kubeinvaders
|
||||
SCRIPT
|
||||
|
||||
config.vm.provision 'shell', inline: $script
|
||||
|
||||
config.vm.post_up_message = '\n\nEnjoy KubeInvaders!\n\n'
|
||||
config.vm.synced_folder ".", "/vagrant", type: "smb"
|
||||
|
||||
config.vm.define 'kubeinvaders01' do |rke|
|
||||
rke.vm.box = 'ubuntu/focal64'
|
||||
rke.vm.hostname = 'kubeinvaders01'
|
||||
rke.vm.network "private_network", ip: "192.168.58.99"
|
||||
rke.vm.provider :virtualbox do |vb|
|
||||
config.vm.define 'kubeinvaders01' do |k3s|
|
||||
k3s.vm.box = 'ubuntu/focal64'
|
||||
k3s.vm.hostname = 'kubeinvaders01'
|
||||
k3s.vm.provision 'shell', inline: $k3s_server
|
||||
k3s.vm.network 'private_network', ip: '192.168.58.99'
|
||||
k3s.vm.network 'forwarded_port', guest: 80, host: 8080, host_ip: '127.0.0.1'
|
||||
k3s.vm.provider :virtualbox do |vb|
|
||||
vb.memory = 4096
|
||||
vb.cpus = 2
|
||||
end
|
||||
#k3s.vm.provision "shell",
|
||||
# run: "always",
|
||||
# inline: "route add default gw 192.168.58.99"
|
||||
end
|
||||
|
||||
config.vm.define 'kubeinvaders02' do |k3s|
|
||||
k3s.vm.box = 'ubuntu/focal64'
|
||||
k3s.vm.hostname = 'kubeinvaders02'
|
||||
k3s.vm.network 'private_network', ip: '192.168.58.100'
|
||||
k3s.vm.provider :virtualbox do |vb|
|
||||
vb.memory = 2048
|
||||
vb.cpus = 1
|
||||
end
|
||||
end
|
||||
|
||||
$openresty = <<-SCRIPT
|
||||
cd /vagrant
|
||||
docker build . -t kubeinvaders-dev
|
||||
docker rm kubeinvaders -f
|
||||
docker run -d -v /vagrant/scripts:/usr/local/openresty/nginx/conf/kubeinvaders -p 8080:8080 \
|
||||
--restart always --name kubeinvaders --env KUBERNETES_SERVICE_HOST=192.168.58.99 --env KUBERNETES_SERVICE_PORT=8443\
|
||||
--env ROUTE_HOST=kubeinvaders.io --env ENDPOINT=kubeinvaders.io \
|
||||
--env TOKEN=#{ ENV['KUBEINVADERS_DEV_TOKEN']} --env NAMESPACE="namespace1,namespace2" \
|
||||
kubeinvaders-dev
|
||||
SCRIPT
|
||||
|
||||
config.vm.define 'openresty' do |nginx|
|
||||
nginx.vm.box = 'debian/buster64'
|
||||
nginx.vm.hostname = 'ngnix01'
|
||||
nginx.vm.network 'private_network', ip: '192.168.58.101'
|
||||
nginx.vm.provision 'shell', inline: $openresty
|
||||
nginx.vm.provider :virtualbox do |vb|
|
||||
vb.memory = 2048
|
||||
vb.cpus = 1
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user