Skip to content

Commit

Permalink
Updated java workshop and converted to hugo
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemoralespou committed Dec 12, 2023
1 parent f8e4b1e commit 9567e8d
Show file tree
Hide file tree
Showing 9 changed files with 174 additions and 20 deletions.
Empty file.
57 changes: 56 additions & 1 deletion workshops/lab-java-environment/resources/workshop.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@ spec:
includePaths:
- /resources/**
- /workshop/**
- /exercises/**
- path: .m2
image:
url: ghcr.io/vmware-tanzu-labs/lab-spring-boot-on-k8s-maven:latest
session:
namespaces:
budget: medium
budget: large
resources:
memory: 2Gi
applications:
terminal:
enabled: true
Expand All @@ -27,3 +33,52 @@ spec:
enabled: true
files:
enabled: true
dashboards:
- name: Initializr
url: $(ingress_protocol)://initializr-$(session_namespace).$(ingress_domain)
ingresses:
- name: initializr
protocol: http
host: initializr.$(workshop_namespace).svc.cluster.local
port: 8080
environment:
objects:
- apiVersion: apps/v1
kind: Deployment
metadata:
name: initializr
labels:
app: initializr
spec:
replicas: 1
selector:
matchLabels:
app: initializr
template:
metadata:
labels:
app: initializr
spec:
containers:
- name: dashboard
image: ghcr.io/vmware-tanzu-labs/educates-spring-initializr:2.2.0
imagePullPolicy: Always
ports:
- name: 8080-tcp
containerPort: 8080
protocol: TCP
- apiVersion: v1
kind: Service
metadata:
name: initializr
labels:
app: initializr
spec:
type: ClusterIP
selector:
app: initializr
ports:
- name: 8080-tcp
port: 8080
protocol: TCP
targetPort: 8080
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
This is the initial landing page for your workshop. Include in this page a description of what your workshop is about.
+++
title = 'Workshop Overview'
+++

The Educates training platform is a Kubernetes native application which provides
time limited sandboxes for hosted workshop environments.

This series of workshops demonstrates the capabilities of the Educates training
platform and how it can be used.

In this initial workshop you will find available Java capabilities.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
+++
title = 'Creating an application'
+++

During this workshop we will be using the command line as well as the embedded editor. The editor takes a few moments to start up and be ready, so select the **Editor** tab now to display it, or click on the action block below.

```dashboard:open-dashboard
name: Editor
```

The first thing we need to do is create a Spring Boot application. To do this we are going to to use the `Spring Initializr` web site.

The purpose of the Spring Initializr web site is to allow you to enter in details about the Spring Boot application you want to create. This includes the name of the application, the tooling you want to use, and any dependencies. When you click on generate it will automatically start a download of application source code for a Spring Boot application satisfying those requirements. You can then unpack that on your local computer and start working.

Normally to do this you would go to [start.spring.io](https://start.spring.io/), however for this workshop we have integrated the web site into a tab of the workshop session dashboard. This is done so that rather than downloading the Spring Boot application you create with it to your own local machine, it will download it into the workshop environment.

Select the **Initializr** tab in the workshop session dashboard.

```dashboard:open-dashboard
name: Initializr
```

For this workshop environment you must ensure Java 17 is selected under the project metadata on Spring Initializr.

Because of later commands we will run, we also want to generate a Maven project rather Gradle, so click on **Maven** under the **Project** category to select it.

You can leave as is the other defaults for the project metadata as the workshop is scripted to already expect the project name to be `demo`.

Now click on **Add Dependencies**, search for `Spring Reactive Web` and add it.

Click again on **Add Dependencies** and this time search for `Spring Boot Actuator` and add it.

We are ready to generate the Spring Boot application code. Remember you need to be using the Spring Initializr integrated into the workshop session dashboard.

Click on **Create**.

This should send you back to the terminal and you can see where the Spring Boot application was downloaded and extracted into the workshop environment.

You can see the result by running:

```terminal:execute
command: tree demo
```

To verify that the application code has been generated successfully, open up the main Java source code file for the application.

```editor:open-file
file: ~/exercises/demo/src/main/java/com/example/demo/DemoApplication.java
```

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
+++
title = 'Building the application'
+++

We are now ready to build the application source code. We will first do this direct into the local directory.

Change to the `demo` sub directory.

```terminal:execute
command: cd ~/exercises/demo
```

Then run Maven to start the build.

```terminal:execute
command: ./mvnw install
```

> NOTE: It can take a couple of minutes the first time, but once the dependencies are all cached, subsequent builds would be faster.
When the build has completed, build artefacts including the application JAR file, can be found in the `target` sub directory.

```terminal:execute
command: tree target
```

To test that the application works, run Java with the application JAR file:

```terminal:execute
command: java -jar target/*.jar
```
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
This is the last page of the workshop. Include in this page a summary of the workshop and any links to resources relevant to the workshop. This ensures anyone doing the workshop has material they can research later to learn more.
+++
title = 'Workshop Summary'
+++

This is the end of the workshop. The Educates workshop resource definition for
this workshop can be viewed by clicking:

```dashboard:create-dashboard
name: Resource
prefix: Workshop
title: View workshop definition
description: ""
url: /files/resources/workshop.yaml
```

The source code repository for this series of workshops showcasing the Educates
training platform can be found at:

```dashboard:open-url
url: https://github.com/educates/labs-educates-showcase
```

Documentation for Educates can be found at:

```dashboard:open-url
url: https://docs.educates.dev/
```
9 changes: 0 additions & 9 deletions workshops/lab-java-environment/workshop/modules.yaml

This file was deleted.

7 changes: 0 additions & 7 deletions workshops/lab-java-environment/workshop/workshop.yaml

This file was deleted.

0 comments on commit 9567e8d

Please sign in to comment.