Before you begin
Make sure you have a Kubernetes cluster configured and running.
Procedure
-
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: <MACHINE_PORT>
targetPort: 8065
name: http-demorestroute
selector:
app : demorestroute
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: demorestroute-v1
spec:
replicas: 1
template:
metadata:
labels:
app : demorestroute
version: v1
spec:
containers:
- name: demorestroute
image: <ARTIFACT_REPOSITORY_DOCKER_REGISTRY>/<STUDIO_PROJECT>/demorestroute:latest
imagePullPolicy: IfNotPresent
ports:
- containerPort: 8065
---
where
-
<MACHINE_PORT> corresponds to the port used
to bind the host port to the container port
-
<ARTIFACT_REPOSITORY_DOCKER_REGISTRY>
corresponds to the host of the URL of the artifact repository Docker
registry (Nexus, Artifactory)
-
<STUDIO_PROJECT> corresponds to the Talend Studio project name that is the same
as the Git project name. Project names must be in upper case.
-
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
-
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
-
Access the endpoint in a browser, an XML document is returned.
Example
http://localhost:<MACHINE_PORT>/services/customers
-
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