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

Adding flags from specific backend implementation #83

Closed
ppwfx opened this issue Dec 22, 2016 · 3 comments · Fixed by #272
Closed

Adding flags from specific backend implementation #83

ppwfx opened this issue Dec 22, 2016 · 3 comments · Fixed by #272

Comments

@ppwfx
Copy link

ppwfx commented Dec 22, 2016

Hey,

we are implementing our own version of the ingress controller right now. We would like to add some additional flags, but we can't find any way to accomplish it without touching the generic code.

We added the SetFlags function to the generic launch.go

func SetFlags(flags *pflag.FlagSet) {
	defaultSvc = flags.String("default-backend-service", "",
		`Service used to serve a 404 page for the default backend. Takes the form
    namespace/name. The controller uses the first node port of this Service for
    the default backend.`)

	ingressClass = flags.String("ingress-class", "",
		`Name of the ingress class to route through this controller.`)

	configMap = flags.String("configmap", "",
		`Name of the ConfigMap that contains the custom configuration to use`)

	publishSvc = flags.String("publish-service", "",
		`Service fronting the ingress controllers. Takes the form
	 namespace/name. The controller will set the endpoint records on the
	 ingress objects to reflect those on the service.`)

	tcpConfigMapName = flags.String("tcp-services-configmap", "",
		`Name of the ConfigMap that contains the definition of the TCP services to expose.
	The key in the map indicates the external port to be used. The value is the name of the
	service with the format namespace/serviceName and the port of the service could be a
	number of the name of the port.
	The ports 80 and 443 are not allowed as external ports. This ports are reserved for the backend`)

	udpConfigMapName = flags.String("udp-services-configmap", "",
		`Name of the ConfigMap that contains the definition of the UDP services to expose.
	The key in the map indicates the external port to be used. The value is the name of the
	service with the format namespace/serviceName and the port of the service could be a
	number of the name of the port.`)

	resyncPeriod = flags.Duration("sync-period", 60*time.Second,
		`Relist and confirm cloud resources this often.`)

	watchNamespace = flags.String("watch-namespace", api.NamespaceAll,
		`Namespace to watch for Ingress. Default is to watch all namespaces`)

	healthzPort = flags.Int("healthz-port", 10254, "port for healthz endpoint.")

	profiling = flags.Bool("profiling", true, `Enable profiling via web interface host:port/debug/pprof/`)

	defSSLCertificate = flags.String("default-ssl-certificate", "", `Name of the secret
		that contains a SSL certificate to be used as default for a HTTPS catch-all server`)

	defHealthzURL = flags.String("health-check-path", "/healthz", `Defines
		the URL to be used as health check inside in the default server in NGINX.`)

	k8sClientConfig = kubectl_util.DefaultClientConfig(flags)
}

and call it in our main.go

var (
	flags *pflag.FlagSet
	reloadCommand *string
	webhookEndpoint *string
	templateFile *string
	outputFile *string
)



func init()  {
	flags = pflag.NewFlagSet("", pflag.ExitOnError)
	reloadCommand = flags.String("ReloadCommand", "nginx -s reload", "Command that will be triggered whenever the nginx configuration changes")
	webhookEndpoint = flags.String("WebhookEndpoint", "http://127.0.0.1:8888/set", "Webhook that will be notified whenever new endpoints are added")
	templateFile = flags.String("TemplateFile", "/etc/nginx/nginx.tmpl", "Template to be rendered")
	outputFile = flags.String("OutputFile", "/etc/nginx/nginx.conf", "Location of rendered template")

	controller.SetFlags(flags)

	flags.AddGoFlagSet(flag.CommandLine)
	flags.Parse(os.Args)
}

Do you know of any way to do it in a more elegant fashion? We tried a lot things, but I either wipes the generic flags or all..

Any ideas?

Best regards

@ppwfx
Copy link
Author

ppwfx commented Jan 24, 2017

Still an issue..

@aledbf
Copy link
Member

aledbf commented Feb 14, 2017

@21stio please check @272

The idea is that in the Override method you can add the flags you need to add or change
and the after you call NewIngressController you can add the code you need from the flags

@ppwfx
Copy link
Author

ppwfx commented Feb 16, 2017

Alright, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants