Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dockersamples/wordsmith
Sample project with Docker containers running under Kubernetes
https://github.com/dockersamples/wordsmith
demo docker docker-compose example kubernetes sample swarm
Last synced: about 2 hours ago
JSON representation
Sample project with Docker containers running under Kubernetes
- Host: GitHub
- URL: https://github.com/dockersamples/wordsmith
- Owner: dockersamples
- License: apache-2.0
- Created: 2018-01-09T10:15:33.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-06-23T10:58:28.000Z (5 months ago)
- Last Synced: 2024-11-15T00:57:34.803Z (about 7 hours ago)
- Topics: demo, docker, docker-compose, example, kubernetes, sample, swarm
- Language: Java
- Homepage:
- Size: 401 KB
- Stars: 264
- Watchers: 14
- Forks: 466
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Wordsmith App
Wordsmith is the demo project originally shown at DockerCon EU 2017 and 2018.
The demo app runs across three containers:
- **[api](api/Dockerfile)** - a Java REST API which serves words read from the database
- **[web](web/Dockerfile)** - a Go web application that calls the API and builds words into sentences
- **db** - a Postgres database that stores words## Architecture
![Architecture diagram](architecture.excalidraw.png)
## Build and run in Docker Compose
The only requirement to build and run the app from source is Docker. Clone this repo and use Docker Compose to build all the images. You can use the new V2 Compose with `docker compose` or the classic `docker-compose` CLI:
```shell
docker compose up --build
```Or you can pull pre-built images from Docker Hub using `docker compose pull`.
## Deploy using Kubernetes manifests
You can deploy the same app to Kubernetes using the [Kustomize configuration](./kustomization.yaml). It will define all of the necessary Deployment and Service objects and a ConfigMap to provide the database schema.
Apply the manifest using `kubectl` while at the root of the project:
```shell
kubectl apply -k .
```Once the pods are running, browse to http://localhost:8080 and you will see the site.
Docker Desktop includes Kubernetes and the [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) command line, so you can work directly with the cluster. Check the services are up, and you should see output like this:
```text
kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
db ClusterIP None 55555/TCP 2m
kubernetes ClusterIP 10.96.0.1 443/TCP 38d
web LoadBalancer 10.107.215.211 8080:30220/TCP 2m
words ClusterIP None 55555/TCP 2m
```Check the pods are running and you should see one pod each for the database and web components and five pods for the words API:
```text
kubectl get pods
NAME READY STATUS RESTARTS AGE
db-8678676c79-h2d99 1/1 Running 0 1m
web-5d6bfbbd8b-6zbl8 1/1 Running 0 1m
api-858f6678-6c8kk 1/1 Running 0 1m
api-858f6678-7bqbv 1/1 Running 0 1m
api-858f6678-fjdws 1/1 Running 0 1m
api-858f6678-rrr8c 1/1 Running 0 1m
api-858f6678-x9zqh 1/1 Running 0 1m
```