-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
> Has anyone been able to configure nginx-ingress -> fpm
? Been unable to configure this
#8207
Comments
@vikomte: This issue is currently awaiting triage. If Ingress contributors determines this is a relevant issue, they will accept it by applying the The 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/test-infra repository. |
The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale |
No one has been able to clear this out ? |
There is no data in this issue that someone can analyse. But practically if someone is really going to create a new Kubernetes cluster and then write new php based apps on it, then they will find it more practical to combine the php-code, the fpm software and the nginx web server in one single docker image and spawn one or more pod(s) from that image. Because its simpler to have a 12 factor microservice app in a single self-contained rather than splitting php-code, fpm software and nginx web server into 3 different pods. |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /lifecycle rotten |
The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. This bot triages issues and PRs according to the following rules:
You can:
Please send feedback to sig-contributor-experience at kubernetes/community. /close |
@k8s-triage-robot: Closing this issue. In response to this:
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/test-infra repository. |
Or... the one pod with the php files and php-fpm in one pod, and using the already-existing "ingress nginx" pods and ecosystem the cluster already has. Spinning up more nginx pods is redundant and wasteful for resources when a configuration should be able to serve this. |
Any Updates ? |
Were having exactly this issue - the page https://kubernetes.github.io/ingress-nginx/user-guide/fcgi-services/ is what we followed and no joy, I can see my liviness/rediness probes working (using the php-fpm-healthcheck we get /status hits in the php-fpm log) but all I seem to get is 504. Using php-fpm latest (8.3) - if I put my own NGINX in my deployment and proxy then this works, but since the ingress is NGINX and I don't care about static serving using the built in ingress to talk FCGI seems the right route to go.
The workaround for us was to add another container to our deployment for NGINX and handle fast-cgi there so we can proxy from the ingress controller via the HTTP protocol, however it seems like this should be possible without. |
Are there any updates on this issue? |
well this issue is closed so maybe we need to open a new one - bit of a joke really, asking google it seems this is a common issue but the docs do state this sort of thing should work - would be great if I'd just missed something, but I'm certainly struggling - if I get a chance I'll get a full basic test case together and raise a fresh as our robot enemy @k8s-ci-robot has closed this issue - which means its unlikely to be being worked on. |
|
that page was the guide I followed - there is more info on the github pages - but this documentation does not work for me - pretty sure the yamls provided should be proof enough, I'd be happy to pull together something that can be used as a unit test as a proof this issue still presents. |
|
ok - i'll do my best - but we currently have several large projects on the go and while this would be awesome to get sorted (as it removes yet another layer of abstraction) the unfortunate thing is the work around while daft/wasteful it does work... maybe I missed something but I have already lost several days trying to make this work so would be good to get it written up properly for you guys. |
in that case ;
|
I have tried this ;
Then I edited the ingress and added the required annotations like thus ;
So you can do the same and point your app's serverblock to use it like ;
as described here https://hub.docker.com/r/bitnami/php-fpm |
but i feel my comments or the info in them and your comments need to go into another issue that has the appropriate issue description |
These annotations are for the ingress controller to determine how the traffic should be routed to the container -
So I was expecting the HTTP request to go direct to the fastcgi container as we've told the ingress controller what the protocol is. This is a bit confusing since it gives the impression to the reader that you could route traffic to an API endpoint from external HTTP requests without the need of an additional NGINX container within your deployment, else whats the purpose here? Since NGINX server block above is stating its a fastcgi_pass etc, it would not use the annotations - the pod exposes ports - your block would be for an nginx instance within the deployment no? What I expected (righty or wrongly) was that the annotations would instruct the ingress controller to proxy to php for you since we've told it about the protocol. |
Please move to another issue because this issue describes the problem as |
I think i get this now - so you can expose the FGCI to outside world, rather than implementing the proxy within the ingress.
Dont think this is the case since the FCGI server is the destination of said ingress.
So basically what we are saying is that the ingress routes traffic to an endpoint that must support HTTP if you want to route web traffic to it, and that HTTP->FCGI is something you have to handle within your deployment since nginx-ingress wont help you with this, however you can also expose FCGI to external proxy if you require which is what this feature does. Thanks for your help in clarifying this - in fact it is more obvious now re-reading the docs - The ingress-nginx ingress controller can be used to directly expose FastCGI servers. Enabling FastCGI in your Ingress only requires setting the backend-protocol annotation to FCGI, and with a couple more annotations you can customize the way ingress-nginx handles the communication with your FastCGI server. directly expose means literally the raw service, not proxied as an http endpoint that a browser can visit. The mistake made is in assuming ingress would can handle this for you - its a little more simple than that, a point I'd missed. Thanks @longwuyuan for your patience - I get this now, in our current context we route into this cluster via a proxy so this feature will still be useful since the HTTP server can proxy to the FPM direct instead. |
@BloodyIron @fabpico I see you 2 as successful users of the FCGI feature, in #10462. Requesting you to comment on the last few comments above. If I am wrong, I apologise but your comments could help clarify for @web-engineer . Thanks |
I don't think this understanding is correct. I just configured my Ingress definition as per the documentation (https://kubernetes.github.io/ingress-nginx/user-guide/fcgi-services/) and it looks like it started to correctly proxy requests to FCGI backend. Frontend protocol exposed by ingress controller is still HTTP(s). Even the annotation name - |
@kamilzzz if what you are reporting is true (at least my interpretation) then I think I have made a huge huge mistake. My request is that you help me understand this data. The port name in the ingress here https://kubernetes.github.io/ingress-nginx/user-guide/fcgi-services/ is fastcgi the port number is 9000 And the port name in the ingress resource is fastcgi the name fastcgi in the ingress resource hints the port number behind name fastcgi is port number 9000 is this assumption wrong ? If its wrong, kindly help understand your description
Where is the HTTPS port 443 in that example. If youhave a testbed, can you post all the |
This is very similar setup to mine. Now, you should be able to access This is the same like your app would expose something on port |
I wish we could have the To begin with I am confused about this
So if port number is fcgi=9000 then how was the request received on port 443 ? Or was the request sent to port 9000 and the controller accepted it because the controller is listening on 9000 in addition to 80 & 443 ? I will try to test but I am confused if the example-app is a fpm service or a php application |
@kamilzzz can you post the |
I need some help here to reproduce what you posted.
Test data belowPod created
Service created
configMap created
Ingress Created
Log Messages in controller after creating Ingress
@kamilzzz , can you please guide me on what should my curl command be ? Or how should I send a request to this ingress ? I had assumed that a nginx webserver would use this service like this example https://gist.github.com/md5/d9206eacb5a0ff5d6be0#file-wordpress-fpm-conf-L25 |
The pod is listening on port 9000 ;
|
And the example-app service is available to clients outside the cluster, via the ingress, for connections from outside the cluster to the example-app pod running fpm ;
|
Should copy/paste the fair warning officially provided by the developers of the PHP interpreter here https://hub.docker.com/_/php |
Ingress controller installation: Deployment: apiVersion: apps/v1
kind: Deployment
metadata:
name: php-fpm
labels:
app: php-fpm
spec:
replicas: 1
selector:
matchLabels:
app: php-fpm
template:
metadata:
labels:
app: php-fpm
spec:
containers:
- name: php-fpm
image: php:8.2-fpm
ports:
- containerPort: 9000 Service: apiVersion: v1
kind: Service
metadata:
name: php-fpm-service
spec:
selector:
app: php-fpm
ports:
- protocol: TCP
port: 9000
targetPort: 9000 Config map (for ingress): apiVersion: v1
kind: ConfigMap
metadata:
name: example-cm
data:
SCRIPT_FILENAME: "/var/www/html/index.php" Ingress: apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: php-fpm-ingress
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "FCGI"
nginx.ingress.kubernetes.io/fastcgi-index: "index.php"
nginx.ingress.kubernetes.io/fastcgi-params-configmap: "example-cm"
spec:
ingressClassName: nginx
rules:
- host: fcgi.kubernetes.int
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: php-fpm-service
port:
number: 9000 Deployment order: deployment -> service -> config map -> ingress (config map should be deployed before ingress definition as described in the ingress-controller docs). By default <!DOCTYPE html>
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php echo '<p>Hello World</p>'; ?>
</body>
</html> Testing with curl:
So the flow is like that: |
@kamilzzz, you are right. Thank you very very much for the help. If you want to improve the docs with a PR, it will be a very useful contribution for users of FastCGI. @web-engineer sorry. No need to proxy from elsewhere. These tests did not include all the directives supported by the controller so that will be a task to-do. Reopening this so that we can improve the docs on FastCGI, if posible. /reopen |
@longwuyuan: Reopened this issue. In response to this:
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. |
@vikomte latest messagesare data showing successful php rendering html |
@kamilzzz I just locust tested 20K users on laptop kind cluster to php:fpm-alpine. Are you using php-fpm images as-is in production and not breaking a sweat ! If you are, does your CI just keep rolling out new images that are php-code, plus php plus fpm . |
@kamilzzz Can you look at this https://deploy-preview-11454--kubernetes-ingress-nginx.netlify.app/user-guide/fcgi-services/ and comment |
Sorry probably going to be a while before I can say anything useful on this topic, life stuff, hence the delay in my response, sorry about that! :(( |
Have you managed to do it ? I'm still unable to run a simple website:
php:7.4-fpm -> EXPOSE 4243 -> /var/www/html/index.php -> <?php phpinfo(); ?>
ConfigMap -> SCRIPT_FILENAME: "/var/www/html/index.php"
Originally posted by @vikomte in #6602 (comment)
The text was updated successfully, but these errors were encountered: