kubernetes-ingress icon indicating copy to clipboard operation
kubernetes-ingress copied to clipboard

how to use haproxy-ingress controller with lua script.

Open yashmujumdar15 opened this issue 5 years ago • 4 comments

I want to use haproxy-ingress controller with lua-script. it will be great help if anyone has implemented or has any document on the same

yashmujumdar15 avatar Sep 28 '20 19:09 yashmujumdar15

Hi @yashmujumdar15 Lua usage is not currently available but this can be considered for future releases. can you share more details about your use-case of LUA usage?

Mo3m3n avatar Nov 18 '20 23:11 Mo3m3n

in our case mostly to support CORS. example https://github.com/haproxytech/haproxy-lua-cors/blob/master/example/haproxy/cors.lua

egzonzeneli avatar Dec 07 '20 18:12 egzonzeneli

What is the timeline for this? I also think k this would be a great feature we use lua scripts to decode jwt tokens for more detailed logging.

PvanHengel avatar Jan 02 '21 18:01 PvanHengel

I need the exact same thing - to decode JWT :)

KlavsKlavsen avatar Sep 17 '22 14:09 KlavsKlavsen

Same here, I'd like to add https://doc.crowdsec.net/docs/next/bouncers/haproxy/ to my ingress controller

mateuszdrab avatar Apr 03 '23 21:04 mateuszdrab

we ended up having to fork the base image and build our haproxy IC image like follows:

FROM haproxytech/kubernetes-ingress:1.9.5 AS common

ENV LUA_VERSION 5.3

# Install packages necessary for Lua, Luarocks
RUN apk update
RUN apk add build-base
RUN apk add lua${LUA_VERSION} lua${LUA_VERSION}-dev luarocks${LUA_VERSION}
RUN apk add openssl openssl-dev
RUN apk add git


RUN luarocks-${LUA_VERSION} install luaossl
RUN luarocks-${LUA_VERSION} install luasocket

# Collection of useful Lua utilities, namely https://stevedonovan.github.io/Penlight/api/libraries/pl.tablex.html#merge
# which I use to merge `pg_notify` JSON updates into the global `auth_data` table in memory.
RUN luarocks-${LUA_VERSION} install penlight

... etc. ...

mecampbellsoup avatar Jun 30 '23 19:06 mecampbellsoup

we ended up having to fork the base image and build our haproxy IC image like follows:

FROM haproxytech/kubernetes-ingress:1.9.5 AS common

ENV LUA_VERSION 5.3

# Install packages necessary for Lua, Luarocks
RUN apk update
RUN apk add build-base
RUN apk add lua${LUA_VERSION} lua${LUA_VERSION}-dev luarocks${LUA_VERSION}
RUN apk add openssl openssl-dev
RUN apk add git


RUN luarocks-${LUA_VERSION} install luaossl
RUN luarocks-${LUA_VERSION} install luasocket

# Collection of useful Lua utilities, namely https://stevedonovan.github.io/Penlight/api/libraries/pl.tablex.html#merge
# which I use to merge `pg_notify` JSON updates into the global `auth_data` table in memory.
RUN luarocks-${LUA_VERSION} install penlight

... etc. ...

Doesn't seem too complicated, maybe you could PR it?

mateuszdrab avatar Jun 30 '23 21:06 mateuszdrab

Doesn't seem too complicated, maybe you could PR it?

Huh? Like make the base Dockerfile configurable to install lua/luarocks in the image?

mecampbellsoup avatar Jun 30 '23 22:06 mecampbellsoup

Doesn't seem too complicated, maybe you could PR it?

Huh? Like make the base Dockerfile configurable to install lua/luarocks in the image?

One very weird/surprising thing I have noticed with this approach is that HAProxy is always built w/ Lua 5.3.

This is surprising because the base alpine image hardcoded in the ingress controller Dockerfile here is using haproxy-alpine:2.6, which in turn seems to build haproxy with Lua 5.4.

However, when my IC starts, haproxy reports having been built with 5.3, not 5.4:

/usr/local/share/lua/5.4 $ haproxy -vv | grep Lua
Built with Lua version : Lua 5.3.6

Somehow both 5.3 and 5.4 are installed in the container:

/usr/local/share/lua/5.4 $ ls /usr/lib/lua5.3
liblua-5.3.so.0      liblua-5.3.so.0.0.0
/usr/local/share/lua/5.4 $ ls /usr/lib/lua5.4
liblua-5.4.so.0      liblua-5.4.so.0.0.0  liblua.a             liblua.so

Anyone know what's going on here?

mecampbellsoup avatar Jul 05 '23 21:07 mecampbellsoup

Resolved a while ago: https://github.com/haproxytech/kubernetes-ingress/issues/552

dkorunic avatar Sep 20 '23 15:09 dkorunic