Tool:Iw

From Wikitech
Jump to navigation Jump to search
Toolforge tools
Crystal Clear app package utilities.png
Description Redirect to Toolforge tools
Keywords interwiki
Maintainer(s) BryanDavis (View all)
License GNU General Public License 3.0 or later
Admin log Tools.iw/SAL

Iw is a redirection service designed to be used for creating interwiki links to Toolforge tools.

Interwiki links are used in many Wikimedia wikis including Wikitech to create links to Toolforge tools. The interwiki system is prefix based and does not currently robustly support a single interwiki prefix targeting multiple hosts. This creates a problem for migration of Toolforge tools from path based routing (https://tools.wmflabs.org/$TOOL) to host based routing (https://$TOOL.toolforge.org/). The iw tool is an attempt to bridge this gap by providing a prefix (https://iw.toolforge.org/) with a backend that will redirect to other Toolforge tools.

On-wiki usage

TODO: document how to setup interwiki prefix and use from wikitext

Tool setup

Iw is an Ingress only tool running on Toolforge's 2020 Kubernetes cluster. "Ingress only" means that the tool does not run any application code, but instead does all of its work using Kubernetes Ingress objects to configure the Kubernetes cluster's nginx ingress controller.

$ ssh login.toolforge.org
$ become iw
$ vim ingress.yaml
$ kubectl apply --validate=true -f ingress.yaml
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: iw-legacy
  namespace: tool-iw
  labels:
    name: iw-legacy
  annotations:
    kubernetes.io/ingress.class: nginx
    # Redirect to the path based route for the target tool at tools.wmflabs.org
    nginx.ingress.kubernetes.io/permanent-redirect: https://tools.wmflabs.org/$2
spec:
  rules:
    - host: tools.wmflabs.org
      http:
        paths:
          - backend:
              serviceName: unused
              servicePort: 8000
            path: /iw(/|$)(.*)
            # Example path: /iw/bash/random
            # Captures:
            # $0 == /iw/bash/random
            # $1 == /
            # $2 == bash/random
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: iw-domain
  namespace: tool-iw
  labels:
    name: iw-domain
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/use-regex: "true"
    # Redirect to the host based route for the target tool at *.toolforge.org
    nginx.ingress.kubernetes.io/temporal-redirect: https://$1.toolforge.org/$3
spec:
  rules:
    - host: iw.toolforge.org
      http:
        paths:
          - backend:
              serviceName: unused
              servicePort: 8000
            path: /([^/]+)(/|$)(.*)
            # Example path: /bash/random
            # Captures:
            # $0 == /bash/random
            # $1 == bash
            # $2 == /
            # $3 == random