zhong (钟鹏群) 1 сар өмнө
parent
commit
79149ebd0e

+ 82 - 0
deployments/nginx-deployment-with-ingress-no-class.yaml

@@ -0,0 +1,82 @@
+apiVersion: v1
+kind: Namespace
+metadata:
+  name: nginx-app
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: nginx-deployment
+  namespace: nginx-app
+  labels:
+    app: nginx
+spec:
+  replicas: 3
+  selector:
+    matchLabels:
+      app: nginx
+  template:
+    metadata:
+      labels:
+        app: nginx
+    spec:
+      containers:
+      - name: nginx
+        image: registry.cn-hangzhou.aliyuncs.com/zhongpengqun/wanderer:linux-amd64-nginx-stable-alpine-3.23
+        ports:
+        - containerPort: 80
+        resources:
+          requests:
+            memory: "64Mi"
+            cpu: "250m"
+          limits:
+            memory: "128Mi"
+            cpu: "500m"
+        readinessProbe:
+          httpGet:
+            path: /
+            port: 80
+          initialDelaySeconds: 5
+          periodSeconds: 5
+        livenessProbe:
+          httpGet:
+            path: /
+            port: 80
+          initialDelaySeconds: 10
+          periodSeconds: 10
+
+---
+apiVersion: v1
+kind: Service
+metadata:
+  name: nginx-service
+  namespace: nginx-app
+  labels:
+    app: nginx
+spec:
+  selector:
+    app: nginx
+  ports:
+    - protocol: TCP
+      port: 80
+      targetPort: 80
+  type: ClusterIP
+
+---
+apiVersion: networking.k8s.io/v1
+kind: Ingress
+metadata:
+  name: nginx-ingress
+  namespace: nginx-app
+spec:
+  rules:
+  - host: nginx.local
+    http:
+      paths:
+      - path: /
+        pathType: Prefix
+        backend:
+          service:
+            name: nginx-service
+            port:
+              number: 80

+ 1 - 2
deployments/nginx-deployment-with-ingress.yaml

@@ -68,9 +68,8 @@ kind: Ingress
 metadata:
   name: nginx-ingress
   namespace: nginx-app
-  annotations:
-    kubernetes.io/ingress.class: "traefik"  # Using traefik which is typically available in k3s
 spec:
+  ingressClassName: traefik  # Using traefik which is typically available in k3s
   rules:
   - host: nginx.local
     http: