nginx-deployment-with-ingress.yaml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. apiVersion: v1
  2. kind: Namespace
  3. metadata:
  4. name: nginx-app
  5. ---
  6. apiVersion: apps/v1
  7. kind: Deployment
  8. metadata:
  9. name: nginx-deployment
  10. namespace: nginx-app
  11. labels:
  12. app: nginx
  13. spec:
  14. replicas: 3
  15. selector:
  16. matchLabels:
  17. app: nginx
  18. template:
  19. metadata:
  20. labels:
  21. app: nginx
  22. spec:
  23. containers:
  24. - name: nginx
  25. image: registry.cn-hangzhou.aliyuncs.com/zhongpengqun/wanderer:linux-amd64-nginx-stable-alpine-3.23
  26. ports:
  27. - containerPort: 80
  28. resources:
  29. requests:
  30. memory: "64Mi"
  31. cpu: "250m"
  32. limits:
  33. memory: "128Mi"
  34. cpu: "500m"
  35. readinessProbe:
  36. httpGet:
  37. path: /
  38. port: 80
  39. initialDelaySeconds: 5
  40. periodSeconds: 5
  41. livenessProbe:
  42. httpGet:
  43. path: /
  44. port: 80
  45. initialDelaySeconds: 10
  46. periodSeconds: 10
  47. ---
  48. apiVersion: v1
  49. kind: Service
  50. metadata:
  51. name: nginx-service
  52. namespace: nginx-app
  53. labels:
  54. app: nginx
  55. spec:
  56. selector:
  57. app: nginx
  58. ports:
  59. - protocol: TCP
  60. port: 80
  61. targetPort: 80
  62. type: ClusterIP
  63. ---
  64. apiVersion: networking.k8s.io/v1
  65. kind: Ingress
  66. metadata:
  67. name: nginx-ingress
  68. namespace: nginx-app
  69. spec:
  70. ingressClassName: traefik # Using traefik which is typically available in k3s
  71. rules:
  72. - host: nginx.local
  73. http:
  74. paths:
  75. - path: /
  76. pathType: Prefix
  77. backend:
  78. service:
  79. name: nginx-service
  80. port:
  81. number: 80