mirror of
https://github.com/rancher/os.git
synced 2025-08-06 17:24:16 +00:00
Refactor default configuration
This commit is contained in:
parent
3756bbae90
commit
5877e586b8
@ -14,7 +14,6 @@ func Main() {
|
|||||||
app.Usage = "Control and configure RancherOS"
|
app.Usage = "Control and configure RancherOS"
|
||||||
app.Version = config.VERSION
|
app.Version = config.VERSION
|
||||||
app.Author = "Rancher Labs, Inc."
|
app.Author = "Rancher Labs, Inc."
|
||||||
app.Email = "darren@rancher.com"
|
|
||||||
app.EnableBashCompletion = true
|
app.EnableBashCompletion = true
|
||||||
|
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
@ -22,12 +21,14 @@ func Main() {
|
|||||||
Name: "config",
|
Name: "config",
|
||||||
ShortName: "c",
|
ShortName: "c",
|
||||||
Usage: "configure settings",
|
Usage: "configure settings",
|
||||||
|
HideHelp: true,
|
||||||
Subcommands: configSubcommands(),
|
Subcommands: configSubcommands(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Name: "addon",
|
Name: "addon",
|
||||||
ShortName: "a",
|
ShortName: "a",
|
||||||
Usage: "addon settings",
|
Usage: "addon settings",
|
||||||
|
HideHelp: true,
|
||||||
Subcommands: addonSubCommands(),
|
Subcommands: addonSubCommands(),
|
||||||
},
|
},
|
||||||
//{
|
//{
|
||||||
@ -39,6 +40,7 @@ func Main() {
|
|||||||
{
|
{
|
||||||
Name: "os",
|
Name: "os",
|
||||||
Usage: "operating system upgrade/downgrade",
|
Usage: "operating system upgrade/downgrade",
|
||||||
|
HideHelp: true,
|
||||||
Subcommands: osSubcommands(),
|
Subcommands: osSubcommands(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -3,28 +3,50 @@ package config
|
|||||||
func NewConfig() *Config {
|
func NewConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
Debug: DEBUG,
|
Debug: DEBUG,
|
||||||
Dns: []string{
|
State: StateConfig{
|
||||||
"8.8.8.8",
|
|
||||||
"8.8.4.4",
|
|
||||||
},
|
|
||||||
State: ConfigState{
|
|
||||||
Required: false,
|
Required: false,
|
||||||
Dev: "LABEL=RANCHER_STATE",
|
Dev: "LABEL=RANCHER_STATE",
|
||||||
FsType: "auto",
|
FsType: "auto",
|
||||||
},
|
},
|
||||||
SystemDockerArgs: []string{"docker", "-d", "-s", "overlay", "-b", "none", "--restart=false", "-H", DOCKER_SYSTEM_HOST},
|
SystemDocker: DockerConfig{
|
||||||
|
Args: []string{
|
||||||
|
"docker",
|
||||||
|
"-d",
|
||||||
|
"-s",
|
||||||
|
"overlay",
|
||||||
|
"-b",
|
||||||
|
"none",
|
||||||
|
"--restart=false",
|
||||||
|
"-g", "/var/lib/system-docker",
|
||||||
|
"-H", DOCKER_SYSTEM_HOST,
|
||||||
|
},
|
||||||
|
},
|
||||||
Modules: []string{},
|
Modules: []string{},
|
||||||
Userdocker: UserDockerInfo{
|
UserDocker: DockerConfig{
|
||||||
UseTLS: true,
|
TLSArgs: []string{
|
||||||
|
"--tlsverify",
|
||||||
|
"--tlscacert=ca.pem",
|
||||||
|
"--tlscert=server-cert.pem",
|
||||||
|
"--tlskey=server-key.pem",
|
||||||
|
"-H=0.0.0.0:2376",
|
||||||
|
},
|
||||||
|
Args: []string{
|
||||||
|
"docker",
|
||||||
|
"-d",
|
||||||
|
"-s", "overlay",
|
||||||
|
"-G", "docker",
|
||||||
|
"-H", DOCKER_HOST,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Network: NetworkConfig{
|
Network: NetworkConfig{
|
||||||
Interfaces: []InterfaceConfig{
|
Dns: DnsConfig{
|
||||||
{
|
Nameservers: []string{"8.8.8.8", "8.8.4.4"},
|
||||||
Match: "eth*",
|
},
|
||||||
|
Interfaces: map[string]InterfaceConfig{
|
||||||
|
"eth*": {
|
||||||
DHCP: true,
|
DHCP: true,
|
||||||
},
|
},
|
||||||
{
|
"lo": {
|
||||||
Match: "lo",
|
|
||||||
Address: "127.0.0.1/8",
|
Address: "127.0.0.1/8",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -32,12 +54,28 @@ func NewConfig() *Config {
|
|||||||
CloudInit: CloudInit{
|
CloudInit: CloudInit{
|
||||||
Datasources: []string{"configdrive:/media/config-2"},
|
Datasources: []string{"configdrive:/media/config-2"},
|
||||||
},
|
},
|
||||||
|
Upgrade: UpgradeConfig{
|
||||||
|
Url: "https://cdn.rancher.io/rancheros/versions.yml",
|
||||||
|
},
|
||||||
|
BootstrapContainers: []ContainerConfig{
|
||||||
|
{
|
||||||
|
Id: "udev",
|
||||||
|
Cmd: "--name=udev " +
|
||||||
|
"--net=none " +
|
||||||
|
"--privileged " +
|
||||||
|
"--rm " +
|
||||||
|
"-v=/dev:/host/dev " +
|
||||||
|
"-v=/lib/modules:/lib/modules:ro " +
|
||||||
|
"udev",
|
||||||
|
},
|
||||||
|
},
|
||||||
SystemContainers: []ContainerConfig{
|
SystemContainers: []ContainerConfig{
|
||||||
{
|
{
|
||||||
Id: "system-volumes",
|
Id: "system-volumes",
|
||||||
Cmd: "--name=system-volumes " +
|
Cmd: "--name=system-volumes " +
|
||||||
"--net=none " +
|
"--net=none " +
|
||||||
"--read-only " +
|
"--read-only " +
|
||||||
|
"-v=/etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/ca-certificates.crt " +
|
||||||
"-v=/var/lib/rancher/conf:/var/lib/rancher/conf " +
|
"-v=/var/lib/rancher/conf:/var/lib/rancher/conf " +
|
||||||
"-v=/lib/modules:/lib/modules:ro " +
|
"-v=/lib/modules:/lib/modules:ro " +
|
||||||
"-v=/var/run:/var/run " +
|
"-v=/var/run:/var/run " +
|
||||||
@ -67,19 +105,42 @@ func NewConfig() *Config {
|
|||||||
Cmd: "--name=user-volumes " +
|
Cmd: "--name=user-volumes " +
|
||||||
"--net=none " +
|
"--net=none " +
|
||||||
"--read-only " +
|
"--read-only " +
|
||||||
"-v=/var/lib/rancher/state/home:/home " +
|
"-v=/home:/home " +
|
||||||
"-v=/var/lib/rancher/state/opt:/opt " +
|
"-v=/opt:/opt " +
|
||||||
"state",
|
"state",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Id: "udev",
|
Id: "docker-volumes",
|
||||||
Cmd: "--name=udev " +
|
Cmd: "--name=docker-volumes " +
|
||||||
"--net=none " +
|
"--net=none " +
|
||||||
"--privileged " +
|
"--read-only " +
|
||||||
|
"-v=/var/lib/docker:/var/lib/docker " +
|
||||||
|
"-v=/var/lib/system-docker:/var/lib/system-docker " +
|
||||||
|
"state",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Id: "all-volumes",
|
||||||
|
Cmd: "--name=all-volumes " +
|
||||||
"--rm " +
|
"--rm " +
|
||||||
"-v=/dev:/host/dev " +
|
"--net=none " +
|
||||||
"-v=/lib/modules:/lib/modules:ro " +
|
"--read-only " +
|
||||||
"udev",
|
"--volumes-from=docker-volumes " +
|
||||||
|
"--volumes-from=command-volumes " +
|
||||||
|
"--volumes-from=user-volumes " +
|
||||||
|
"--volumes-from=system-volumes " +
|
||||||
|
"state",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Id: "cloud-init-pre",
|
||||||
|
Cmd: "--name=cloud-init-pre " +
|
||||||
|
"--rm " +
|
||||||
|
"--privileged " +
|
||||||
|
"--net=host " +
|
||||||
|
"-e CLOUD_INIT_NETWORK=false " +
|
||||||
|
"--volumes-from=command-volumes " +
|
||||||
|
"--volumes-from=system-volumes " +
|
||||||
|
"cloudinit",
|
||||||
|
ReloadConfig: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Id: "network",
|
Id: "network",
|
||||||
@ -133,10 +194,7 @@ func NewConfig() *Config {
|
|||||||
"--pid=host " +
|
"--pid=host " +
|
||||||
"--net=host " +
|
"--net=host " +
|
||||||
"--privileged " +
|
"--privileged " +
|
||||||
"--volumes-from=command-volumes " +
|
"--volumes-from=all-volumes " +
|
||||||
"--volumes-from=user-volumes " +
|
|
||||||
"--volumes-from=system-volumes " +
|
|
||||||
"-v=/var/lib/rancher/state/docker:/var/lib/docker " +
|
|
||||||
"userdocker",
|
"userdocker",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -145,9 +203,7 @@ func NewConfig() *Config {
|
|||||||
"-d " +
|
"-d " +
|
||||||
"--rm " +
|
"--rm " +
|
||||||
"--privileged " +
|
"--privileged " +
|
||||||
"--volumes-from=command-volumes " +
|
"--volumes-from=all-volumes " +
|
||||||
"--volumes-from=user-volumes " +
|
|
||||||
"--volumes-from=system-volumes " +
|
|
||||||
"--restart=always " +
|
"--restart=always " +
|
||||||
"--ipc=host " +
|
"--ipc=host " +
|
||||||
"--net=host " +
|
"--net=host " +
|
||||||
@ -165,9 +221,7 @@ func NewConfig() *Config {
|
|||||||
"-d " +
|
"-d " +
|
||||||
"--rm " +
|
"--rm " +
|
||||||
"--privileged " +
|
"--privileged " +
|
||||||
"--volumes-from=command-volumes " +
|
"--volumes-from=all-volumes " +
|
||||||
"--volumes-from=user-volumes " +
|
|
||||||
"--volumes-from=system-volumes " +
|
|
||||||
"--restart=always " +
|
"--restart=always " +
|
||||||
"--ipc=host " +
|
"--ipc=host " +
|
||||||
"--net=host " +
|
"--net=host " +
|
||||||
@ -177,20 +231,5 @@ func NewConfig() *Config {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
RescueContainer: &ContainerConfig{
|
|
||||||
Id: "console",
|
|
||||||
Cmd: "--name=rescue " +
|
|
||||||
"-d " +
|
|
||||||
"--rm " +
|
|
||||||
"--privileged " +
|
|
||||||
"--volumes-from=console-volumes " +
|
|
||||||
"--volumes-from=user-volumes " +
|
|
||||||
"--volumes-from=system-volumes " +
|
|
||||||
"--restart=always " +
|
|
||||||
"--ipc=host " +
|
|
||||||
"--net=host " +
|
|
||||||
"--pid=host " +
|
|
||||||
"rescue",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
const (
|
const (
|
||||||
VERSION = "0.0.1"
|
VERSION = "0.2.0-dev"
|
||||||
CONSOLE_CONTAINER = "console"
|
CONSOLE_CONTAINER = "console"
|
||||||
DOCKER_BIN = "/usr/bin/docker"
|
DOCKER_BIN = "/usr/bin/docker"
|
||||||
|
DOCKER_SYSTEM_HOME = "/var/lib/system-docker"
|
||||||
DOCKER_SYSTEM_HOST = "unix:///var/run/system-docker.sock"
|
DOCKER_SYSTEM_HOST = "unix:///var/run/system-docker.sock"
|
||||||
DOCKER_HOST = "unix:///var/run/docker.sock"
|
DOCKER_HOST = "unix:///var/run/docker.sock"
|
||||||
IMAGES_PATH = "/"
|
IMAGES_PATH = "/"
|
||||||
@ -15,6 +16,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
CloudConfigFile = "/var/lib/rancher/conf/cloud-config-rancher.yml"
|
||||||
ConfigFile = "/var/lib/rancher/conf/rancher.yml"
|
ConfigFile = "/var/lib/rancher/conf/rancher.yml"
|
||||||
PrivateConfigFile = "/var/lib/rancher/conf/rancher-private.yml"
|
PrivateConfigFile = "/var/lib/rancher/conf/rancher-private.yml"
|
||||||
)
|
)
|
||||||
@ -27,38 +29,42 @@ type ContainerConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
Addons map[string]Config `yaml:"addons,omitempty"`
|
||||||
|
BootstrapContainers []ContainerConfig `yaml:"bootstrap_containers,omitempty"`
|
||||||
|
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
|
||||||
|
Console ConsoleConfig `yaml:"console,omitempty"`
|
||||||
Debug bool `yaml:"debug,omitempty"`
|
Debug bool `yaml:"debug,omitempty"`
|
||||||
Disable []string `yaml:"disable,omitempty"`
|
Disable []string `yaml:"disable,omitempty"`
|
||||||
Dns []string `yaml:"dns,flow,omitempty"`
|
|
||||||
//Rescue bool `yaml:"rescue,omitempty"`
|
|
||||||
//RescueContainer *ContainerConfig `yaml:"rescue_container,omitempty"`
|
|
||||||
Console ConsoleConfig `yaml:"console,omitempty"`
|
|
||||||
State ConfigState `yaml:"state,omitempty"`
|
|
||||||
Userdocker UserDockerConfig `yaml:"userdocker,omitempty"`
|
|
||||||
Upgrade UpgradeConfig `yaml:"upgrade,omitempty"`
|
|
||||||
BootstrapContainers []ContainerConfig `yaml:"bootstrap_containers,omitempty"`
|
|
||||||
SystemContainers []ContainerConfig `yaml:"system_containers,omitempty"`
|
|
||||||
UserContainers []ContainerConfig `yaml:"user_containers,omitempty"`
|
|
||||||
SystemDockerArgs []string `yaml:"system_docker_args,flow,omitempty"`
|
|
||||||
Modules []string `yaml:"modules,omitempty"`
|
|
||||||
CloudInit CloudInit `yaml:"cloud_init,omitempty"`
|
|
||||||
Ssh SshConfig `yaml:"ssh,omitempty"`
|
|
||||||
EnabledAddons []string `yaml:"enabled_addons,omitempty"`
|
EnabledAddons []string `yaml:"enabled_addons,omitempty"`
|
||||||
Addons map[string]Config `yaml:"addons,omitempty"`
|
Modules []string `yaml:"modules,omitempty"`
|
||||||
Network NetworkConfig `yaml:"network,omitempty"`
|
Network NetworkConfig `yaml:"network,omitempty"`
|
||||||
|
Ssh SshConfig `yaml:"ssh,omitempty"`
|
||||||
|
State StateConfig `yaml:"state,omitempty"`
|
||||||
|
SystemContainers []ContainerConfig `yaml:"system_containers,omitempty"`
|
||||||
|
SystemDocker DockerConfig `yaml:"system_docker,omitempty"`
|
||||||
|
Upgrade UpgradeConfig `yaml:"upgrade,omitempty"`
|
||||||
|
UserContainers []ContainerConfig `yaml:"user_containers,omitempty"`
|
||||||
|
UserDocker DockerConfig `yaml:"user_docker,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConsoleConfig struct {
|
type ConsoleConfig struct {
|
||||||
Tail bool `yaml:"tail,omitempty"`
|
Tail bool `yaml:"tail,omitempty"`
|
||||||
Ephemeral bool `yaml:"ephemeral,omitempty"`
|
Persistent bool `yaml:"persistent,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UpgradeConfig struct {
|
type UpgradeConfig struct {
|
||||||
Url string `yaml:"url,omitempty"`
|
Url string `yaml:"url,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DnsConfig struct {
|
||||||
|
Nameservers []string `yaml:"nameservers,flow,omitempty"`
|
||||||
|
Search []string `yaml:"search,flow,omitempty"`
|
||||||
|
Domain string `yaml:"domain,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
type NetworkConfig struct {
|
type NetworkConfig struct {
|
||||||
Interfaces []InterfaceConfig `yaml:"interfaces,omitempty"`
|
Dns DnsConfig `yaml:"dns,omitempty"`
|
||||||
|
Interfaces map[string]InterfaceConfig `yaml:"interfaces,omitempty"`
|
||||||
PostRun *ContainerConfig `yaml:"post_run,omitempty"`
|
PostRun *ContainerConfig `yaml:"post_run,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,21 +76,25 @@ type InterfaceConfig struct {
|
|||||||
MTU int `yaml:"mtu,omitempty"`
|
MTU int `yaml:"mtu,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type UserDockerConfig struct {
|
type DockerConfig struct {
|
||||||
UseTLS bool `yaml:"use_tls,omitempty"`
|
TLS bool `yaml:"tls,omitempty"`
|
||||||
TLSServerCert string `yaml:"tls_server_cert,omitempty"`
|
TLSArgs []string `yaml:"tls_args,flow,omitempty"`
|
||||||
TLSServerKey string `yaml:"tls_server_key,omitempty"`
|
Args []string `yaml:"args,flow,omitempty"`
|
||||||
TLSCACert string `yaml:"tls_ca_cert,omitempty"`
|
ServerCert string `yaml:"server_cert,omitempty"`
|
||||||
|
ServerKey string `yaml:"server_key,omitempty"`
|
||||||
|
CACert string `yaml:"ca_cert,omitempty"`
|
||||||
|
CAKey string `yaml:"ca_key,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SshConfig struct {
|
type SshConfig struct {
|
||||||
Keys map[string]string `yaml:"keys,omitempty"`
|
Keys map[string]string `yaml:"keys,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ConfigState struct {
|
type StateConfig struct {
|
||||||
FsType string `yaml:"fstype,omitempty"`
|
FsType string `yaml:"fstype,omitempty"`
|
||||||
Dev string `yaml:"dev,omitempty"`
|
Dev string `yaml:"dev,omitempty"`
|
||||||
Required bool `yaml:"required,omitempty"`
|
Required bool `yaml:"required,omitempty"`
|
||||||
|
Autoformat []string `yaml:"autoformat,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type CloudInit struct {
|
type CloudInit struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user