@@ -46,7 +46,6 @@ type ContourRouter struct {
4646
4747// Reconcile creates or updates the HTTP proxy
4848func (cr * ContourRouter ) Reconcile (canary * flaggerv1.Canary ) error {
49- const annotation = "projectcontour.io/ingress.class"
5049
5150 apexName , primaryName , canaryName := canary .GetServiceNames ()
5251
@@ -163,6 +162,10 @@ func (cr *ContourRouter) Reconcile(canary *flaggerv1.Canary) error {
163162 }
164163 newMetadata .Annotations = filterMetadata (newMetadata .Annotations )
165164
165+ if cr .ingressClass != "" {
166+ newSpec .IngressClassName = cr .ingressClass
167+ }
168+
166169 proxy , err := cr .contourClient .ProjectcontourV1 ().HTTPProxies (canary .Namespace ).Get (context .TODO (), apexName , metav1.GetOptions {})
167170 if errors .IsNotFound (err ) {
168171 proxy = & contourv1.HTTPProxy {
@@ -189,10 +192,7 @@ func (cr *ContourRouter) Reconcile(canary *flaggerv1.Canary) error {
189192 }
190193
191194 if cr .ingressClass != "" {
192- if proxy .Annotations == nil {
193- proxy .Annotations = make (map [string ]string )
194- }
195- proxy .Annotations [annotation ] = cr .ingressClass
195+ proxy .Spec .IngressClassName = cr .ingressClass
196196 }
197197
198198 _ , err = cr .contourClient .ProjectcontourV1 ().HTTPProxies (canary .Namespace ).Create (context .TODO (), proxy , metav1.CreateOptions {})
@@ -382,6 +382,10 @@ func (cr *ContourRouter) SetRoutes(
382382 }
383383 }
384384
385+ if cr .ingressClass != "" {
386+ proxy .Spec .IngressClassName = cr .ingressClass
387+ }
388+
385389 _ , err = cr .contourClient .ProjectcontourV1 ().HTTPProxies (canary .Namespace ).Update (context .TODO (), proxy , metav1.UpdateOptions {})
386390 if err != nil {
387391 return fmt .Errorf ("HTTPProxy %s.%s update error: %w" , apexName , canary .Namespace , err )
0 commit comments