Skip to content
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

css file is not getting rendered using custom default backend #11169

Open
xpan0616 opened this issue Mar 27, 2024 · 5 comments
Open

css file is not getting rendered using custom default backend #11169

xpan0616 opened this issue Mar 27, 2024 · 5 comments
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one.

Comments

@xpan0616
Copy link

xpan0616 commented Mar 27, 2024

What happened:
I set custom default backend for my ingress nginx controller. When I test this, I can see 503.html page showing but without any CSS applied to it can you help me understand why.

apiVersion: v1
kind: ConfigMap
metadata:
  name: custom-error-pages
  namespace: nginx-external
data:
  503.html: |
    <!DOCTYPE html>
    <html>
        <head>
            <title>ERROR PAGE</title>
            <link rel="stylesheet"  href="custom.css">
        </head>
        <body>
          <h1>ERROR PAGE</h1>
        </body>
    </html>
 custom.css: |
    body {
        background-color: #f2f2f2;
        font-family: Arial, sans-serif;
    }

controller:
  config:
     custom-http-errors: "503"
defaultBackend:
  enabled: true
  image:
    registry: registry.k8s.io
    image: ingress-nginx/nginx-errors
    tag: "0.48.1"
  extraVolumes:
    - name: custom-error-pages
      configMap:
        name: custom-error-pages
        items:
        - key: "503.html"
          path: "503.html"
        - key: "custom.css"
          path: "custom.css"
  extraVolumeMounts:
    - name: custom-error-pages
      mountPath: /www

What you expected to happen:

I expect if html page has css or picture it should work. In your example, I don't see such an example with css or image

I am not sure ! I tried to change the css link to
<link rel="stylesheet" href="/www/custom.css">
that didn't work either

NGINX Ingress controller version (exec into the pod and run nginx-ingress-controller --version.):

Kubernetes version (use kubectl version):

kubectl version
Client Version: v1.29.1
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.27.9

Environment:

  • Cloud provider or hardware configuration: AKS

  • OS (e.g. from /etc/os-release):

  • Kernel (e.g. uname -a):

  • Install tools:

    • Please mention how/where was the cluster created like kubeadm/kops/minikube/kind etc. This is a AKS cluster
  • Basic cluster related info:

    • kubectl get nodes -o wide
  • How was the ingress-nginx-controller installed: helm upgrade --install nginx-external ingress-nginx/ingress-nginx --namespace nginx-external -f external-ingress-config.yaml

  • If helm was used then please show output of helm ls -A | grep -i ingress

helm ls -A | grep -i ingress
nginx-external                          nginx-external  13              2024-03-26 18:20:11.7097725 -0700 PDT   deployed        ingress-nginx-4.10.0                                                            1.10.0
  • If helm was used then please show output of helm -n <ingresscontrollernamespace> get values <helmreleasename>
USER-SUPPLIED VALUES:
controller:
  config:
    compute-full-forwarded-for: "true"
    custom-http-errors: "503"
    enable-real-ip: "true"
    http-redirect-code: "301"
    minReadySeconds: 0
    server-tokens: "false"
    ssl-redirect: "true"
    updateStrategy:
      rollingUpdate:
        maxUnavailable: 1
        type: RollingUpdate
    use-forwarded-headers: "true"
  ingressClassResource:
    controllerValue: k8s.io/ingress-nginx
    default: false
    enabled: true
    name: nginx-external
  metrics:
    enabled: "true"
  podAnnotations:
    prometheus.io/port: "10254"
    prometheus.io/scrape: "true"
  service:
    annotations:
      service.beta.kubernetes.io/azure-load-balancer-internal: "false"
    externalTrafficPolicy: Local
    loadBalancerIP: <redact>
defaultBackend:
  enabled: true
  extraVolumeMounts:
  - mountPath: /www
    name: custom-error-pages
  extraVolumes:
  - configMap:
      items:
      - key: 503.html
        path: 503.html
      - key: custom.css
        path: custom.css
      name: custom-error-pages
    name: custom-error-pages
  image:
    image: ingress-nginx/nginx-errors
    registry: registry.k8s.io
    tag: 0.48.1

  • Current State of the controller:
    • kubectl describe ingressclasses
      Name: nginx-external
      Labels: app.kubernetes.io/component=controller
      app.kubernetes.io/instance=nginx-external
      app.kubernetes.io/managed-by=Helm
      app.kubernetes.io/name=ingress-nginx
      app.kubernetes.io/part-of=ingress-nginx
      app.kubernetes.io/version=1.10.0
      helm.sh/chart=ingress-nginx-4.10.0
      Annotations: meta.helm.sh/release-name: nginx-external
      meta.helm.sh/release-namespace: nginx-external
      Controller: k8s.io/ingress-nginx
      Events:

    • kubectl -n <ingresscontrollernamespace> get all -A -o wide

NAME                                                               READY   STATUS    RESTARTS   AGE     IP             NODE                                  NOMINATED NODE   READINESS GATES
pod/nginx-external-ingress-nginx-controller-8bfffc649-mldjl        1/1     Running   0          4h39m   10.224.1.75    aks-application-78946373-vmss00001p   <none>           <none>
pod/nginx-external-ingress-nginx-defaultbackend-6dd799b6d9-bdgcs   1/1     Running   0          3h30m   10.224.1.112   aks-application-78946373-vmss00001p   <none>           <none>

NAME                                                        TYPE           CLUSTER-IP     EXTERNAL-IP    PORT(S)                      AGE   SELECTOR
service/nginx-external-ingress-nginx-controller             LoadBalancer   10.0.251.10    23.98.149.42   80:32372/TCP,443:31446/TCP   77d   app.kubernetes.io/component=controller,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx
service/nginx-external-ingress-nginx-controller-admission   ClusterIP      10.0.115.228   <none>         443/TCP                      77d   app.kubernetes.io/component=controller,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx
service/nginx-external-ingress-nginx-controller-metrics     ClusterIP      10.0.105.125   <none>         10254/TCP                    77d   app.kubernetes.io/component=controller,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx
service/nginx-external-ingress-nginx-defaultbackend         ClusterIP      10.0.113.245   <none>         80/TCP                       12h   app.kubernetes.io/component=default-backend,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx

NAME                                                          READY   UP-TO-DATE   AVAILABLE   AGE   CONTAINERS                      IMAGES                                                                                                                     SELECTOR
deployment.apps/nginx-external-ingress-nginx-controller       1/1     1            1           77d   controller                      registry.k8s.io/ingress-nginx/controller:v1.10.0@sha256:42b3f0e5d0846876b1791cd3afeb5f1cbbe4259d6f35651dcc1b5c980925379c   app.kubernetes.io/component=controller,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx
deployment.apps/nginx-external-ingress-nginx-defaultbackend   1/1     1            1           12h   ingress-nginx-default-backend   registry.k8s.io/ingress-nginx/nginx-errors:0.48.1                                                                          app.kubernetes.io/component=default-backend,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx

NAME                                                                     DESIRED   CURRENT   READY   AGE     CONTAINERS                      IMAGES                                                                                                                     SELECTOR
replicaset.apps/nginx-external-ingress-nginx-controller-7545bcf997       0         0         0       25h     controller                      registry.k8s.io/ingress-nginx/controller:v1.10.0@sha256:42b3f0e5d0846876b1791cd3afeb5f1cbbe4259d6f35651dcc1b5c980925379c   app.kubernetes.io/component=controller,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx,pod-template-hash=7545bcf997
replicaset.apps/nginx-external-ingress-nginx-controller-7669b88964       0         0         0       77d     controller                      registry.k8s.io/ingress-nginx/controller:v1.9.5@sha256:b3aba22b1da80e7acfc52b115cae1d4c687172cbf2b742d5b502419c25ff340e    app.kubernetes.io/component=controller,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx,pod-template-hash=7669b88964
replicaset.apps/nginx-external-ingress-nginx-controller-8bfffc649        1         1         1       12h     controller                      registry.k8s.io/ingress-nginx/controller:v1.10.0@sha256:42b3f0e5d0846876b1791cd3afeb5f1cbbe4259d6f35651dcc1b5c980925379c   app.kubernetes.io/component=controller,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx,pod-template-hash=8bfffc649
replicaset.apps/nginx-external-ingress-nginx-defaultbackend-5d999cdb8b   0         0         0       12h     ingress-nginx-default-backend   registry.k8s.io/ingress-nginx/nginx-errors:0.48.1                                                                          app.kubernetes.io/component=default-backend,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx,pod-template-hash=5d999cdb8b
replicaset.apps/nginx-external-ingress-nginx-defaultbackend-6d485dd789   0         0         0       6h3m    ingress-nginx-default-backend   registry.k8s.io/ingress-nginx/nginx-errors:0.48.1                                                                          app.kubernetes.io/component=default-backend,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx,pod-template-hash=6d485dd789
replicaset.apps/nginx-external-ingress-nginx-defaultbackend-6dd799b6d9   1         1         1       3h49m   ingress-nginx-default-backend   registry.k8s.io/ingress-nginx/nginx-errors:0.48.1 
  • kubectl -n <ingresscontrollernamespace> describe po <ingresscontrollerpodname>
Name:             nginx-external-ingress-nginx-controller-8bfffc649-mldjl
Namespace:        nginx-external
Priority:         0
Service Account:  nginx-external-ingress-nginx
Node:             aks-application-78946373-vmss00001p/10.224.1.100
Start Time:       Tue, 26 Mar 2024 17:30:26 -0700
Labels:           app.kubernetes.io/component=controller
                 app.kubernetes.io/instance=nginx-external
                 app.kubernetes.io/managed-by=Helm
                 app.kubernetes.io/name=ingress-nginx
                 app.kubernetes.io/part-of=ingress-nginx
                 app.kubernetes.io/version=1.10.0
                 helm.sh/chart=ingress-nginx-4.10.0
                 pod-template-hash=8bfffc649
Annotations:      prometheus.io/port: 10254
                 prometheus.io/scrape: true
Status:           Running
IP:               10.224.1.75
IPs:
 IP:           10.224.1.75
Controlled By:  ReplicaSet/nginx-external-ingress-nginx-controller-8bfffc649
Containers:
 controller:
   Container ID:    containerd://e645702565a289d56e04d5decfcf61c8a7ec789351556ffad6d1f2272d0f75e4
   Image:           registry.k8s.io/ingress-nginx/controller:v1.10.0@sha256:42b3f0e5d0846876b1791cd3afeb5f1cbbe4259d6f35651dcc1b5c980925379c
   Image ID:        registry.k8s.io/ingress-nginx/controller@sha256:42b3f0e5d0846876b1791cd3afeb5f1cbbe4259d6f35651dcc1b5c980925379c
   Ports:           80/TCP, 443/TCP, 10254/TCP, 8443/TCP
   Host Ports:      0/TCP, 0/TCP, 0/TCP, 0/TCP
   SeccompProfile:  RuntimeDefault
   Args:
     /nginx-ingress-controller
     --default-backend-service=$(POD_NAMESPACE)/nginx-external-ingress-nginx-defaultbackend
     --publish-service=$(POD_NAMESPACE)/nginx-external-ingress-nginx-controller
     --election-id=nginx-external-ingress-nginx-leader
     --controller-class=k8s.io/ingress-nginx
     --ingress-class=nginx
     --configmap=$(POD_NAMESPACE)/nginx-external-ingress-nginx-controller
     --validating-webhook=:8443
     --validating-webhook-certificate=/usr/local/certificates/cert
     --validating-webhook-key=/usr/local/certificates/key
   State:          Running
     Started:      Tue, 26 Mar 2024 17:30:27 -0700
   Ready:          True
   Restart Count:  0
   Requests:
     cpu:      100m
     memory:   90Mi
   Liveness:   http-get http://:10254/healthz delay=10s timeout=1s period=10s #success=1 #failure=5
   Readiness:  http-get http://:10254/healthz delay=10s timeout=1s period=10s #success=1 #failure=3
   Environment:
     POD_NAME:       nginx-external-ingress-nginx-controller-8bfffc649-mldjl (v1:metadata.name)
     POD_NAMESPACE:  nginx-external (v1:metadata.namespace)
     LD_PRELOAD:     /usr/local/lib/libmimalloc.so
   Mounts:
     /usr/local/certificates/ from webhook-cert (ro)
     /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-tstdm (ro)
Conditions:
 Type              Status
 Initialized       True
 Ready             True
 ContainersReady   True
 PodScheduled      True
Volumes:
 webhook-cert:
   Type:        Secret (a volume populated by a Secret)
   SecretName:  nginx-external-ingress-nginx-admission
   Optional:    false
 kube-api-access-tstdm:
   Type:                    Projected (a volume that contains injected data from multiple sources)
   TokenExpirationSeconds:  3607
   ConfigMapName:           kube-root-ca.crt
   ConfigMapOptional:       <nil>
   DownwardAPI:             true
QoS Class:                   Burstable
Node-Selectors:              kubernetes.io/os=linux
Tolerations:                 node.kubernetes.io/memory-pressure:NoSchedule op=Exists
                            node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
                            node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:                      <none>
  • kubectl -n <ingresscontrollernamespace> describe svc <ingresscontrollerservicename>
Name:                     nginx-external-ingress-nginx-controller
Namespace:                nginx-external
Labels:                   app.kubernetes.io/component=controller
                          app.kubernetes.io/instance=nginx-external
                          app.kubernetes.io/managed-by=Helm
                          app.kubernetes.io/name=ingress-nginx
                          app.kubernetes.io/part-of=ingress-nginx
                          app.kubernetes.io/version=1.10.0
                          helm.sh/chart=ingress-nginx-4.10.0
Annotations:              meta.helm.sh/release-name: nginx-external
                          meta.helm.sh/release-namespace: nginx-external
                          service.beta.kubernetes.io/azure-load-balancer-internal: false
Selector:                 app.kubernetes.io/component=controller,app.kubernetes.io/instance=nginx-external,app.kubernetes.io/name=ingress-nginx
Type:                     LoadBalancer
IP Family Policy:         SingleStack
IP Families:              IPv4
IP:                       10.0.251.10
IPs:                      10.0.251.10
IP:                       23.98.149.42
LoadBalancer Ingress:     23.98.149.42
Port:                     http  80/TCP
TargetPort:               http/TCP
NodePort:                 http  32372/TCP
Endpoints:                10.224.1.75:80
Port:                     https  443/TCP
TargetPort:               https/TCP
NodePort:                 https  31446/TCP
Endpoints:                10.224.1.75:443
Session Affinity:         None
External Traffic Policy:  Local
HealthCheck NodePort:     30473
Events:                   <none>
  • Current state of ingress object, if applicable:

    • kubectl -n <appnamespace> get all,ing -o wide
    • kubectl -n <appnamespace> describe ing <ingressname>
    • If applicable, then, your complete and exact curl/grpcurl command (redacted if required) and the reponse to the curl/grpcurl command with the -v flag
  • Others:

    • Any other related information like ;
      • copy/paste of the snippet (if applicable)
      • kubectl describe ... of any custom configmap(s) created and in use
      • Any other related information that may help
@xpan0616 xpan0616 added the kind/bug Categorizes issue or PR as related to a bug. label Mar 27, 2024
@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/test-infra 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 27, 2024
@longwuyuan
Copy link
Contributor

/remove-kind bug

I think static content serving etc is a question for your frontend engineering team. They can use relative path maybe. The controller just routes requests and CSS is not requested explicitly by a client

@k8s-ci-robot k8s-ci-robot added needs-kind Indicates a PR lacks a `kind/foo` label and requires one. and removed kind/bug Categorizes issue or PR as related to a bug. labels Mar 27, 2024
@xpan0616
Copy link
Author

xpan0616 commented Mar 27, 2024 via email

@longwuyuan
Copy link
Contributor

I can not create a new backend to give example

I dont see the code of your backend so can not comment on that.

Please wait for comments from other users of custom backend who have same use case.

Copy link

This is stale, but we won't close it automatically, just bare in mind the maintainers may be busy with other tasks and will reach your issue ASAP. If you have any question or request to prioritize this, please reach #ingress-nginx-dev on Kubernetes Slack.

@github-actions github-actions bot added the lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. label Apr 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. 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