You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
2.2 KiB

  1. # Namespace
  2. apiVersion: v1
  3. kind: Namespace
  4. metadata:
  5. name: nginx-deployment
  6. ---
  7. # Persistent Volume
  8. apiVersion: v1
  9. kind: PersistentVolume
  10. metadata:
  11. name: nginx-pv
  12. spec:
  13. capacity:
  14. storage: 5Gi
  15. accessModes:
  16. - ReadWriteOnce
  17. persistentVolumeReclaimPolicy: Retain
  18. storageClassName: manual
  19. hostPath:
  20. path: "/mnt/data/nginx-pv" # Adjust this path according to the Kubernetes node filesystem
  21. ---
  22. # Persistent Volume Claim
  23. apiVersion: v1
  24. kind: PersistentVolumeClaim
  25. metadata:
  26. name: nginx-pvc
  27. namespace: nginx-deployment
  28. spec:
  29. storageClassName: manual
  30. accessModes:
  31. - ReadWriteOnce
  32. resources:
  33. requests:
  34. storage: 5Gi
  35. ---
  36. # Deployment for Nginx Pods
  37. apiVersion: apps/v1
  38. kind: Deployment
  39. metadata:
  40. name: nginx-deployment
  41. namespace: nginx-deployment
  42. spec:
  43. replicas: 2
  44. selector:
  45. matchLabels:
  46. app: nginx
  47. template:
  48. metadata:
  49. labels:
  50. app: nginx
  51. spec:
  52. containers:
  53. - name: nginx
  54. image: nginx:latest
  55. ports:
  56. - containerPort: 80
  57. volumeMounts:
  58. - mountPath: /usr/share/nginx/html
  59. name: nginx-storage
  60. resources:
  61. limits:
  62. memory: "512Mi"
  63. cpu: "1"
  64. requests:
  65. memory: "256Mi"
  66. cpu: "0.5"
  67. volumes:
  68. - name: nginx-storage
  69. persistentVolumeClaim:
  70. claimName: nginx-pvc
  71. ---
  72. # Service of type LoadBalancer to expose Nginx externally
  73. apiVersion: v1
  74. kind: Service
  75. metadata:
  76. name: nginx-service
  77. namespace: nginx-deployment
  78. spec:
  79. selector:
  80. app: nginx
  81. ports:
  82. - protocol: TCP
  83. port: 80
  84. targetPort: 80
  85. type: LoadBalancer
  86. ---
  87. # Ingress to route traffic to Nginx service (no specific host)
  88. apiVersion: networking.k8s.io/v1
  89. kind: Ingress
  90. metadata:
  91. name: nginx-ingress
  92. namespace: nginx-deployment
  93. annotations:
  94. traefik.ingress.kubernetes.io/router.entrypoints: web
  95. spec:
  96. rules:
  97. - http:
  98. # host: something.hs-fulda.de # Replace with your domain
  99. paths:
  100. - path: /
  101. pathType: Prefix
  102. backend:
  103. service:
  104. name: nginx-service
  105. port:
  106. number: 80