diff --git a/charts/vela-core/templates/defwithtemplate/gateway.yaml b/charts/vela-core/templates/defwithtemplate/gateway.yaml
index 6e1a75e2cc191686c8c295a39bb7e20b7e368e37..9b044df2e3a45caf711d82a7ecf317eaab57414f 100644
--- a/charts/vela-core/templates/defwithtemplate/gateway.yaml
+++ b/charts/vela-core/templates/defwithtemplate/gateway.yaml
@@ -32,21 +32,30 @@ spec:
         	kind:       "Ingress"
         	metadata: {
         		name: context.name
-        		annotations: "kubernetes.io/ingress.class": parameter.class
+        		annotations: {
+        			if !parameter.classInSpec {
+        				"kubernetes.io/ingress.class": parameter.class
+        			}
+        		}
+        	}
+        	spec: {
+        		if parameter.classInSpec {
+        			ingressClassName: parameter.class
+        		}
+        		rules: [{
+        			host: parameter.domain
+        			http: paths: [
+        				for k, v in parameter.http {
+        					path:     k
+        					pathType: "ImplementationSpecific"
+        					backend: service: {
+        						name: context.name
+        						port: number: v
+        					}
+        				},
+        			]
+        		}]
         	}
-        	spec: rules: [{
-        		host: parameter.domain
-        		http: paths: [
-        			for k, v in parameter.http {
-        				path:     k
-        				pathType: "ImplementationSpecific"
-        				backend: service: {
-        					name: context.name
-        					port: number: v
-        				}
-        			},
-        		]
-        	}]
         }
         parameter: {
         	// +usage=Specify the domain you want to expose
@@ -57,6 +66,9 @@ spec:
 
         	// +usage=Specify the class of ingress to use
         	class: *"nginx" | string
+
+        	// +usage=Set ingress class in '.spec.ingressClassName' instead of 'kubernetes.io/ingress.class' annotation.
+        	classInSpec: *false | bool
         }
   status:
     customStatus: |-
diff --git a/charts/vela-minimal/templates/defwithtemplate/gateway.yaml b/charts/vela-minimal/templates/defwithtemplate/gateway.yaml
index 6e1a75e2cc191686c8c295a39bb7e20b7e368e37..9b044df2e3a45caf711d82a7ecf317eaab57414f 100644
--- a/charts/vela-minimal/templates/defwithtemplate/gateway.yaml
+++ b/charts/vela-minimal/templates/defwithtemplate/gateway.yaml
@@ -32,21 +32,30 @@ spec:
         	kind:       "Ingress"
         	metadata: {
         		name: context.name
-        		annotations: "kubernetes.io/ingress.class": parameter.class
+        		annotations: {
+        			if !parameter.classInSpec {
+        				"kubernetes.io/ingress.class": parameter.class
+        			}
+        		}
+        	}
+        	spec: {
+        		if parameter.classInSpec {
+        			ingressClassName: parameter.class
+        		}
+        		rules: [{
+        			host: parameter.domain
+        			http: paths: [
+        				for k, v in parameter.http {
+        					path:     k
+        					pathType: "ImplementationSpecific"
+        					backend: service: {
+        						name: context.name
+        						port: number: v
+        					}
+        				},
+        			]
+        		}]
         	}
-        	spec: rules: [{
-        		host: parameter.domain
-        		http: paths: [
-        			for k, v in parameter.http {
-        				path:     k
-        				pathType: "ImplementationSpecific"
-        				backend: service: {
-        					name: context.name
-        					port: number: v
-        				}
-        			},
-        		]
-        	}]
         }
         parameter: {
         	// +usage=Specify the domain you want to expose
@@ -57,6 +66,9 @@ spec:
 
         	// +usage=Specify the class of ingress to use
         	class: *"nginx" | string
+
+        	// +usage=Set ingress class in '.spec.ingressClassName' instead of 'kubernetes.io/ingress.class' annotation.
+        	classInSpec: *false | bool
         }
   status:
     customStatus: |-
diff --git a/vela-templates/definitions/internal/trait/gateway.cue b/vela-templates/definitions/internal/trait/gateway.cue
index 1dd6926db835db4e7732393b092a82f26e5b1a40..c376fd02e7fc23b1bd051d013ff7eb7fabbdb199 100644
--- a/vela-templates/definitions/internal/trait/gateway.cue
+++ b/vela-templates/definitions/internal/trait/gateway.cue
@@ -1,4 +1,4 @@
-"gateway": {
+gateway: {
 	type: "trait"
 	annotations: {}
 	labels: {}
@@ -49,22 +49,29 @@ template: {
 		metadata: {
 			name: context.name
 			annotations: {
-				"kubernetes.io/ingress.class": parameter.class
+				if !parameter.classInSpec {
+					"kubernetes.io/ingress.class": parameter.class
+				}
 			}
 		}
-		spec: rules: [{
-			host: parameter.domain
-			http: paths: [
-				for k, v in parameter.http {
-					path:     k
-					pathType: "ImplementationSpecific"
-					backend: service: {
-						name: context.name
-						port: number: v
-					}
-				},
-			]
-		}]
+		spec: {
+			if parameter.classInSpec {
+				ingressClassName: parameter.class
+			}
+			rules: [{
+				host: parameter.domain
+				http: paths: [
+					for k, v in parameter.http {
+						path:     k
+						pathType: "ImplementationSpecific"
+						backend: service: {
+							name: context.name
+							port: number: v
+						}
+					},
+				]
+			}]
+		}
 	}
 
 	parameter: {
@@ -76,5 +83,8 @@ template: {
 
 		// +usage=Specify the class of ingress to use
 		class: *"nginx" | string
+
+		// +usage=Set ingress class in '.spec.ingressClassName' instead of 'kubernetes.io/ingress.class' annotation.
+		classInSpec: *false | bool
 	}
 }