mirror of
https://github.com/marcel-dempers/docker-development-youtube-series.git
synced 2025-06-06 17:01:30 +00:00
deploy examples to k8s
This commit is contained in:
parent
7eb88e36b2
commit
6d1cefacfd
@ -0,0 +1,89 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: playlists-api
|
||||||
|
labels:
|
||||||
|
app: playlists-api
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: playlists-api
|
||||||
|
replicas: 1
|
||||||
|
strategy:
|
||||||
|
type: RollingUpdate
|
||||||
|
rollingUpdate:
|
||||||
|
maxSurge: 1
|
||||||
|
maxUnavailable: 0
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: playlists-api
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: playlists-api
|
||||||
|
image: aimvector/service-mesh:playlists-api-1.0.0
|
||||||
|
ports:
|
||||||
|
- containerPort: 10010
|
||||||
|
env:
|
||||||
|
- name: "ENVIRONMENT"
|
||||||
|
value: "DEBUG"
|
||||||
|
- name: "REDIS_HOST"
|
||||||
|
value: "playlists-db"
|
||||||
|
- name: "REDIS_PORT"
|
||||||
|
value: "6379"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: playlists-api
|
||||||
|
labels:
|
||||||
|
app: playlists-api
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
selector:
|
||||||
|
app: playlists-api
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
name: http
|
||||||
|
port: 80
|
||||||
|
targetPort: 10010
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: playlists-db
|
||||||
|
labels:
|
||||||
|
app: playlists-db
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: playlists-db
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: playlists-db
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: playlists-api
|
||||||
|
image: redis:6.0-alpine
|
||||||
|
ports:
|
||||||
|
- containerPort: 6379
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: playlists-db
|
||||||
|
labels:
|
||||||
|
app: playlists-db
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
selector:
|
||||||
|
app: playlists-db
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
name: http
|
||||||
|
port: 6379
|
||||||
|
targetPort: 6379
|
||||||
|
|
||||||
|
|
89
kubernetes/servicemesh/applications/videos-api/deploy.yaml
Normal file
89
kubernetes/servicemesh/applications/videos-api/deploy.yaml
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: videos-api
|
||||||
|
labels:
|
||||||
|
app: videos-api
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: videos-api
|
||||||
|
replicas: 1
|
||||||
|
strategy:
|
||||||
|
type: RollingUpdate
|
||||||
|
rollingUpdate:
|
||||||
|
maxSurge: 1
|
||||||
|
maxUnavailable: 0
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: videos-api
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: videos-api
|
||||||
|
image: aimvector/service-mesh:videos-api-1.0.0
|
||||||
|
ports:
|
||||||
|
- containerPort: 10010
|
||||||
|
env:
|
||||||
|
- name: "ENVIRONMENT"
|
||||||
|
value: "DEBUG"
|
||||||
|
- name: "REDIS_HOST"
|
||||||
|
value: "videos-db"
|
||||||
|
- name: "REDIS_PORT"
|
||||||
|
value: "6379"
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: videos-api
|
||||||
|
labels:
|
||||||
|
app: videos-api
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
selector:
|
||||||
|
app: videos-api
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
name: http
|
||||||
|
port: 10010
|
||||||
|
targetPort: 10010
|
||||||
|
---
|
||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: videos-db
|
||||||
|
labels:
|
||||||
|
app: videos-db
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: videos-db
|
||||||
|
replicas: 1
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: videos-db
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: videos-db
|
||||||
|
image: redis:6.0-alpine
|
||||||
|
ports:
|
||||||
|
- containerPort: 6379
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: videos-db
|
||||||
|
labels:
|
||||||
|
app: videos-db
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
selector:
|
||||||
|
app: videos-db
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
name: http
|
||||||
|
port: 6379
|
||||||
|
targetPort: 6379
|
||||||
|
|
||||||
|
|
44
kubernetes/servicemesh/applications/videos-web/deploy.yaml
Normal file
44
kubernetes/servicemesh/applications/videos-web/deploy.yaml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: videos-web
|
||||||
|
labels:
|
||||||
|
app: videos-web
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: videos-web
|
||||||
|
replicas: 1
|
||||||
|
strategy:
|
||||||
|
type: RollingUpdate
|
||||||
|
rollingUpdate:
|
||||||
|
maxSurge: 1
|
||||||
|
maxUnavailable: 0
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: videos-web
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: videos-web
|
||||||
|
image: aimvector/service-mesh:videos-web-1.0.0
|
||||||
|
ports:
|
||||||
|
- containerPort: 80
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: videos-web
|
||||||
|
labels:
|
||||||
|
app: videos-web
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
selector:
|
||||||
|
app: videos-web
|
||||||
|
ports:
|
||||||
|
- protocol: TCP
|
||||||
|
name: http
|
||||||
|
port: 80
|
||||||
|
targetPort: 80
|
||||||
|
|
||||||
|
|
@ -111,9 +111,11 @@ This is intentional to demonstrate a busy network.
|
|||||||
+------------+ +-----------+
|
+------------+ +-----------+
|
||||||
|
|
||||||
```
|
```
|
||||||
|
<br/>
|
||||||
|
|
||||||
## Run the apps
|
## Run the apps: Docker
|
||||||
|
<hr/>
|
||||||
|
<br/>
|
||||||
There is a `docker-compose.yaml` in this directory. <br/>
|
There is a `docker-compose.yaml` in this directory. <br/>
|
||||||
Change your terminal to this folder and run:
|
Change your terminal to this folder and run:
|
||||||
|
|
||||||
@ -125,3 +127,67 @@ docker-compose up
|
|||||||
```
|
```
|
||||||
|
|
||||||
You can access the app on `http://localhost`
|
You can access the app on `http://localhost`
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## Run the apps: Kubernetes
|
||||||
|
<hr/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
Create a cluster with [kind](https://kind.sigs.k8s.io/docs/user/quick-start/)
|
||||||
|
|
||||||
|
```
|
||||||
|
kind create cluster --name servicemesh --image kindest/node:v1.18.4
|
||||||
|
```
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
### Deploy videos-web
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
```
|
||||||
|
cd ./kubernetes/servicemesh/
|
||||||
|
|
||||||
|
kubectl apply -f applications/videos-web/deploy.yaml
|
||||||
|
kubectl port-forward svc/videos-web 80:80
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
You should see blank page at `http://localhost/` <br/>
|
||||||
|
It's blank because it needs the `playlists-api` to get data
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
### Deploy playlists-api and database
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
```
|
||||||
|
cd ./kubernetes/servicemesh/
|
||||||
|
|
||||||
|
kubectl apply -f applications/playlists-api/deploy.yaml
|
||||||
|
kubectl port-forward svc/playlists-api 81:80
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
You should see empty playlists page at `http://localhost/` <br/>
|
||||||
|
Playlists are empty because it needs the `videos-api` to get video data <br/>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
### Deploy videos-api and database
|
||||||
|
|
||||||
|
<hr/>
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
```
|
||||||
|
cd ./kubernetes/servicemesh/
|
||||||
|
|
||||||
|
kubectl apply -f applications/videos-api/deploy.yaml
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Refresh page at `http://localhost/` <br/>
|
||||||
|
You should now see the complete architecture in the browser <br/>
|
Loading…
x
Reference in New Issue
Block a user