Files
kubeinvaders/nginx/KubeInvaders_dev.templ
2021-01-02 18:35:13 +01:00

43 lines
1.4 KiB
Plaintext

server {
listen 8080 default_server;
root /var/www/html/;
index index.html;
location /kube-linter {
default_type text/html;
content_by_lua_block {
local arg = ngx.req.get_uri_args()
ngx.req.read_body()
local request_body = ngx.req.get_body_data()
local opts = " --token=" .. arg['token'] .. " --server=" .. arg['k8s_url'] .. " --insecure-skip-tls-verify=true -n " .. arg['namespace']
os.execute("kubectl get pod " .. arg['pod_name'] .. " " .. opts .. " -o yaml > /tmp/" .. arg['pod_name'] .. ".yaml")
os.execute("/opt/kube-linter-parser.sh /tmp/" .. arg['pod_name'] .. ".yaml > /tmp/" .. arg['pod_name'] .. ".linter")
local handle = io.popen('jq -R -s -c \'split("\n")\' < /tmp/' .. arg['pod_name'] .. '.linter | jq \'map(select(length > 0))\'')
local result = handle:read("*a")
os.execute("rm -f /tmp/" .. arg['pod_name'] .. ".linter")
os.execute("rm -f /tmp/" .. arg['pod_name'] .. ".yaml")
ngx.say(result)
}
}
location / {
try_files $uri $uri/ =404;
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
}
location /kube {
rewrite ^/kube(.*)$ /api$1 break;
proxy_pass ${ENDPOINT};
}
location /kube/api {
rewrite ^/kube/api(.*)$ /api$1 break;
proxy_pass ${ENDPOINT};
}
}