img is a highly scalable version of imaginary, that uses cloud native services such as Kubernetes, HPA, Varnish Cache, Ngninx and Prometheus technologies to deploy a service on demand and a large-scale solution for massive image processing.
Refer to the imaginary repository for supported image operations and additional configuration.
IMG runs in high availability mode using multiple Varnish and application pods.
┌────────────┐
│ │
┌────► imaginary │
│ │ │
┌────────────┐ ┌────────────┐ ┌────────────┐ │ └────────────┘
│ │ │ │ │ │ │
│ Ingress ──┼──►│ Varnish ├────►│ Balancer ─┼─┤
│ │ │ │ │ │ │ ┌────────────┐
└────────────┘ └────────────┘ └────────────┘ │ │ │
└────► imaginary │
│ │
└────────────┘
You may want to edit ansible/playbooks/install_img.yaml to match your domain name just change this:
role: ansible-imaginary
vars:
server_domain_names=[www.example.com]
role: ansible-prometheus
To this:
roles:
role: ansible-imaginary
vars:
server_domain_names=[YOUR_SERVER_NAME]
role: ansible-prometheus
ansible-playbook -u root image-service/ansible/playbooks/install_img.yamlansible-playbook -u root -i inventory_file_with_server_info ansible/playbooks/install_img.yamlThe following tables lists optional ansible variables along with the default values if not defined.
| Variable Name | Default value if not defined | Description |
|---|---|---|
| INSTALL_K3S | true | installs k3s for you |
| INSTALL_NGINX_INGRESS | true | installs the nginx ingress |
| imaginary_cpus | 4 | number of cpus imaginary uses |
| imaginary_cpu | 1600m | |
| min_replicas | 2 | minimum number of replicas imaginary creates |
| max_replicas | 6 | maximum number of replicas imaginary can create |
| cache_size | 128m | the varnish cache size |
| imaginary_port | 9000 | The port used by imaginary internally |
| server_domain_names | None | domain name to use such as [www.example.com] |
| allowed_origins | None | If set limits the origins used by imaginary |
| Variable Name | Default value if not defined | Description |
|---|---|---|
| UPGRADE_NGINX_INGRESS | true | installs or upgrades nginx to work with prometheus |
| prometheus_release_name | monitoring | the name used for prometheus stack pods |
| prometheus_namespace | monitoring | the namespace the prometheus stack installs under |
To test our local image, let's process a file. In this case, we're going to crop an existing image from Imaginary's github repository.
curl -O "http://localhost:8080/crop?width=500&height=400&url=https://raw.githubusercontent.com/h2non/imaginary/master/testdata/large.jpg"
This will ask Imaginary to crop, to 100x100, an image stored in the Imaginary Github repository. This should result in a file, large.jpg being written to disc which you can display using your preferred image viewer. MacOS users can simply open large.jpg at the command line.