Skip to content

Commit

Permalink
Merge pull request #7 from vivoit00/develop
Browse files Browse the repository at this point in the history
Project (almost) finished
  • Loading branch information
vivoit00 committed Jun 22, 2024
2 parents 67672b3 + 3a32937 commit 6731daf
Show file tree
Hide file tree
Showing 47 changed files with 231 additions and 1,896 deletions.
194 changes: 46 additions & 148 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,171 +1,69 @@
# 2024-March-11 Cloud and Semester Introduction
# Todo Application Setup Guide

## Initial Brainstorming Session - Technologies and Motivators for Distributed Systems
## Overview

![Brainstorming](/pics/2024-03-11-DistributedSystemsBrainstorm.png)
Application with a Thymeleaf Frontend, Django Backend and PostgreSQL Database.

### Content

* Why distributed systems, why container, why modern software?
* What is Cloud Computing? Encounters in everyday life and history
* Characteristic, advantages & challenges
* Terminology - public, private, hybrid, dedicated
* Abstraction layers - IaaS, PaaS, FaaS, SaaS
* Overview - Hypervisors, virtual machines, containers and orchestration

### Objectives and exercises
_The student is able to describe the reasons for distributed systems and
cloud computing in own words and list examples for offerings, topologies and technologies. Includes ability to differentiate between different abstraction layers and knowledge how those layers and according technologies interact with each other. No exercises in this module_

### Student Questions
## Steps to Run

* What is Polyglot Software Development?
* What did the role of containers change for polyglot software?
* Security and Cloud - is it safe? :-)
1. Clone the repository:

![Polyglot Container](/pics/2024-03-11-ContainerVsTraditional.png)
```sh
git clone https://github.com/vivoit00/PuVS-to-do-list
cd PuVS-to-do-list/sample/otel-in-action
git checkout develop
```

### Outlook for Labs
2. Build and run the containers:

* Distributed app
* Polyglot implementation
* Containerisation
* Kubernetes
* DevOps/CICD/Observability (optional)
```sh
docker-compose up --build
```

![Exercise Tech Stack](/pics/2024-03-11-Blackboard.jpg)
3. Access the services:
- Django Backend: `https://localhost:8080`
- Thymeleaf Frontend: `https://localhost:8090`

### Homework
## Endpoints

* Get a public GitHub, GitLab or Bitbucket account
* Play around with GitHub codespaces and/or Gitpod

# 2024-March-18 Session canceled

# 2024-March-25 Cloud-based IDEs Intro & Docker/Container
### Get All Todos

### Content
* Why do we need Containers?
* Challenges for (polyglot) distributed systems in traditional IT:
- **URL:** `/todos/`
- **Method:** GET
- **Response:** List of todo items in plain text

* Each environment has to be configured manually: Servers as well as local dev environments
* Configuration has to be as identical as possible: minor configuration drifts can lead to errors and the "it runs on my machine" problem
* Polyglot Server Environments are a huge challenge as for each programing language a separate configuration has to be managed on all systems.
* Changing Versions is tedious for local dev environment
### Add a Todo

![image](https://github.com/maeddes/hse-24-summer/assets/22505258/63a76e4b-cd0e-4f9d-8e6e-cb7b364d4581)
- **URL:** `/todos/{toDo}`
- **Method:** POST
- **Path Parameter:**
- `toDo`: The name of the todo item to be added
- **Response:** The added todo item in plain text

* Whereas containerized Applications bring their own Environment and Configuration
* No need to preconfigure the local environment per programming language or application.
* Only the container engine is required to run all kinds of containers.

![image](https://github.com/maeddes/hse-24-summer/assets/22505258/35dfe922-1c43-46db-a419-4c602dd084dc)
### Delete a Todo

* How does the container engine work?
* Layer-based setup of containers
* Container vs Container Image
* How to create a container from application to dockerfile to image to running container
- **URL:** `/todos/{toDo}`
- **Method:** DELETE
- **Path Parameter:**
- `toDo`: The name of the todo item to be deleted
- **Response:** 204 No Content if successful

![image](https://github.com/maeddes/hse-24-summer/assets/22505258/bcad4374-da59-429a-8272-1b42642c888c)
### Example Usage

### Student Questions:
* Do I have to set up, build, and run the dockerfile for each container?
* Can I run multiple applications inside a container?
#### Get all Todos
```sh
curl https://localhost:8080/todos/
```

### Labs
Exercises can be found [here](https://lecture.new.trainings.nvtc.io/basics/container/)
#### Add a Todo
```sh
curl -X POST https://localhost:8080/todos/NewItem
```
## Configuration
The `docker-compose.yaml` file contains all the needed configurations for frontend, backend <br>
and database


# 2024-April-8th Spring Boot Intro & HTTP/REST

## Spring Boot

![Spring Boot typical flow](https://raw.githubusercontent.com/maeddes/hft-2022-winter/main/pics/spring_boot_initializr_flow_2022_10_17.png)

* Background: Spring Framework - History & components
* Spring ← → Spring Boot
* Spring Initializr (start.spring.io) & starter dependencies
* Basic project structure (folders, configuration ..)
* "Hello, World!" example explained
* Using Actuator

### Objectives

The student is able to build and configure an own Spring Boot application from scratch with the IDE of choice. The exercise is to build an own "Hello, World!" application that exposes various - endpoints and is able to execute CRUD operations on the state of the application. Optional: Add logging and testing, configure Actuator.

### Review questions

* "WHY Spring Boot?" Provide 3 advantages of this framework
* Describe Spring Boot to somebody not familiar with it in own words ()
* How do you start building a Spring Boot app? Initializr & Dependencies
* List 4 different starter dependencies and explain briefly what they do (old question) (4P)
"I did not do my lab task with Spring Boot. I implemented using Python and I can tell you how it works there ..."

### Helpful Links:

- https://start.spring.io
- https://www.baeldung.com/spring-requestmapping
- https://www.baeldung.com/spring-boot-actuator-enable-endpoints

## REST

![REST, Controllers, Representations](https://github.com/maeddes/hft-23-winter/blob/main/pics/REST_stuff.png)

* Synchronous communication
* HTTP and REST
* Verbs, Resources, Nouns
* Evolution, Richardson Maturity Model
* CRUD Operations
* Building a REST API with Spring (Boot)
* Building a data model with REST

### Links:

* https://restfulapi.net/idempotent-rest-apis/
* https://restfulapi.net/richardson-maturity-model/
* https://en.wikipedia.org/wiki/List_of_HTTP_status_codes

* https://www.baeldung.com/spring-requestmapping
* https://www.baeldung.com/spring-request-response-body
* https://www.baeldung.com/spring-rest-openapi-documentation
* https://www.baeldung.com/spring-cors

### Review questions

* Identify good and bad API examples and explain why
* Describe the concepts of Verbs and Nouns
* When is an invocation idempotent and safe? What does it mean? Provide examples
* Describe in your own words the mapping of REST calls to database (SQL) and CRUD calls

### Objectives and exercises
_The student understands the concepts of an API and synchronous communication in distributed systems and can explain it in own words._

# 2024-April-15th Distributed Application Sample / Outlook Lab / Docker Advanced topics - TODO :-)

# 2024-April-22nd Cloud-native Software development - Theory part

Cloud-native Software development - Theory part

Theory lecture - Cloud-Native Software

* CAP Theorem
* Conway's Law
* Fallacies of distributed computing
* Domain-Driven Design basics (not relevant for exam)
* 12-factor application
* Evolution of applications and deployments: Monolithic -> Service-Oriented Architecture -> Microservices
* Introduction to serverless and FaaS terminology

### Objectives and exercises
_The student knows about the evolution of distributed systems (and middleware) and the drivers towards state-of-the-art implementation and deployment. She/he can explain the underlying concepts and theories and put it into practical context. No dedicated exercises for this module. Recap of basics: Spring Boot, Docker, configuration._

### Review questions

* "WHY" Cloud-Native Software? What IS Cloud-Native Software?
* Why "evolution" from a monolithic approach to a distributed approach?
* How does the CAP Theorem/Conway's Law relate to this?
* (NO Domain-Driven Design questions)
* How do the 12-factor application "methodology" relate to the technologies that we covered in this semester? (important)
* "WHY" is external configuration important in cloud-native software?
* Where did you see aspects of external configuration in the technologies we used? Provide examples
* What is the advantage of polyglot applications? Why in particular for cloud-native software? What kind of disadvantages do you see?
Binary file removed pics/2024-03-11-Blackboard.jpg
Binary file not shown.
Binary file removed pics/2024-03-11-ContainerVsTraditional.png
Binary file not shown.
Binary file removed pics/2024-03-11-DistributedSystemsBrainstorm.png
Binary file not shown.
133 changes: 7 additions & 126 deletions sample/otel-in-action/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ networks:

services:

### APPLICATION PART

postgresdb:
image: postgres
networks:
Expand All @@ -13,43 +11,32 @@ services:
- 5432:5432
environment:
- POSTGRES_PASSWORD=password
- POSTGRES_USER=matthias
- POSTGRES_USER=postgres
- POSTGRES_DB=mydb

todobackend-springboot:
image: maeddes/todobackend-springboot:v2402
todobackend-django:
image: vivoit0000/todo_backend
networks:
- todonet
build:
context: ./todobackend-springboot
dockerfile: Dockerfile
ports:
- "8080:8080"
restart: unless-stopped
environment:
- SPRING_PROFILES_ACTIVE=prod
# - OTEL_EXPORTER_OTLP_ENDPOINT=https://jaeger:4318 # http endpoint
- OTEL_EXPORTER_OTLP_ENDPOINT=otelcol:4317
- OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=otelcol:4317
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc
- OTEL_EXPORTER_OTLP_METRICS_PROTOCOL=grpc
- OTEL_RESOURCE_ATTRIBUTES=service.name=todobackend-springboot
- OTEL_METRICS_EXPORTER=otlp,logging-otlp
- OTEL_LOGS_EXPORTER=none
depends_on:
- postgresdb
volumes:
- ./todobackend_django:/app

todoui-thymeleaf:
image: maeddes/todoui-thymeleaf:v2404
build:
context: ./todoui-thymeleaf
dockerfile: Dockerfile #-multistage
dockerfile: Dockerfile
networks:
- todonet
ports:
- "8090:8090"
environment:
- BACKEND_URL=https://todobackend-springboot:8080/
- BACKEND_URL=https://todobackend-django:8080/
- OTEL_EXPORTER_OTLP_ENDPOINT=otelcol:4317
- OTEL_EXPORTER_OTLP_METRICS_ENDPOINT=otelcol:4317
- OTEL_EXPORTER_OTLP_TRACES_PROTOCOL=grpc
Expand All @@ -58,115 +45,9 @@ services:
- OTEL_METRICS_EXPORTER=otlp,logging-otlp
- OTEL_LOGS_EXPORTER=none

todoui-flask:
image: maeddes/todoui-flask:v2404
build:
context: ./todoui-flask
networks:
- todonet
ports:
- "5001:5000"
environment:
- BACKEND_URL=https://todobackend-springboot:8080/todos/
- OTEL_EXPORTER_OTLP_ENDPOINT=otelcol:4317
- OTEL_RESOURCE_ATTRIBUTES=service.name=todoui-flask
- OTEL_METRICS_EXPORTER=otlp

loadgenerator:
image: generator:v0.1
build:
context: ./loadgenerator
networks:
- todonet


# ### OTEL PART

# # jaegercol:
# # image: jaegertracing/all-in-one:latest
# # environment:
# # - COLLECTOR_OTLP_ENABLED=true
# # ports:
# # - "16686:16686"
# # - "4317:4317"

# jaeger:
# image: ${JAEGERTRACING_IMAGE}
# networks:
# - todonet
# command:
# - "--memory.max-traces=5000"
# - "--prometheus.server-url=https://prometheus:9090"
# - "--prometheus.query.normalize-calls=true"
# - "--prometheus.query.normalize-duration=true"
# # - "--query.base-path=/jaeger/ui"
# ports:
# - "16686:16686"
# deploy:
# resources:
# limits:
# memory: 400M
# restart: unless-stopped
# environment:
# - METRICS_STORAGE_TYPE=prometheus

# otelcol:
# image: ${COLLECTOR_CONTRIB_IMAGE}
# restart: unless-stopped
# networks:
# - todonet
# command: ["--config=/etc/otel-collector-config.yml", ""]
# volumes:
# - ./collector/otel-collector-config.yml:/etc/otel-collector-config.yml
# ports:
# - "4317:4317" # OTLP gRPC receiver
# - "4318:4318"
# depends_on:
# - jaeger

# # Prometheus
# prometheus:
# image: ${PROMETHEUS_IMAGE}
# networks:
# - todonet
# command:
# - --web.console.templates=/etc/prometheus/consoles
# - --web.console.libraries=/etc/prometheus/console_libraries
# - --storage.tsdb.retention.time=1h
# - --config.file=/etc/prometheus/prometheus-config.yaml
# - --storage.tsdb.path=/prometheus
# - --web.enable-lifecycle
# - --web.route-prefix=/
# - --enable-feature=exemplar-storage
# - --enable-feature=otlp-write-receiver
# volumes:
# - ./prometheus/prometheus-config.yaml:/etc/prometheus/prometheus-config.yaml
# deploy:
# resources:
# limits:
# memory: 300M
# restart: unless-stopped
# ports:
# - "${PROMETHEUS_SERVICE_PORT}:${PROMETHEUS_SERVICE_PORT}"




# # opensearch:
# # image: ${OPENSEARCH_IMAGE}
# # container_name: opensearch
# # deploy:
# # resources:
# # limits:
# # memory: 1G
# # restart: unless-stopped
# # environment:
# # - cluster.name=demo-cluster
# # - node.name=demo-node
# # - bootstrap.memory_lock=true
# # - discovery.type=single-node
# # - OPENSEARCH_JAVA_OPTS=-Xms300m -Xmx300m
# # - DISABLE_INSTALL_DEMO_CONFIG=true
# # - DISABLE_SECURITY_PLUGIN=true
# # ports:
# # - "9200:9200"
Loading

0 comments on commit 6731daf

Please sign in to comment.