Accessibility as a service with Kubernetes and The A11y Machine

Overview

Recently I found a really cool project for running accessibility scans against websites, but heres the kicker, it generates a really snazzy report once it is complete.

Given my itch to automate everything, I decided to wrap it in some Kubernetes goodness.

The key Kubernetes components used for this implementation are:

For this post we will use the http://kubernetes.io site as our example target.

Job

The following definition will:

apiVersion: batch/v1
kind: Job
metadata:
  name: a11y
spec:
  template:
    metadata:
      name: a11y-generate
    spec:
      containers:
      - name: a11ym
        image: nickschuch/the-a11y-machine
        command: ["a11ym",  "http://kubernetes.io", "-o", "/var/output"]
        volumeMounts:
        - name: report
          mountPath: "/var/output"
      volumes:
      - name: report
        hostPath:
          path: "/tmp/report"
      restartPolicy: OnFailure
# https://raw.githubusercontent.com/nickschuch/blog-kube-a11y/master/a11y-job.yaml
$ kubectl create -f a11y-job.yaml

Replication Controller

The following definition will consume our report, from the persistent storage, and expose it with Nginx.

apiVersion: v1
kind: ReplicationController
metadata:
  name: a11y
spec:
  replicas: 1
  selector:
    app: a11y-frontend
  template:
    metadata:
      name: a11y-frontend
      labels:
        app: a11y-frontend
    spec:
      containers:
      - name: report-frontend
        image: nginx
        volumeMounts:
        - name: report
          mountPath: "/usr/share/nginx/html"
      volumes:
      - name: report
        hostPath:
          path: "/tmp/report"
# https://raw.githubusercontent.com/nickschuch/blog-kube-a11y/master/a11y-rc.yaml
$ kubectl create -f a11y-rc.yaml

Service

Finally, we now need to expose our report outside of the internal Kubernetes network. The following definition will make our report available on:

apiVersion: v1
kind: Service
metadata:
  name: a11y
spec:
  selector:
    app: a11y-frontend
  ports:
  - name: http
    protocol: TCP
    port: 80
    nodePort: 30061
  type: LoadBalancer
# https://raw.githubusercontent.com/nickschuch/blog-kube-a11y/master/a11y-svc.yaml
$ kubectl create -f a11y-svc.yaml

Conclusion

For the small amount of time it has taken me to put this together, I feel I have yielded some big results.

Below is the outcome from my quick scan of the https://kubernetes.io site.

Limitations in the current design