Skip to content

fax4ever/image-caption-generation

Repository files navigation

Image Caption Generation

See extra documentation here In particular to see how set up an Ingress controller

Build and deploy cycle

The parts from 7 to 12 can be skipped if you don't want update the container images The part 15 is only to apply some changes to the cluster if you redeploy and publish a new image of the application

  1. Update the source code
git pull
  1. Make image-caption-generation the working namespace
kubectl config set-context --current --namespace=image-caption-generation
  1. Remove any previous deployment
kubectl delete namespace image-caption-generation
  1. Recreate an empty namespace for the new deployment
kubectl create namespace image-caption-generation
  1. Install RabbitMQ. Notice that you need to install the bitnami repository before.
helm install -f rabbitmq.yaml -n image-caption-generation img-rabbitmq bitnami/rabbitmq --version 12.12.0
  1. Install Infinispan. Notice that you need to install openshift repository before.
helm install -f infinispan.yaml -n image-caption-generation infinispan openshift/infinispan --version 0.3.2
  1. Optionally Create some port forwarding

For instance if the Kubernetes does not have a LoadBalancer service.

kubectl port-forward services/img-rabbitmq 15672
kubectl port-forward services/infinispan 11222
  1. Optionally Compile the Java/Quarkus gallery service:
mvn -f ./gallery/pom.xml clean package
  1. Optionally Compile the Java/Quarkus user service:
mvn -f ./users/pom.xml clean package
  1. Optionally Compile the Angular web application:

[./webapp/] <-- run from this subdir

ng build --configuration production
  1. Optionally Build the Docker images locally:
docker-compose build
  1. Optionally Push the Docker images to the Docker remote repository:
docker-compose push
  1. Deploy the application, Kubernetes will pull the images from the remote repository:
kubectl apply -f kubernetes.yaml
  1. See all the pods starting...
kubectl get pods -w
  1. Optionally redeploy a service
kubectl rollout restart deployment caption

Play with the App

This demo is executable without the need of a webapp implemented.

  1. Crate users
http POST http://localhost/users/user <<<'{"name":"norman", "pass":"norman", "pro":true}'
http POST http://localhost/users/user <<<'{"name":"victor", "pass":"victor", "pro":false}'
  1. Verify login service
http POST http://localhost/users/user/validate <<<'{"username":"fabio", "password":"fabio"}'
http POST http://localhost/users/user/validate <<<'{"username":"norman", "password":"wrong"}'
http POST http://localhost/users/user/validate <<<'{"username":"norman", "password":"norman"}'
http POST http://localhost/users/user/validate <<<'{"username":"victor", "password":"victor"}'
  1. Publish images

Go to the page http://localhost/caption/new-image/norman and insert some images In this case the images are generated for the user norman.

Go to the page http://localhost/caption/new-image/victor and insert some images In this case the images are generated for the user victor.

  1. Verify that images are stored and are retrievable from the caption service.

Go to the page http://localhost/caption/image/victor/empire-state-building.png

  1. Find all images belonging to norman / victor
http http://localhost/gallery/image/user/norman
http http://localhost/gallery/image/user/victor
  1. Find all images having a capture containing the term cat / clock
http http://localhost/gallery/image/caption/cat
http http://localhost/gallery/image/caption/clock
  1. Test that the webapp is reachable

Navigate to http://localhost/