Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the k8s manifest and other minor details #98

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the .vs/ folder from this PR

git rm -r .vs --cached or something similar would work

"ExpandedNodes": [
""
],
"SelectedNode": "\\C:\\Users\\jlecadou\\Source\\Repos\\azure-voting-app-redis",
"PreviewInSolutionExplorer": false
}
Binary file added .vs/azure-voting-app-redis/v17/.wsuo
Binary file not shown.
12 changes: 12 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[[source]]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the images aren't reading from this Pipfile, it can be removed

url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]

[dev-packages]

[requires]
python_version = "3.11"
python_full_version = "3.11.2"
39 changes: 37 additions & 2 deletions azure-vote-all-in-one-redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ spec:
app: azure-vote-back
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
"kubernetes.io/os": linux
containers:
- name: azure-vote-back
image: mcr.microsoft.com/oss/bitnami/redis:6.0.8
Expand All @@ -23,6 +23,27 @@ spec:
ports:
- containerPort: 6379
name: redis
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 200m
memory: 200Mi
livenessProbe:
exec:
command:
- redis-cli
- ping
initialDelaySeconds: 15
periodSeconds: 10
readinessProbe:
exec:
command:
- redis-cli
- ping
initialDelaySeconds: 5
periodSeconds: 10
---
apiVersion: v1
kind: Service
Expand Down Expand Up @@ -54,7 +75,7 @@ spec:
app: azure-vote-front
spec:
nodeSelector:
"beta.kubernetes.io/os": linux
"kubernetes.io/os": linux
containers:
- name: azure-vote-front
image: mcr.microsoft.com/azuredocs/azure-vote-front:v1
Expand All @@ -63,11 +84,25 @@ spec:
resources:
requests:
cpu: 250m
memory: 128Mi
limits:
cpu: 500m
memory: 256Mi
env:
- name: REDIS
value: "azure-vote-back"
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 15
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 10
---
apiVersion: v1
kind: Service
Expand Down
12 changes: 11 additions & 1 deletion azure-vote/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
FROM tiangolo/uwsgi-nginx-flask:python3.6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove the commented lines and the comment. The git history is sufficient to explain the change

# FROM tiangolo/uwsgi-nginx-flask:python3.6

# Update the base image to use Python 3.11
FROM tiangolo/uwsgi-nginx:python3.11
LABEL maintainer="Sebastian Ramirez <[email protected]>"
# Make /app/* available to be imported by Python globally to better support several use cases like Alembic migrations.

ENV PYTHONPATH=/app



RUN pip install redis
ADD /azure-vote /app
5 changes: 4 additions & 1 deletion azure-vote/Dockerfile-for-app-service
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FROM tiangolo/uwsgi-nginx-flask:python3.6
# FROM tiangolo/uwsgi-nginx-flask:python3.6

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the commented line

FROM tiangolo/uwsgi-nginx:python3.11
LABEL maintainer="Sebastian Ramirez <[email protected]>"
ENV PYTHONPATH=/app

COPY sshd_config /etc/ssh/
COPY app_init.supervisord.conf /etc/supervisor/conf.d
Expand Down
2 changes: 1 addition & 1 deletion azure-vote/azure-vote/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</head>
<body>
<div id="container">
<form id="form" name="form" action="/"" method="post"><center>
<form id="form" name="form" action="/" method="post"><center>
<div id="logo">{{title}}</div>
<div id="space"></div>
<div id="form">
Expand Down
130 changes: 130 additions & 0 deletions notes.md

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this from the branch and copy the contents into the PR description

Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Improvements to azure-vote-all-in-one-redis.yaml

1. Use resource requests and limits for both azure-vote-back and azure-vote-front containers to ensure they have predictable resource usage and prevent resource starvation.

2. Set up liveness and readiness probes for both containers to improve the self-healing capabilities of your deployments and ensure the availability of your services.

```yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: azure-vote-back
spec:
replicas: 1
selector:
matchLabels:
app: azure-vote-back
template:
metadata:
labels:
app: azure-vote-back
spec:
nodeSelector:
"kubernetes.io/os": linux
containers:
- name: azure-vote-back
image: mcr.microsoft.com/oss/bitnami/redis:6.0.8
env:
- name: ALLOW_EMPTY_PASSWORD
value: "yes"
ports:
- containerPort: 6379
name: redis
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 200m
memory: 200Mi
livenessProbe:
exec:
command:
- redis-cli
- ping
initialDelaySeconds: 15
periodSeconds: 10
readinessProbe:
exec:
command:
- redis-cli
- ping
initialDelaySeconds: 5
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: azure-vote-back
spec:
ports:
- port: 6379
selector:
app: azure-vote-back
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: azure-vote-front
spec:
replicas: 1
selector:
matchLabels:
app: azure-vote-front
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 1
minReadySeconds: 5
template:
metadata:
labels:
app: azure-vote-front
spec:
nodeSelector:
"kubernetes.io/os": linux
containers:
- name: azure-vote-front
image: mcr.microsoft.com/azuredocs/azure-vote-front:v1
ports:
- containerPort: 80
resources:
requests:
cpu: 250m
memory: 128Mi
limits:
cpu: 500m
memory: 256Mi
env:
- name: REDIS
value: "azure-vote-back"
livenessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 15
periodSeconds: 10
readinessProbe:
httpGet:
path: /
port: 80
initialDelaySeconds: 5
periodSeconds: 10
---
apiVersion: v1
kind: Service
metadata:
name: azure-vote-front
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: azure-vote-front
```

## Changes made

1. Added memory requests and limits to both `azure-vote-back` and `azure-vote-front` containers.
2. Changed nodeSelector key from `beta.kubernetes.io/os` to `kubernetes.io/os` as the beta label has been deprecated.
3. Added liveness