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

Does ST2 Web Ingress support not only "/"? #145

Closed
wantdrink opened this issue Aug 5, 2020 · 7 comments
Closed

Does ST2 Web Ingress support not only "/"? #145

wantdrink opened this issue Aug 5, 2020 · 7 comments
Labels
question Further information is requested

Comments

@wantdrink
Copy link

wantdrink commented Aug 5, 2020

Hi there,
We are testing installing 2 stackstorm (1 active and the other for backup) in the same k8s cluster. The helm release name is 'st1' and 'st2'
.
I enabled the ingress and try to use path rewrite and hope to access them with /st1 /st2.
"stackstorm.dev.com" is our dev F5 VIP with DNS resolvable.

ingress:
  enabled: true
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
  hosts:
    - host: stackstorm.dev.com
      paths:
        - path: /st1(/|$)(.*)
          serviceName: st1-st2web
          servicePort: 80

Finally I found that access https://stackstorm.dev.com/st1/ (the tail '/' should not be omitted) and try to login.I can see the home page, but login will be redirected to:

Request URL: https://stackstorm.dev.com/auth/tokens

context 'st1' was lost.

Do we support the URL rewrite in st2-web like grafana? If not we can only access the ingress from that VIP with "/" for only one of those instances.

@arm4b arm4b added the question Further information is requested label Aug 5, 2020
@arm4b
Copy link
Member

arm4b commented Aug 8, 2020

The Helm chart just provides the templating around the K8s Ingress (https://kubernetes.io/docs/concepts/services-networking/ingress/):
https://github.com/StackStorm/stackstorm-ha/blob/5575afcc8594b21e90648ae78f27b2c2ec254ee7/templates/ingress.yaml#L24-L44

As I understand the behavior and rewrite mechanisms might look different depending on K8s Ingress controller you configure (https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/).

So worth debugging further down the path.

Another point to mention, - after the Ingress you hit the nginx st2web. So that's another place to look at. Here is how the config looks like: https://github.com/StackStorm/st2/blob/master/conf/nginx/st2.conf

If you'll find the solution for your problem, - please don't forget to share it in the issue.

@wantdrink
Copy link
Author

Thanks @armab .
Based on https://github.com/StackStorm/st2/blob/master/conf/nginx/st2.conf if change the requirement from "access different context path to reach different stackstorm HA instances" to "just change the context path for the only one", it could be solved as:

annotations:
  kubernetes.io/ingress.class: nginx
  nginx.ingress.kubernetes.io/rewrite-target: /$2
hosts:
  - host: stackstorm.dev.com
    paths:
      - path: /st1(/|$)(.*)
        serviceName: st1-st2web
        servicePort: 80
      - path: /auth(/|$)(.*)
        serviceName: st1-st2auth
        servicePort: 9100
      - path: /api(/|$)(.*)
        serviceName: st1-st2api
        servicePort: 9101
      - path: /stream(/|$)(.*)
        serviceName: st1-st2stream
        servicePort: 9102

But for the original requirement we still need to dig into the code. The web UI access api/stream/auth directly with https://[api/stream/auth] without considering the context path.
So maybe it's hard to access different HA instances with the rewrite mechenizm.

@moonrail
Copy link
Contributor

moonrail commented Apr 1, 2021

Hi @wantdrink
I just stumbled upon this issue.

The solution is to configure st2web.

In #165 this chart was extended to give you the possibility to set the configuration of st2web.
It was released in https://github.com/StackStorm/stackstorm-ha/releases/tag/v0.52.0.
Here is the description in values.yaml how to use it: https://github.com/StackStorm/stackstorm-ha/blob/89be5cdc65beba7155140594118dbda1fef23356/values.yaml#L250

For your use-case the variables could be e.g.:

(...)
st2web:
  (...)
  config: |
    'use strict';

    /* global angular */
    angular.module('main')
      .constant('st2Config', {

        hosts: [
          {
            name: 'test',
            url: 'https://stackstorm.dev.com/st1/api',
            auth: 'https://stackstorm.dev.com/st1/auth',
            stream: 'https://stackstorm.dev.com/st1/stream',
          }
        ]

      });

@cognifloyd
Copy link
Member

@wantdrink does #145 (comment) resolve your issues?

@cognifloyd
Copy link
Member

@wantdrink I'm going to close this. Please reopen if you still have a question about this.

@wantdrink
Copy link
Author

Thanks a lot @moonrail & @cognifloyd , that really helps!

@wantdrink
Copy link
Author

wantdrink commented Jan 2, 2022

@moonrail, Furthermore in the latest 0.8.0 what we have to do is to change it as:

st2web:  
  replicas: 2
  ......
  extra_volumes: []
    # see examples under st2workflowengine.extra_volumes
  # User-defined st2web config with custom settings to replace default config.js
  # See https://github.com/StackStorm/st2web#connecting-to-st2-server for more info

  # config: |
  #  // see https://github.com/StackStorm/st2web/blob/master/config.js
  config: |
    'use strict';

    /* global angular */
    angular.module('main')
      .constant('st2Config', {

        hosts: [
          {
            name: 'stackstorm.dev.com',
            url: 'https://stackstorm.dev.com/st1/api',
            auth: 'https://stackstorm.dev.com/st1/auth',
            stream: 'https://stackstorm.dev.com/st1/stream',
          }
        ]

      });

  # postStartScript is optional. It has the contents of a bash script.
  # k8s will run the script in the st2 container in parallel with the ENTRYPOINT.
  # The pod will not be marked as "running" until this script completes successfully.
  # see: https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/
  postStartScript: ""
  ......

and in the ingress still needs to configure rewrite below? Thanks a lot.

ingress:
  enabled: true
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /$2
    nginx.ingress.kubernetes.io/force-ssl-redirect: "true"
  hosts:
    - host: stackstorm.dev.com
      paths:
        - path: /st1(/|$)(.*)
          serviceName: st1-st2web
          servicePort: 80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants