diff --git a/.vs/VSWorkspaceState.json b/.vs/VSWorkspaceState.json new file mode 100644 index 0000000000..8ac564e451 --- /dev/null +++ b/.vs/VSWorkspaceState.json @@ -0,0 +1,7 @@ +{ + "ExpandedNodes": [ + "" + ], + "SelectedNode": "\\C:\\Users\\jlecadou\\Source\\Repos\\azure-voting-app-redis", + "PreviewInSolutionExplorer": false +} \ No newline at end of file diff --git a/.vs/azure-voting-app-redis/v17/.wsuo b/.vs/azure-voting-app-redis/v17/.wsuo new file mode 100644 index 0000000000..2cee29561a Binary files /dev/null and b/.vs/azure-voting-app-redis/v17/.wsuo differ diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000000..04edd2a087 --- /dev/null +++ b/Pipfile @@ -0,0 +1,12 @@ +[[source]] +url = "https://pypi.org/simple" +verify_ssl = true +name = "pypi" + +[packages] + +[dev-packages] + +[requires] +python_version = "3.11" +python_full_version = "3.11.2" diff --git a/azure-vote-all-in-one-redis.yaml b/azure-vote-all-in-one-redis.yaml index e971a76092..e578141ea5 100644 --- a/azure-vote-all-in-one-redis.yaml +++ b/azure-vote-all-in-one-redis.yaml @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/azure-vote/Dockerfile b/azure-vote/Dockerfile index ac103827a0..c990425066 100644 --- a/azure-vote/Dockerfile +++ b/azure-vote/Dockerfile @@ -1,3 +1,13 @@ -FROM tiangolo/uwsgi-nginx-flask:python3.6 +# 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 " +# 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 diff --git a/azure-vote/Dockerfile-for-app-service b/azure-vote/Dockerfile-for-app-service index 2086975bd7..bc3adaedb7 100644 --- a/azure-vote/Dockerfile-for-app-service +++ b/azure-vote/Dockerfile-for-app-service @@ -1,4 +1,7 @@ -FROM tiangolo/uwsgi-nginx-flask:python3.6 +# FROM tiangolo/uwsgi-nginx-flask:python3.6 +FROM tiangolo/uwsgi-nginx:python3.11 +LABEL maintainer="Sebastian Ramirez " +ENV PYTHONPATH=/app COPY sshd_config /etc/ssh/ COPY app_init.supervisord.conf /etc/supervisor/conf.d diff --git a/azure-vote/azure-vote/templates/index.html b/azure-vote/azure-vote/templates/index.html index 603e11002b..b1d86052ad 100644 --- a/azure-vote/azure-vote/templates/index.html +++ b/azure-vote/azure-vote/templates/index.html @@ -12,7 +12,7 @@
-
+
diff --git a/notes.md b/notes.md new file mode 100644 index 0000000000..4948683ea9 --- /dev/null +++ b/notes.md @@ -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