|
99 | 99 | healthAddr string |
100 | 100 | serviceEndpoints string |
101 | 101 |
|
102 | | - errEKSInvalidFlags = errors.New("invalid EKS flag combination") |
| 102 | + // maxEKSSyncPeriod is the maximum allowed duration for the sync-period flag when using EKS. It is set to 10 minutes |
| 103 | + // because during resync it will create a new AWS auth token which can a maximum life of 15 minutes and this ensures |
| 104 | + // the token (and kubeconfig secret) is refreshed before token expiration. |
| 105 | + maxEKSSyncPeriod = time.Minute * 10 |
| 106 | + errMaxSyncPeriodExceeded = errors.New("sync period greater than maximum allowed") |
| 107 | + errEKSInvalidFlags = errors.New("invalid EKS flag combination") |
103 | 108 | ) |
104 | 109 |
|
105 | 110 | func main() { |
@@ -282,6 +287,11 @@ func enableGates(ctx context.Context, mgr ctrl.Manager, awsServiceEndpoints []sc |
282 | 287 | if feature.Gates.Enabled(feature.EKS) { |
283 | 288 | setupLog.Info("enabling EKS controllers") |
284 | 289 |
|
| 290 | + if syncPeriod > maxEKSSyncPeriod { |
| 291 | + setupLog.Error(errMaxSyncPeriodExceeded, "failed to enable EKS", "max-sync-period", maxEKSSyncPeriod, "syn-period", syncPeriod) |
| 292 | + os.Exit(1) |
| 293 | + } |
| 294 | + |
285 | 295 | enableIAM := feature.Gates.Enabled(feature.EKSEnableIAM) |
286 | 296 | allowAddRoles := feature.Gates.Enabled(feature.EKSAllowAddRoles) |
287 | 297 | setupLog.V(2).Info("EKS IAM role creation", "enabled", enableIAM) |
@@ -432,7 +442,7 @@ func initFlags(fs *pflag.FlagSet) { |
432 | 442 | fs.DurationVar(&syncPeriod, |
433 | 443 | "sync-period", |
434 | 444 | 10*time.Minute, |
435 | | - "The minimum interval at which watched resources are reconciled (e.g. 15m)", |
| 445 | + fmt.Sprintf("The minimum interval at which watched resources are reconciled. If EKS is enabled the maximum allowed is %s", maxEKSSyncPeriod), |
436 | 446 | ) |
437 | 447 |
|
438 | 448 | fs.IntVar(&webhookPort, |
|
0 commit comments