Deploy FusionExport inside a Kubernetes Cluster

In this article, we will talk about how you can deploy fusionexport inside a Kubernetes cluster.
About FusionExport
FusionExport, allows you to export your dashboards to images and PDFs. The exported files can be used for sending emails, attachments, and printable documents. It supports formats like PNG and JPG and vector formats like SVG and PDF.
For more info please visit here — https://www.fusioncharts.com/dev/exporting-charts/using-fusionexport/overview
Creating Kubernetes manifest file
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: fe-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: fe
name: fe
spec:
selector:
matchLabels:
app: fe
template:
metadata:
labels:
app: fe
spec:
securityContext:
fsGroup: 472
supplementalGroups:
- 0
containers:
- name: fusionexport
image: zapdos13/fusionexport_server
imagePullPolicy: IfNotPresent
ports:
- containerPort: 1337
name: localhost
protocol: TCP
readinessProbe:
failureThreshold: 3
httpGet:
path: /robots.txt
port: 1337
scheme: HTTP
initialDelaySeconds: 10
periodSeconds: 30
successThreshold: 1
timeoutSeconds: 2
livenessProbe:
failureThreshold: 3
initialDelaySeconds: 30
periodSeconds: 10
successThreshold: 1
tcpSocket:
port: 1337
timeoutSeconds: 1
resources:
requests:
cpu: 250m
memory: 750Mi
volumeMounts:
- mountPath: /var/lib/fe
name: fe-pv
volumes:
- name: fe-pv
persistentVolumeClaim:
claimName: fe-pvc
---
apiVersion: v1
kind: Service
metadata:
name: fe
spec:
ports:
- port: 1337
protocol: TCP
targetPort: localhost
selector:
app: fe
sessionAffinity: None
type: LoadBalancer
I have built & deployed the fusionexport image in my docker hub — https://hub.docker.com/r/zapdos13/fusionexport_server
Send the manifest to the Kubernetes API server
- Run the following command:
kubectl apply -f <file_name>.yaml -n <namespace_name>
- Check that it worked by running the following:
kubectl port-forward service/fe 1337:1337 -n <namespace_name>
- Navigate to
127.0.0.1:1337
in your browser. You should see a fusionexport service running.

Exporting a chart
I am using a node js app to interact with the service and export a pdf file.
// Exporting a chart
const path = require("path");
// Require FusionExport
const { ExportManager, ExportConfig } = require("../");
// Instantiate ExportManager
const exportManager = new ExportManager();
// Instantiate ExportConfig and add the required configurations
const exportConfig = new ExportConfig();
exportConfig.set("chartConfig", path.join(__dirname, "resources", "single.json"));
// provide the export config
exportManager
.export(exportConfig, ".", true)
.then(exportedFiles => {
exportedFiles.forEach(file => console.log(file));
})
.catch(err => {
console.log(err);
});
The above file generated an exported PDF file —

Here are the logs of the pod when the export request is sent to the service —
kubectl logs <pod_name> -n <namespace_name>

Conclusion
Hope this article will help deploy fusionexport in Kubernetes with ease, reach out to fusioncharts team for more details regarding fusioncharts & fusionexport at support@fusioncharts.com