Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/contour: optional CRDs #5080

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions changelogs/unreleased/5080-nsimons-minor.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Allow Disabling Features
nsimons marked this conversation as resolved.
Show resolved Hide resolved

The `contour serve` command takes a new optional flag, `--disable-feature`, that allows disabling
certain features.

Currently this flag can be used to disable the informer for ExtensionService resources,
effectively making the ExtensionService CRD optional in the cluster.
To do this, use the flag as follows: `--disable-feature=extensionservices`
15 changes: 12 additions & 3 deletions cmd/contour/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ func registerServe(app *kingpin.Application) (*kingpin.CmdClause, *serveContext)
serve.Flag("debug", "Enable debug logging.").Short('d').BoolVar(&ctx.Config.Debug)
serve.Flag("debug-http-address", "Address the debug http endpoint will bind to.").PlaceHolder("<ipaddr>").StringVar(&ctx.debugAddr)
serve.Flag("debug-http-port", "Port the debug http endpoint will bind to.").PlaceHolder("<port>").IntVar(&ctx.debugPort)
serve.Flag("disable-feature", "Do not start an informer for the specified resources.").PlaceHolder("<extensionservices>").EnumsVar(&ctx.disabledFeatures, "extensionservices")
serve.Flag("disable-leader-election", "Disable leader election mechanism.").BoolVar(&ctx.LeaderElection.Disable)

serve.Flag("envoy-http-access-log", "Envoy HTTP access log.").PlaceHolder("/path/to/file").StringVar(&ctx.httpAccessLog)
Expand Down Expand Up @@ -469,14 +470,22 @@ func (s *Server) doServe() error {
Counter: contourMetrics.EventHandlerOperations,
}

// Inform on default resources.
for name, r := range map[string]client.Object{
// Start to build informers.
informerResources := map[string]client.Object{
"httpproxies": &contour_api_v1.HTTPProxy{},
"tlscertificatedelegations": &contour_api_v1.TLSCertificateDelegation{},
"extensionservices": &contour_api_v1alpha1.ExtensionService{},
"services": &corev1.Service{},
"ingresses": &networking_v1.Ingress{},
} {
}

// Some of the resources are optional and can be disabled, do not create informers for those.
for _, feat := range s.ctx.disabledFeatures {
delete(informerResources, feat)
}

// Inform on the remaining resources.
for name, r := range informerResources {
if err := informOnResource(r, eventHandler, s.mgr.GetCache()); err != nil {
s.log.WithError(err).WithField("resource", name).Fatal("failed to create informer")
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/contour/servecontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ type serveContext struct {

// Leader election configuration.
LeaderElection LeaderElection

// Features disabled by the user.
disabledFeatures []string
}

type ServerConfig struct {
Expand Down
1 change: 1 addition & 0 deletions site/content/docs/main/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Many of these flags are mirrored in the [Contour Configuration File](#configurat
| `--use-proxy-protocol` | Use PROXY protocol for all listeners |
| `--accesslog-format=<envoy\|json>` | Format for Envoy access logs |
| `--disable-leader-election` | Disable leader election mechanism |
| `--disable-feature=<extensionservices>` | Do not start an informer for the specified resources. |
| `--leader-election-lease-duration` | The duration of the leadership lease. |
| `--leader-election-renew-deadline` | The duration leader will retry refreshing leadership before giving up. |
| `--leader-election-retry-period` | The interval which Contour will attempt to acquire leadership lease. |
Expand Down
6 changes: 6 additions & 0 deletions site/content/docs/main/deploy-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ Next, pass `--envoy-service-http-port=80 --envoy-service-https-port=443` to the
This is best paired with a DaemonSet (perhaps paired with Node affinity) to ensure that a single instance of Contour runs on each Node.
See the [AWS NLB tutorial][10] as an example.

## Disabling Features

You can run Contour with certain features disabled by passing `--disable-feature` flag to the Contour `serve` command.
Currently this flag can be used to disable the informer for ExtensionService resources, effectively making the ExtensionService CRD optional in the cluster.
To do this, use the flag as follows: `--disable-feature=extensionservices`

## Upgrading Contour/Envoy

At times, it's needed to upgrade Contour, the version of Envoy, or both.
Expand Down