Skip to content

Lua scripts in controller 1.12.0 Doesnt work #12975

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
FaraSys opened this issue Mar 14, 2025 · 2 comments
Closed

Lua scripts in controller 1.12.0 Doesnt work #12975

FaraSys opened this issue Mar 14, 2025 · 2 comments
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@FaraSys
Copy link

FaraSys commented Mar 14, 2025

What happened:
Hello everyone.

Last week, I updated the Ingress controllers from version 1.11.2 to 1.12.0, and I started experiencing issues when using Lua scripts through the configuration-snippet annotation.

I created an Ingress resource (you can see the YAML below) that includes the configuration-snippet annotation referencing my Lua script. After applying this Ingress resource, when I try to access it, I receive a 404 HTTP response.

Next, I logged into the Ingress controller and opened the nginx.conf file, and noticed that the server block for my resource is simply missing.

If I remove the configuration-snippet annotation, the resource appears in the nginx.conf configuration file of the controller.

Could you please help me resolve this issue?

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: qpba-mid
  namespace: mid
  annotations:
    ingress.kubernetes.io/ssl-redirect: 'true'
    ingress.kubernetes.io/use-port-in-redirects: 'true'
    nginx.ingress.kubernetes.io/enable-cors: 'true'
    nginx.ingress.kubernetes.io/force-ssl-redirect: 'true'
    nginx.ingress.kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/proxy-buffering: 'off'
    nginx.ingress.kubernetes.io/proxy-max-temp-file-size: 256m
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/server-snippet: |
      access_by_lua_file /etc/nginx/lua/qpba.lua;
spec:
  ingressClassName: nginx
  tls:
    - hosts:
        - qpba-mid.domain.net
      secretName: tls-cert
  rules:
    - host: qpba-mid.domain.net
      http:
        paths:
          - path: /mid(/|$)(.*)
            pathType: Prefix
            backend:
              service:
                name: mid
                port:
                  number: 80

What you expected to happen:

  1. Successfully parse and include the Lua script in the NGINX configuration.

  2. Create the corresponding server block in the nginx.conf file.

  3. Allow access to the resource without any issues, returning the appropriate HTTP response (e.g., 200 OK) when accessed.

In other words, the Ingress resource should work as intended, with the Lua script being executed as part of the NGINX configuration, and the resource should be accessible without errors.

NGINX Ingress controller version (exec into the pod and run /nginx-ingress-controller --version):
NGINX Ingress controller
Release: v1.12.0
Build: ba73b2c
Repository:
https://github.com/kubernetes/ingress-nginx
nginx version: nginx/1.25.5

Kubernetes version (use kubectl version):
Client Version: v1.30.8
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.30.8
Environment:

@FaraSys FaraSys added the kind/bug Categorizes issue or PR as related to a bug. label Mar 14, 2025
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If Ingress contributors determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority labels Mar 14, 2025
@FaraSys FaraSys changed the title Lua scripts in controller 1.12.0 Doesnt worl Lua scripts in controller 1.12.0 Doesnt work Mar 14, 2025
@Gacko
Copy link
Member

Gacko commented Mar 15, 2025

Snippet annotations are of annotation risk level Critical and therefore disabled by default in v1.12.0. You need to raise your annotation risk level back to Critical to enable them: #11819

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.
Projects
Development

No branches or pull requests

3 participants