Skip to content

Commit

Permalink
Update deploy.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
scolomar authored Jan 13, 2025
1 parent d8fbe26 commit 5567750
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions main/openshift/manifests/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ kind: Deployment
metadata:
name: phpinfo
spec:
# This manifest ensures that replicas are distributed across two availability zones and placed on separate worker nodes.
# Deploying 4 replicas will ensure they are spread across 4 different nodes in two availability zones.
# Deploying 2 replicas will ensure they are spread across 2 different nodes in two availability zones.
replicas: 4
selector:
matchLabels:
Expand All @@ -13,18 +16,28 @@ spec:
app: phpinfo
spec:
topologySpreadConstraints:
- maxSkew: 1
topologyKey: topology.kubernetes.io/zone
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: phpinfo
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: DoNotSchedule
labelSelector:
matchLabels:
app: phpinfo
- labelSelector:
matchLabels:
app: phpinfo
# maxSkew is the parameter used to evenly distribute workloads across specified topology keys.
# When maxSkew is set to 1, the workload is balanced such that the difference between the highest and lowest workload across topological regions does not exceed 1 unit.
maxSkew: 1
# In this configuration, the topology key represents an availability zone, such as a distinct data center.
topologyKey: topology.kubernetes.io/zone
# If the scheduler cannot find an available worker node in the specified availability zone, the replica will not be scheduled.
# This may block the deployment if no nodes are available, but it is essential to maintain high availability and resilience.
whenUnsatisfiable: DoNotSchedule
- labelSelector:
matchLabels:
app: phpinfo
# maxSkew is the parameter used to evenly distribute workloads across specified topology keys.
# When maxSkew is set to 1, the workload is balanced such that the difference between the highest and lowest workload across topological regions does not exceed 1 unit.
maxSkew: 1
# In this configuration, the topology key represents a hostname, indicating a specific worker node.
topologyKey: kubernetes.io/hostname
# If the scheduler cannot find an available worker node, the replica will not be scheduled.
# This behavior may block the deployment if no nodes are available, but it ensures high availability and resilience.
whenUnsatisfiable: DoNotSchedule
containers:
- command:
- php
Expand All @@ -36,14 +49,23 @@ spec:
name: phpinfo
ports:
- containerPort: 9000
# It is highly recommended to configure resources limitations to avoid any container can request too much memory or CPU from the host node
resources:
# Limits are set higher than requests, effectively overcommitting resources.
# This approach carries some risk because if all containers simultaneously utilize resources up to their limits, the node could exceed its capacity, potentially triggering the OOM killer or causing CPU throttling.
limits:
cpu: 40m
memory: 40M
memory: 40M
# Requests define the minimum CPU and memory resources required to schedule the replica.
# A replica will not be scheduled if sufficient resources are not available on the node to meet the requests.
# However, these resources are not reserved for the replica. The scheduler only ensures they are available at the time of scheduling.
requests:
cpu: 20m
memory: 20M
securityContext:
# This setting makes the container's filesystem read-only.
# It is considered a best practice for enhancing security.
# If your application requires writing to the container's filesystem, you must mount a writable temporary filesystem for that purpose.
readOnlyRootFilesystem: true
volumeMounts:
- mountPath: /data
Expand Down

0 comments on commit 5567750

Please sign in to comment.