instruction: Create a Kubernetes Deployment configuration with best practices
output: ```yaml
  apiVersion: apps/v1
  kind: Deployment
  metadata:
   name: my-nginx
  spec:
   selector:
   matchLabels:
   run: my-nginx
   replicas: 2
   template:
   metadata:
   labels:
   run: my-nginx
   spec:
   containers:
   - name: my-nginx
   image: nginx
   ports:
   - containerPort: 80
  EOF
  
  cat <<EOF >./kustomization.yaml
  resources:
  - deployment.yaml
  images:
  - name: nginx
   newName: my.image.registry/nginx
   newTag: "1.4.0"
  EOF
  Run kubectl kustomize ./ to see that the image being used is updated:apiVersion: apps/v1
  kind: Deployment
  metadata:
   name: my-nginx
  spec:
   replicas: 2
   selector:
   matchLabels:
   run: my-nginx
   template:
   metadata:
   labels:
   run: my-nginx
   spec:
   containers:
   - image: my.image.registry/nginx:1.4.0
   name: my-nginx
   ports:
   - containerPort: 80
  Sometimes, the application running in a Pod may need to use configuration values from other objects. For example,
  a Pod from a Deployment object need to read the corresponding Service name from Env or as a command argument.
  Since the Service name may change as namePrefix or nameSuffix is added in the kustomization.yaml file. It is
  not recommended to hard code the Service name in the command argument. For this usage, Kustomize can inject
  the Service name into containers through replacements.# Create a deployment.yaml file (quoting the here doc delimiter)
  cat <<'EOF' > deployment.yaml
  ```
  
  ## Error Handling and Troubleshooting
  
  ### Common Issues and Solutions
  
  **Issue 1: Container startup failures**
  ```bash
  # Check container logs
  docker logs <container_id>
  
  # Debug with interactive shell
  docker run -it --entrypoint /bin/sh <image_name>
  ```
  
  **Issue 2: Resource constraints**
  ```bash
  # Check resource usage
  kubectl top pods
  kubectl describe pod <pod_name>
  
  # Scale resources if needed
  kubectl patch deployment <deployment_name> -p '{{"spec":{{"template":{{"spec":{{"containers":[{{"name":"<container_name>","resources":{{"requests":{{"memory":"256Mi","cpu":"200m"}},"limits":{{"memory":"512Mi","cpu":"400m"}}}}}}]}}}}}}}'
  ```
  
  **Issue 3: Network connectivity**
  ```bash
  # Test service connectivity
  kubectl exec -it <pod_name> -- wget -qO- <service_name>:<port>/health
  
  # Check service endpoints
  kubectl get endpoints <service_name>
  ```
  
  ### Monitoring and Alerts
  
  Set up proper monitoring to catch issues early:
  
  ```yaml
  # Example alert rule
  groups:
  - name: application.rules
    rules:
    - alert: HighErrorRate
      expr: rate(http_requests_total{{status=~"5.."}}}[5m]) > 0.1
      for: 5m
      annotations:
        summary: "High error rate detected"
        description: "Error rate is above 10% for 5 minutes"
  ```