Skip to content

Instantly share code, notes, and snippets.

@mihirvijdeshpande
Created April 5, 2024 03:21
Show Gist options
  • Save mihirvijdeshpande/c6345a07c2a41ae8ab009a7a7d518b4e to your computer and use it in GitHub Desktop.
Save mihirvijdeshpande/c6345a07c2a41ae8ab009a7a7d518b4e to your computer and use it in GitHub Desktop.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
# Update with your desired number of replicas (e.g., replicas: 2)
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
# Adjust resource requests and limits based on your application needs
resources:
requests:
memory: "100Mi"
cpu: "50m"
limits:
memory: "200Mi"
cpu: "100m"
containers:
- name: nginx
image: nginx:latest # Replace with specific version if needed
ports:
- containerPort: 80
volumeMounts:
- name: nginx-config # Mount the config volume
mountPath: /etc/nginx/conf.d # Mount path within the container
livenessProbe: # Liveness probe configuration
httpGet:
path: /healthz # Health check endpoint (replace if needed)
port: 80
initialDelaySeconds: 120 # Wait 120 seconds before probe starts
periodSeconds: 30 # Perform probe every 30 seconds
failureThreshold: 3 # Consider container unhealthy after 3 failures
readinessProbe: # Readiness probe configuration
httpGet:
path: /
port: 80
initialDelaySeconds: 30 # Wait 30 seconds before probe starts
periodSeconds: 10 # Perform probe every 10 seconds
failureThreshold: 5 # Consider container unready after 5 failures
volumes: # Define a volume for configuration
- name: nginx-config
configMap:
name: nginx-config # Reference the config map containing nginx configuration
optional: false # Mount the volume by default
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nginx-config
data: # Replace with your desired Nginx configuration
default.conf: |
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment