This example code is taken from Spring Boot CRUD Example with RESTful APIs, JPA, Hibernate, MySQL, Lombok, FreeMarker and VueJS
The CNDE runs like a normal Pod within the Kubernetes cluster. Therefore it is possible that all applications you start can be accessed by a Kubernetes Service resource.
Since this demo exposes port 8888 the Service looks like this:
apiVersion: v1
kind: Service
metadata:
name: product-web-test
spec:
selector:
app: code-server
user-env-name: norbert
ports:
- protocol: TCP
port: 8888
(The service' selector points to the running CNDE Pod with the Username Norbert
)
To test the Web-application we want to create in this demo, we additionally need an Ingress resource to make the service available on the Internet:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
kubernetes.io/tls-acme: "true"
name: product-web
spec:
rules:
- host: product.norbert.kubeplatform.ch.innoq.io
http:
paths:
- backend:
serviceName: product-web-test
servicePort: 8888
path: /
tls:
- hosts:
- product.norbert.kubeplatform.ch.innoq.io
secretName: norbert-product-web-tls
This can be done for every application, that is running inside your CNDE.
-
Clone the demo repository with
[git clone https://github.com/Cloud-Native-Coding/cnde-example-springboot-crud-mysql-vuejs.git
-
In folder
config
executek apply -k .
to install required Kubernetes resources -
Install Java
sudo apt update sudo apt install default-jdk maven
-
Install VS-Code extensions:
Java IDE Pack
,Kubernetes Support
-
Run Application with
mvn clean spring-boot:run
-
Move Browser to
product.norbert.kubeplatform.ch.innoq.io
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose up
head again to product.norbert.kubeplatform.ch.innoq.io