How can I config the context path to access in nifi + kubernetes as /something/nifi?

7/24/2019

I'm setting up a new pod in kubernetes with apache nifi using the nifi docker Image. How can I configure k8 and nifi to access to the ui as something.com/mynifi/nifi instead of something.com/nifi?

Running k8, with other services. I've tried setting up the env variable NIFI_WEB_PROXY_CONTEXT_PATH to add '/mynifi'

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: mynifi
spec:
  replicas: 1
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
  minReadySeconds: 5
  revisionHistoryLimit: 0
  template:
    metadata:
      labels:
        app: mynifi
    spec:
      imagePullSecrets:
        - name: mynifi
      containers:
        - name: mynifi
          image: apache/nifi
          imagePullPolicy: Always
          env:
            - name: NIFI_WEB_PROXY_CONTEXT_PATH
              value: "/mynifi"
          ports:
            - name: service
              protocol: TCP
              containerPort: 8080
          resources:
            requests:
              cpu: 50m
              memory: 128Mi
            limits:
              cpu: 500m
              memory: 1024Mi

My ingress

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/configuration-snippet: |
      proxy_set_header X-ProxyContextPath /mynifi;
  name: mynifi
  namespace: default
spec:
  rules:
    - host: something.com
      http:
        paths:
          - backend:
              serviceName: mynifi
              servicePort: 8080
            path: /mynifi/
  tls:
    - hosts:
        - something.com

Accessing to something.com/mynifi/ is redirecting me to something.com/nifi. I want to use something.com/mynifi/nifi

-- Ricardo Colombo
apache-nifi
kubernetes

1 Answer

7/31/2019

I don't think you can accomplish it with ingress somehow.

Could be something in nifi setting /opt/nifi/nifi-current/conf/nifi.properties

Normally, your ingress looks like:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: /mynifi
  name: mynifi
  namespace: default
spec:
  rules:
    - host: something.com
      http:
        paths:
          - backend:
              serviceName: mynifi
              servicePort: 8080
            path: /*
  tls:
    - hosts:
        - something.com

That would rewrite something.com/<blah>/<blah> to something.com/mynifi

However, nifi controls root path by itself and always tries to redirect to something.com/nifi

As a result you'll trap to infinite redirection loop and eventually get

ERR_TOO_MANY_REDIRECTS
-- A_Suh
Source: StackOverflow