Spencer Smith b84d5e2660 feat: allow for exposing ports on docker clusters
This PR will introduce a `-p/--exposed-ports` flag to talosctl. This
flag will allow us to enable port forwards on worker nodes only. This
will allow for ingresses on docker clusters so we can hopefully use
ingress for Arges initial bootstrapping. I modeled this after how KIND allows ingresses
[here](https://kind.sigs.k8s.io/docs/user/ingress/)

Signed-off-by: Spencer Smith <robertspencersmith@gmail.com>
2020-03-30 15:24:25 -04:00

92 lines
2.0 KiB
Go

// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
package provision
import (
"io"
"os"
"github.com/talos-systems/talos/cmd/talosctl/pkg/client"
"github.com/talos-systems/talos/cmd/talosctl/pkg/client/config"
)
// Option controls Provisioner.
type Option func(o *Options) error
// WithLogWriter sets logging destination.
func WithLogWriter(w io.Writer) Option {
return func(o *Options) error {
o.LogWriter = w
return nil
}
}
// WithEndpoint specifies endpoint to use when acessing Talos cluster.
func WithEndpoint(endpoint string) Option {
return func(o *Options) error {
o.ForceEndpoint = endpoint
return nil
}
}
// WithTalosConfig specifies talosconfig to use when acessing Talos cluster.
func WithTalosConfig(talosConfig *config.Config) Option {
return func(o *Options) error {
o.TalosConfig = talosConfig
return nil
}
}
// WithTalosClient specifies client to use when acessing Talos cluster.
func WithTalosClient(client *client.Client) Option {
return func(o *Options) error {
o.TalosClient = client
return nil
}
}
// WithBootladerEmulation enables bootloader emulation.
func WithBootladerEmulation() Option {
return func(o *Options) error {
o.BootloaderEmulation = true
return nil
}
}
// WithDockerPorts allows docker provisioner to expose ports on workers
func WithDockerPorts(ports []string) Option {
return func(o *Options) error {
o.DockerPorts = ports
return nil
}
}
// Options describes Provisioner parameters.
type Options struct {
LogWriter io.Writer
TalosConfig *config.Config
TalosClient *client.Client
ForceEndpoint string
// Enable bootloader by booting from disk image assets.
BootloaderEmulation bool
// Expose ports to worker machines in docker provisioner
DockerPorts []string
}
// DefaultOptions returns default options.
func DefaultOptions() Options {
return Options{
LogWriter: os.Stderr,
}
}