mirror of
https://github.com/rancher/os.git
synced 2025-07-30 22:24:33 +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.Version = config.VERSION
|
||||
app.Author = "Rancher Labs, Inc."
|
||||
app.Email = "darren@rancher.com"
|
||||
app.EnableBashCompletion = true
|
||||
|
||||
app.Commands = []cli.Command{
|
||||
@ -22,12 +21,14 @@ func Main() {
|
||||
Name: "config",
|
||||
ShortName: "c",
|
||||
Usage: "configure settings",
|
||||
HideHelp: true,
|
||||
Subcommands: configSubcommands(),
|
||||
},
|
||||
{
|
||||
Name: "addon",
|
||||
ShortName: "a",
|
||||
Usage: "addon settings",
|
||||
HideHelp: true,
|
||||
Subcommands: addonSubCommands(),
|
||||
},
|
||||
//{
|
||||
@ -39,6 +40,7 @@ func Main() {
|
||||
{
|
||||
Name: "os",
|
||||
Usage: "operating system upgrade/downgrade",
|
||||
HideHelp: true,
|
||||
Subcommands: osSubcommands(),
|
||||
},
|
||||
{
|
||||
|
@ -3,28 +3,50 @@ package config
|
||||
func NewConfig() *Config {
|
||||
return &Config{
|
||||
Debug: DEBUG,
|
||||
Dns: []string{
|
||||
"8.8.8.8",
|
||||
"8.8.4.4",
|
||||
},
|
||||
State: ConfigState{
|
||||
State: StateConfig{
|
||||
Required: false,
|
||||
Dev: "LABEL=RANCHER_STATE",
|
||||
FsType: "auto",
|
||||
},
|
||||
SystemDockerArgs: []string{"docker", "-d", "-s", "overlay", "-b", "none", "--restart=false", "-H", DOCKER_SYSTEM_HOST},
|
||||
Modules: []string{},
|
||||
Userdocker: UserDockerInfo{
|
||||
UseTLS: true,
|
||||
SystemDocker: DockerConfig{
|
||||
Args: []string{
|
||||
"docker",
|
||||
"-d",
|
||||
"-s",
|
||||
"overlay",
|
||||
"-b",
|
||||
"none",
|
||||
"--restart=false",
|
||||
"-g", "/var/lib/system-docker",
|
||||
"-H", DOCKER_SYSTEM_HOST,
|
||||
},
|
||||
},
|
||||
Modules: []string{},
|
||||
UserDocker: DockerConfig{
|
||||
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{
|
||||
Interfaces: []InterfaceConfig{
|
||||
{
|
||||
Match: "eth*",
|
||||
DHCP: true,
|
||||
Dns: DnsConfig{
|
||||
Nameservers: []string{"8.8.8.8", "8.8.4.4"},
|
||||
},
|
||||
Interfaces: map[string]InterfaceConfig{
|
||||
"eth*": {
|
||||
DHCP: true,
|
||||
},
|
||||
{
|
||||
Match: "lo",
|
||||
"lo": {
|
||||
Address: "127.0.0.1/8",
|
||||
},
|
||||
},
|
||||
@ -32,12 +54,28 @@ func NewConfig() *Config {
|
||||
CloudInit: CloudInit{
|
||||
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{
|
||||
{
|
||||
Id: "system-volumes",
|
||||
Cmd: "--name=system-volumes " +
|
||||
"--net=none " +
|
||||
"--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=/lib/modules:/lib/modules:ro " +
|
||||
"-v=/var/run:/var/run " +
|
||||
@ -67,19 +105,42 @@ func NewConfig() *Config {
|
||||
Cmd: "--name=user-volumes " +
|
||||
"--net=none " +
|
||||
"--read-only " +
|
||||
"-v=/var/lib/rancher/state/home:/home " +
|
||||
"-v=/var/lib/rancher/state/opt:/opt " +
|
||||
"-v=/home:/home " +
|
||||
"-v=/opt:/opt " +
|
||||
"state",
|
||||
},
|
||||
{
|
||||
Id: "udev",
|
||||
Cmd: "--name=udev " +
|
||||
Id: "docker-volumes",
|
||||
Cmd: "--name=docker-volumes " +
|
||||
"--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 " +
|
||||
"-v=/dev:/host/dev " +
|
||||
"-v=/lib/modules:/lib/modules:ro " +
|
||||
"udev",
|
||||
"--net=none " +
|
||||
"--read-only " +
|
||||
"--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",
|
||||
@ -133,10 +194,7 @@ func NewConfig() *Config {
|
||||
"--pid=host " +
|
||||
"--net=host " +
|
||||
"--privileged " +
|
||||
"--volumes-from=command-volumes " +
|
||||
"--volumes-from=user-volumes " +
|
||||
"--volumes-from=system-volumes " +
|
||||
"-v=/var/lib/rancher/state/docker:/var/lib/docker " +
|
||||
"--volumes-from=all-volumes " +
|
||||
"userdocker",
|
||||
},
|
||||
{
|
||||
@ -145,9 +203,7 @@ func NewConfig() *Config {
|
||||
"-d " +
|
||||
"--rm " +
|
||||
"--privileged " +
|
||||
"--volumes-from=command-volumes " +
|
||||
"--volumes-from=user-volumes " +
|
||||
"--volumes-from=system-volumes " +
|
||||
"--volumes-from=all-volumes " +
|
||||
"--restart=always " +
|
||||
"--ipc=host " +
|
||||
"--net=host " +
|
||||
@ -165,9 +221,7 @@ func NewConfig() *Config {
|
||||
"-d " +
|
||||
"--rm " +
|
||||
"--privileged " +
|
||||
"--volumes-from=command-volumes " +
|
||||
"--volumes-from=user-volumes " +
|
||||
"--volumes-from=system-volumes " +
|
||||
"--volumes-from=all-volumes " +
|
||||
"--restart=always " +
|
||||
"--ipc=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
|
||||
|
||||
const (
|
||||
VERSION = "0.0.1"
|
||||
VERSION = "0.2.0-dev"
|
||||
CONSOLE_CONTAINER = "console"
|
||||
DOCKER_BIN = "/usr/bin/docker"
|
||||
DOCKER_SYSTEM_HOME = "/var/lib/system-docker"
|
||||
DOCKER_SYSTEM_HOST = "unix:///var/run/system-docker.sock"
|
||||
DOCKER_HOST = "unix:///var/run/docker.sock"
|
||||
IMAGES_PATH = "/"
|
||||
@ -15,6 +16,7 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
CloudConfigFile = "/var/lib/rancher/conf/cloud-config-rancher.yml"
|
||||
ConfigFile = "/var/lib/rancher/conf/rancher.yml"
|
||||
PrivateConfigFile = "/var/lib/rancher/conf/rancher-private.yml"
|
||||
)
|
||||
@ -27,39 +29,43 @@ type ContainerConfig struct {
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
Debug bool `yaml:"debug,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"`
|
||||
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"`
|
||||
Disable []string `yaml:"disable,omitempty"`
|
||||
EnabledAddons []string `yaml:"enabled_addons,omitempty"`
|
||||
Modules []string `yaml:"modules,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 {
|
||||
Tail bool `yaml:"tail,omitempty"`
|
||||
Ephemeral bool `yaml:"ephemeral,omitempty"`
|
||||
Tail bool `yaml:"tail,omitempty"`
|
||||
Persistent bool `yaml:"persistent,omitempty"`
|
||||
}
|
||||
|
||||
type UpgradeConfig struct {
|
||||
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 {
|
||||
Interfaces []InterfaceConfig `yaml:"interfaces,omitempty"`
|
||||
PostRun *ContainerConfig `yaml:"post_run,omitempty"`
|
||||
Dns DnsConfig `yaml:"dns,omitempty"`
|
||||
Interfaces map[string]InterfaceConfig `yaml:"interfaces,omitempty"`
|
||||
PostRun *ContainerConfig `yaml:"post_run,omitempty"`
|
||||
}
|
||||
|
||||
type InterfaceConfig struct {
|
||||
@ -70,21 +76,25 @@ type InterfaceConfig struct {
|
||||
MTU int `yaml:"mtu,omitempty"`
|
||||
}
|
||||
|
||||
type UserDockerConfig struct {
|
||||
UseTLS bool `yaml:"use_tls,omitempty"`
|
||||
TLSServerCert string `yaml:"tls_server_cert,omitempty"`
|
||||
TLSServerKey string `yaml:"tls_server_key,omitempty"`
|
||||
TLSCACert string `yaml:"tls_ca_cert,omitempty"`
|
||||
type DockerConfig struct {
|
||||
TLS bool `yaml:"tls,omitempty"`
|
||||
TLSArgs []string `yaml:"tls_args,flow,omitempty"`
|
||||
Args []string `yaml:"args,flow,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 {
|
||||
Keys map[string]string `yaml:"keys,omitempty"`
|
||||
}
|
||||
|
||||
type ConfigState struct {
|
||||
FsType string `yaml:"fstype,omitempty"`
|
||||
Dev string `yaml:"dev,omitempty"`
|
||||
Required bool `yaml:"required,omitempty"`
|
||||
type StateConfig struct {
|
||||
FsType string `yaml:"fstype,omitempty"`
|
||||
Dev string `yaml:"dev,omitempty"`
|
||||
Required bool `yaml:"required,omitempty"`
|
||||
Autoformat []string `yaml:"autoformat,omitempty"`
|
||||
}
|
||||
|
||||
type CloudInit struct {
|
||||
|
Loading…
Reference in New Issue
Block a user