# Executing ESB artifacts on Kubernetes

Available in...

* Cloud API Services Platform
* Cloud Data Fabric
* Data Fabric
* Data Services Platform
* ESB
* Qlik Cloud Enterprise Edition
* Qlik Talend Cloud Enterprise Edition
* Qlik Talend Cloud Premium Edition
* Real-Time Big Data Platform

## Before you begin

Make sure you have a Kubernetes cluster configured and running.

## Procedure

1. Create a demorestroute.yaml configuration file as follows to deploy the DemoRESTRoute artifact.
   ```
   # Kubernetes DemoRESTRoute deployment
   apiVersion: v1
   kind: Service
   metadata:
     name: demorestroute
     labels:
       app: demorestroute
   spec:
     ports:
       - port: 8065
         targetPort: 8065
         name: http-demorestroute
     selector:
       app: demorestroute
   ---
   apiVersion: apps/v1
   kind: Deployment
   metadata:
     name: demorestroute
   spec:
     replicas: 1
     selector:
       matchLabels:
         app: demorestroute
     template:
       metadata:
         labels:
           app: demorestroute
   #        version: v1
       spec:
         containers:
         - name: demorestroute
           image: <ARTIFACT_REPOSITORY_DOCKER_REGISTRY>/<STUDIO_PROJECT>/demorestroute:latest
           imagePullPolicy: IfNotPresent
           args: 
             - "--name=1111"
           ports:
           - containerPort: 8065
   ---
   ```

   where
   * &lt;ARTIFACT\_REPOSITORY\_DOCKER\_REGISTRY&gt; corresponds to the host of the URL of the artifact repository Docker registry (Nexus, Artifactory)
   * &lt;STUDIO\_PROJECT&gt; corresponds to the Talend Studio project name that is the same as the Git project name. Project names must be in upper case.
   * ```
     args: 
       - "--name=1111"
     ```

     corresponds to the Docker or Kubernetes context parameters that can be changed according to your deployment needs. This way of calling context parameters for Docker and Kubernetes is different from the one used for other types of context parameters (see [Changing context parameters in Jobs and Routes](https://help.qlik.com/talend/en-US/studio-user-guide/8.0/changing-context-parameters-in-jobs-and-routes)).
2. Execute the kubectl apply -f demorestroute.yaml command to deploy the artifact to Kubernetes.
   ### Example
   ```
   $ kubectl apply -f demorestroute.yaml
   		service/demorestroute created
   		deployment.extensions/demorestroute-v1 created
   ```
3. Execute the kubectl get po command to check that the Kubernetes pod is up and running.
   ### Example
   ```
   $ kubectl get po
   NAME                                READY   STATUS    RESTARTS   AGE
   demorestroute-v1-6c4dc67648-z6zh7   1/1     Running   0          8s
   ```
4. Access the endpoint in a browser, an XML document is returned.
   ### Example

   http://localhost:&lt;MACHINE\_PORT&gt;/services/customers
5. Execute the kubectl delete -f demorestroute.yaml command to clean the Kubernetes pod after deploying the artifact.
   ### Example
   ```
   $ kubectl delete -f demorestroute.yaml
   service "demorestroute" deleted
   deployment.extensions "demorestroute-v1" deleted
   ```