Containerization using Docker containers is designed to run servers on physical as well as virtual machines, cloud clusters, public instances etc. Fiorano supports containerization, hence enhancing scalability, high availability, sharing of workload and application deployment.
The Fiorano Servers are containerized in a docker image for easy deployment and scaling at the user end. Docker containers wrap up the servers and their environment without the need for initial environment configuration. Kubernetes is used as a container orchestration tool for deploying the Fiorano SOA in a cluster while managing load balancing and also increasing fault tolerance. Fiorano SOA is compressed as an image and then deployed on to the Kubernetes cluster.
This section illustrates deploying Fiorano API servers in a Kubernetes cluster using Minikube.
Installing Fiorano platform and making changes in the installer
- Click the link below, download the latest Fiorano Installer and install the same:
https://www.fiorano.com/resources/product_downloads - Use ConfigDeployer from $FioranoHome/esb/tools to set up AGS server1 profile by modifying Cassandra DataStore URL, FESPrimary URL, FESSecondary URL with the customized IP (IP refers to the Cluster IP in Kubernetes which redirects requests to the pods in a deployment) 10.96.0.20 and the ports 9042, 2147 and 2148 respectively.
- The postgres driver must be added to the $FioranoHome/esb/server/bin/server.conf as "/postgresql-9.1-902.jdbc4.jar" in the Fiorano Sources for postgres to connect.
- Extract the stripInstaller.tar.gz and run the script in the format as mentioned in the Readme file to reduce the size of the installer.
- Place a copy of the installer in the folder ams_build and ags_build to create separate AGS and AMS images.
- Refer to the Creating Docker Image from the Fiorano setup and make changes in the dockerfile as necessary.
Installing Docker
For Debian-based Linux systems
Install Dependency packages
Add Docker's official GPG key:
Add the Docker repository
Install Docker Engine and Docker Compose
Add a user to the group to run docker commands as a nonprivileged user.
- Log out and log back in so that the group membership is re-evaluated.
Creating a Docker Image from the Fiorano setup
Create a folder with the following structure and place Dockerfile
- Working directory
- Fiorano
- 12.1.0
- Dockerfile
- Postgres Driver
- Fiorano
Contents of DockerFile:
For creating ESB servers
To create docker image of AMS servers
To create docker image of AGS servers
Create the docker image from the setup
Open the terminal to the folder with dockerfile and execute the command:
Save the docker image to a tar file
Likewise, docker images can be built and saved for Fiorano AGS, AMS and ESB servers as per requirement.
References and Side Note for docker
Purpose | Command |
---|---|
To pull Cassandra and postgres images Images can be saved as mentioned in the section above. | docker pull cassandra |
To remove all stopped containers, all dangling images, and all unused networks | docker system prune |
To lists all containers | docker ps -a |
To list all docker images | docker images |
To remove all dangling images | docker image prune |
To remove all images | docker image prune -a |
Kubernetes Cluster Setup on Local System
Installing Virtual Box
Download the virtual box from https://www.virtualbox.org/wiki/Downloads
Installing Minikube (for Debian-based Linux)
Install and setup kubectl
Install Minikube
Start Minikube and check
Starting local Kubernetes v1.10.0 cluster...
Starting VM...
Downloading Minikube ISO
171.87 MB / 171.87 MB [============================================] 100.00% 0s
Getting VM IP address...
Moving files into cluster...
Downloading kubeadm v1.10.0
Downloading kubelet v1.10.0
Finished Downloading kubelet v1.10.0
Finished Downloading kubeadm v1.10.0
Setting up certs...
Connecting to cluster...
Setting up kubeconfig...
Starting cluster components...
Kubectl is now configured to use the cluster.
Loading cached images from config file.
Setting up a Kubernetes cluster
Set up a Network File System for persisting data
- Install nfs-server in the host machine and nfs-client in the client machine to access the files.
To link a host directory to mount point, edit /etc/fstab and then give the command below:
- To mount a directory, edit /etc/exports and set the directory.
Use the command below to export all directories mentioned in the /etc/exports:
Check if it is mounted successfully using the command below:
Start Minikube
For Windows 10 Professional Edition
- Install Chocolatey package manager for ease.
- Enable Hyper-V from Windows Features
Using chocolatey, install kubernetes-cli using the command:
Using chocolatey, install minikube using the command:
- To set where the VM needs to be created, add MINIKUBE_HOME=<pathofVMdir> to system properties.
- After it creates VM in the path, configure Hyper-V Switch Manager to allow internet access for the VM.
Start minikube vm using the command:
For Debian based Linux
Start minikube and set up resources as per requirement
Open dashboard using the command:
Minikube file setup
Ssh into the VM
Set user permissions in the data folder in minikube
Also note the <VM_IP> of the minikube node
Transfer the .tar files saved from docker
The tar file can be copied using scp command
Load the docker images
Load the cassandra, postgres, AMS and AGS images
Enable port-forwarding in the minikube
Create a script with contents as below and execute the script to open port forwarding:
Restart the minikube with existing configurations
Execute the yaml files in the order mentioned below
services.yaml file contains the ports required to be exposed by the node for AMS servers and database while also taking care of directing requests. It is of type NodePort and has cluster IP 10.96.0.20
ags-services.yaml contains the ports for accessing resource created by a project. It is of type LoadBalancer and has cluster IP 10.96.0.30
Set the login credentials for postgres comprising of username, password in postgres-config.yaml
Create persistent volumes and their respective claims for Cassandra, Postgres and Fiorano AMS runtimedata.
Create deployment for multicontainer pods containing Fiorano AMS and databases.
Wait for 5 minutes to get all the containers running and the workloads to turn green from yellow which means deployments are successful.
Check if deployment successful by opening the apimgmt dashboard in the browser.
Common causes of deployment failure:- Fiorano Installer License Expiry
- Unable to link to the persistent volume which may be due to unavailability of NFS-server
- Ensure that the docker image is loaded in minikube ssh and the docker image name correctly corresponds in the yaml file.
Create a stateful set for AGS servers. ( Ensure port forwarding has been enabled in VM before this step)
Login to the API management dashboard and check for the servers ags_0 etc. available in the server group - serverGroup1.
Deploy projects and check the accessibility of the resource hosted by the gateway servers by changing the IP to localhost:2160
Scaling
Manual Scaling
Change the number of replicas manually by clicking "Edit" option in stateful sets in dashboard.
Autoscaling
For auto-scaling add resource request and limit value in AGS stateful sets.
Now stop minikube in current configuration
- Start minikube with the following arguments.
For Debian based Linux:
For Windows:
Enable the metrics-server add on using the following command:
Then wait for some time and create the autoscaler
For system details:For container details:For the above-mentioned autoscaler details:For memory-based autoscaling, create a yaml file with the content below and set targetAverageUtilization in it as per requirement:
To deploy this autoscaler use the command below:
Use kubectl describe hpa to see what its doing
To delete hpa, use:
Kubernetes Cluster Setup on Google Cloud with Istio
Creating Kubernetes Cluster on Google Cloud
Login and Select Kubernetes Engine on Google Cloud Platform
Create a cluster by running the following command on cloud shell
Retrieve your credentials for kubectl
Grant cluster administrator (admin) permissions to the current user
To create the necessary RBAC rules for Istio, the current user requires admin permissions.
Configuring Istio
Downloading Istio
Go to the Istio release page to download the installation file for your OS, or download and extract the latest release automatically (Linux or macOS) as mentioned in https://istio.io/docs/setup/getting-started/
Run the following in the cloud shell
Adding istioctl client to your cloud system path
Configuring Istio Profile
For this installation, we use the demo configuration profile. It’s selected to have a good set of defaults for testing along with dashboards like kiali, prometheus etc.
Configuring Istio Namespace to allow injection
Add a namespace label to instruct Istio to automatically inject Envoy sidecar proxies when you deploy your application later
Configuration changes to Fiorano installer for cloud setup
In the Fiorano Latest installer, change the IP for Cassandra, Primary and Secondary URL as 10.35.240.20 (configured cluster IP for AMS) in config deployer in for server1 profile AGS.
Configuring the Docker image
- Upload the tar files created for AMS and AGS compressed as zip to the google cloud console, after upload extract the same.
- Change directory and go to the directory containing the docker images using cloud shell
Run the following code blocks to load docker images to the cloud docker
Add Cred Helper
Add the Docker credHelper entry to Docker's configuration file, or creates the file if it doesn't exist. This will register gcloud as the credential helper for all Google-supported Docker registries. ( refer to https://cloud.google.com/container-registry/docs/pushing-and-pulling)Create tags with registry name
ExamplePush the tagged images to container registry
Example
Create Persistent Volume Claims
Run the following command to execute the yaml files for persistent volume claim configuration, please navigate to the folder containing the yamls before executing
Configure Postgres Login
Apply the postgres configuration file for login credentials
The template of the file can be found here.
Create the load balancer services
Load Balancer configuration for AMS
Sample services.yaml can be found here
Load Balancer Configuration for AGS
Sample ags-services.yaml can be found here
Configuring Ingress hosts and ports
Create AMS, Cassandra and postgres deployment
Sample yaml file can be found here.
Create AGS stateful set deployment
Sample yaml file can be found here.
Create the kubernetes gateway service to access services outside a cluster
Sample yaml file can be found here.
Create the kubernetes virtual services which would specify host URI
Click the file names to get sample virtual.yaml and resource.yaml files
To check INGRESS_HOST and PORT give the following command in cloud shell