-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add basic redis and flask project template with deployment and build …
…scripts
- Loading branch information
Showing
28 changed files
with
693 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.idea | ||
.DS_Store |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
helm repo add bitnami https://charts.bitnami.com/bitnami | ||
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx | ||
|
||
helm repo update | ||
|
||
helm install -f helm-config/redis-helm-values.yaml redis bitnami/redis | ||
helm install -f helm-config/nginx-helm-values.yaml nginx ingress-nginx/ingress-nginx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
|
||
helm repo add bitnami https://charts.bitnami.com/bitnami | ||
helm repo update | ||
|
||
helm install -f helm-config/redis-helm-values.yaml redis bitnami/redis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
version: "3" | ||
services: | ||
|
||
gateway: | ||
image: nginx:latest | ||
volumes: | ||
- ./gateway_nginx.conf:/etc/nginx/nginx.conf:ro | ||
ports: | ||
- "8000:80" | ||
|
||
order-service: | ||
build: ./order | ||
image: order:latest | ||
environment: | ||
- GATEWAY_URL=http://gateway:80 | ||
command: gunicorn -b 0.0.0.0:5000 app:app | ||
env_file: | ||
- env/order_redis.env | ||
|
||
order-db: | ||
image: redis:latest | ||
command: redis-server --requirepass redis --maxmemory 512mb | ||
|
||
stock-service: | ||
build: ./stock | ||
image: stock:latest | ||
command: gunicorn -b 0.0.0.0:5000 app:app | ||
env_file: | ||
- env/stock_redis.env | ||
|
||
stock-db: | ||
image: redis:latest | ||
command: redis-server --requirepass redis --maxmemory 512mb | ||
|
||
payment-service: | ||
build: ./payment | ||
image: user:latest | ||
command: gunicorn -b 0.0.0.0:5000 app:app | ||
env_file: | ||
- env/payment_redis.env | ||
|
||
payment-db: | ||
image: redis:latest | ||
command: redis-server --requirepass redis --maxmemory 512mb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
REDIS_HOST=order-db | ||
REDIS_PORT=6379 | ||
REDIS_PASSWORD=redis | ||
REDIS_DB=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
REDIS_HOST=payment-db | ||
REDIS_PORT=6379 | ||
REDIS_PASSWORD=redis | ||
REDIS_DB=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
REDIS_HOST=stock-db | ||
REDIS_PORT=6379 | ||
REDIS_PASSWORD=redis | ||
REDIS_DB=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
events { worker_connections 2048;} | ||
|
||
http { | ||
upstream order-app { | ||
server order-service:5000; | ||
} | ||
upstream payment-app { | ||
server payment-service:5000; | ||
} | ||
upstream stock-app { | ||
server stock-service:5000; | ||
} | ||
server { | ||
listen 80; | ||
location /orders/ { | ||
proxy_pass http://order-app/; | ||
} | ||
location /payment/ { | ||
proxy_pass http://payment-app/; | ||
} | ||
location /stock/ { | ||
proxy_pass http://stock-app/; | ||
} | ||
access_log /var/log/nginx/server.access.log; | ||
} | ||
access_log /var/log/nginx/access.log; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
resources: | ||
limits: | ||
cpu: 500m | ||
memory: 1Gi | ||
requests: | ||
cpu: 500m | ||
memory: 1Gi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
auth: | ||
password: redis | ||
master: | ||
persistence: | ||
size: 4Gi | ||
resources: | ||
requests: | ||
memory: 4Gi | ||
cpu: 2 | ||
replica: | ||
replicaCount: 1 | ||
persistence: | ||
size: 4Gi | ||
resources: | ||
requests: | ||
memory: 4Gi | ||
cpu: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: Ingress | ||
metadata: | ||
name: ingress-service | ||
annotations: | ||
kubernetes.io/ingress.class: nginx | ||
nginx.ingress.kubernetes.io/rewrite-target: /$1 | ||
spec: | ||
rules: | ||
- http: | ||
paths: | ||
- path: /orders/?(.*) | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: order-service | ||
port: | ||
number: 5000 | ||
- path: /stock/?(.*) | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: stock-service | ||
port: | ||
number: 5000 | ||
- path: /payment/?(.*) | ||
pathType: Prefix | ||
backend: | ||
service: | ||
name: user-service | ||
port: | ||
number: 5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: order-service | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
component: order | ||
ports: | ||
- port: 5000 | ||
name: http | ||
targetPort: 5000 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: order-deployment | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
component: order | ||
template: | ||
metadata: | ||
labels: | ||
component: order | ||
spec: | ||
containers: | ||
- name: order | ||
image: order:latest | ||
resources: | ||
limits: | ||
memory: "1Gi" | ||
cpu: "1" | ||
requests: | ||
memory: "1Gi" | ||
cpu: "1" | ||
command: ["gunicorn"] | ||
args: ["-b", "0.0.0.0:5000", "app:app"] | ||
ports: | ||
- containerPort: 5000 | ||
env: | ||
- name: USER_SERVICE_URL | ||
value: "user-service" | ||
- name: STOCK_SERVICE_URL | ||
value: "stock-service" | ||
- name: REDIS_HOST | ||
value: redis-master | ||
- name: REDIS_PORT | ||
value: '6379' | ||
- name: REDIS_PASSWORD | ||
value: "redis" | ||
- name: REDIS_DB | ||
value: "0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: stock-service | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
component: stock | ||
ports: | ||
- port: 5000 | ||
name: http | ||
targetPort: 5000 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: stock-deployment | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
component: stock | ||
template: | ||
metadata: | ||
labels: | ||
component: stock | ||
spec: | ||
containers: | ||
- name: stock | ||
image: stock:latest | ||
resources: | ||
limits: | ||
memory: "1Gi" | ||
cpu: "1" | ||
requests: | ||
memory: "1Gi" | ||
cpu: "1" | ||
command: ["gunicorn"] | ||
args: ["-b", "0.0.0.0:5000", "app:app"] | ||
ports: | ||
- containerPort: 5000 | ||
env: | ||
- name: REDIS_HOST | ||
value: redis-master | ||
- name: REDIS_PORT | ||
value: '6379' | ||
- name: REDIS_PASSWORD | ||
value: "redis" | ||
- name: REDIS_DB | ||
value: "0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: user-service | ||
spec: | ||
type: ClusterIP | ||
selector: | ||
component: user | ||
ports: | ||
- port: 5000 | ||
name: http | ||
targetPort: 5000 | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: user-deployment | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
component: user | ||
template: | ||
metadata: | ||
labels: | ||
component: user | ||
spec: | ||
containers: | ||
- name: user | ||
image: user:latest | ||
resources: | ||
limits: | ||
memory: "1Gi" | ||
cpu: "1" | ||
requests: | ||
memory: "1Gi" | ||
cpu: "1" | ||
command: ["gunicorn"] | ||
args: ["-b", "0.0.0.0:5000", "app:app"] | ||
ports: | ||
- containerPort: 5000 | ||
env: | ||
- name: REDIS_HOST | ||
value: redis-master | ||
- name: REDIS_PORT | ||
value: '6379' | ||
- name: REDIS_PASSWORD | ||
value: "redis" | ||
- name: REDIS_DB | ||
value: "0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM python:3.10-slim | ||
|
||
WORKDIR /home/flask-app | ||
|
||
COPY ./requirements.txt . | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
COPY . . | ||
|
||
EXPOSE 5000 |
Oops, something went wrong.