2019-01-09 16:54:15 +00:00
|
|
|
package cmds
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Server struct {
|
2019-04-05 00:43:00 +00:00
|
|
|
ClusterCIDR string
|
|
|
|
ClusterSecret string
|
|
|
|
ServiceCIDR string
|
|
|
|
ClusterDNS string
|
2019-04-12 06:06:35 +00:00
|
|
|
ClusterDomain string
|
2019-04-05 00:43:00 +00:00
|
|
|
HTTPSPort int
|
|
|
|
HTTPPort int
|
|
|
|
DataDir string
|
|
|
|
DisableAgent bool
|
|
|
|
KubeConfigOutput string
|
|
|
|
KubeConfigMode string
|
2019-05-29 18:53:51 +00:00
|
|
|
TLSSan cli.StringSlice
|
2019-04-05 00:43:00 +00:00
|
|
|
BindAddress string
|
|
|
|
ExtraAPIArgs cli.StringSlice
|
|
|
|
ExtraSchedulerArgs cli.StringSlice
|
|
|
|
ExtraControllerArgs cli.StringSlice
|
2019-03-08 22:47:44 +00:00
|
|
|
Rootless bool
|
2019-08-25 05:27:24 +00:00
|
|
|
StoreBootstrap bool
|
2019-05-15 23:05:24 +00:00
|
|
|
StorageEndpoint string
|
2019-06-11 22:48:47 +00:00
|
|
|
StorageCAFile string
|
|
|
|
StorageCertFile string
|
|
|
|
StorageKeyFile string
|
2019-05-29 18:53:51 +00:00
|
|
|
AdvertiseIP string
|
|
|
|
AdvertisePort int
|
2019-07-12 16:59:03 +00:00
|
|
|
DisableScheduler bool
|
2019-01-09 16:54:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var ServerConfig Server
|
|
|
|
|
|
|
|
func NewServerCommand(action func(*cli.Context) error) cli.Command {
|
|
|
|
return cli.Command{
|
|
|
|
Name: "server",
|
|
|
|
Usage: "Run management server",
|
|
|
|
UsageText: appName + " server [OPTIONS]",
|
|
|
|
Action: action,
|
|
|
|
Flags: []cli.Flag{
|
2019-08-08 05:45:54 +00:00
|
|
|
VLevel,
|
|
|
|
VModule,
|
|
|
|
LogFile,
|
|
|
|
AlsoLogToStderr,
|
2019-03-31 00:10:23 +00:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "bind-address",
|
2019-04-12 00:30:49 +00:00
|
|
|
Usage: "k3s bind address (default: localhost)",
|
2019-03-31 00:10:23 +00:00
|
|
|
Destination: &ServerConfig.BindAddress,
|
|
|
|
},
|
2019-01-09 16:54:15 +00:00
|
|
|
cli.IntFlag{
|
|
|
|
Name: "https-listen-port",
|
|
|
|
Usage: "HTTPS listen port",
|
|
|
|
Value: 6443,
|
|
|
|
Destination: &ServerConfig.HTTPSPort,
|
|
|
|
},
|
|
|
|
cli.IntFlag{
|
|
|
|
Name: "http-listen-port",
|
|
|
|
Usage: "HTTP listen port (for /healthz, HTTPS redirect, and port for TLS terminating LB)",
|
|
|
|
Value: 0,
|
|
|
|
Destination: &ServerConfig.HTTPPort,
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "data-dir,d",
|
|
|
|
Usage: "Folder to hold state default /var/lib/rancher/k3s or ${HOME}/.rancher/k3s if not root",
|
|
|
|
Destination: &ServerConfig.DataDir,
|
|
|
|
},
|
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "disable-agent",
|
|
|
|
Usage: "Do not run a local agent and register a local kubelet",
|
|
|
|
Destination: &ServerConfig.DisableAgent,
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "cluster-cidr",
|
|
|
|
Usage: "Network CIDR to use for pod IPs",
|
|
|
|
Destination: &ServerConfig.ClusterCIDR,
|
2019-03-04 05:25:02 +00:00
|
|
|
Value: "10.42.0.0/16",
|
2019-01-09 16:54:15 +00:00
|
|
|
},
|
2019-01-22 21:14:58 +00:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "cluster-secret",
|
|
|
|
Usage: "Shared secret used to bootstrap a cluster",
|
|
|
|
Destination: &ServerConfig.ClusterSecret,
|
|
|
|
EnvVar: "K3S_CLUSTER_SECRET",
|
|
|
|
},
|
2019-03-06 10:37:03 +00:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "service-cidr",
|
|
|
|
Usage: "Network CIDR to use for services IPs",
|
|
|
|
Destination: &ServerConfig.ServiceCIDR,
|
|
|
|
Value: "10.43.0.0/16",
|
|
|
|
},
|
2019-03-06 11:16:04 +00:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "cluster-dns",
|
|
|
|
Usage: "Cluster IP for coredns service. Should be in your service-cidr range",
|
|
|
|
Destination: &ServerConfig.ClusterDNS,
|
2019-03-06 18:41:07 +00:00
|
|
|
Value: "",
|
2019-03-06 11:16:04 +00:00
|
|
|
},
|
2019-04-12 06:06:35 +00:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "cluster-domain",
|
|
|
|
Usage: "Cluster Domain",
|
|
|
|
Destination: &ServerConfig.ClusterDomain,
|
|
|
|
Value: "cluster.local",
|
|
|
|
},
|
2019-01-22 21:14:58 +00:00
|
|
|
cli.StringSliceFlag{
|
|
|
|
Name: "no-deploy",
|
2019-03-02 00:11:10 +00:00
|
|
|
Usage: "Do not deploy packaged components (valid items: coredns, servicelb, traefik)",
|
2019-01-22 21:14:58 +00:00
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "write-kubeconfig,o",
|
|
|
|
Usage: "Write kubeconfig for admin client to this file",
|
|
|
|
Destination: &ServerConfig.KubeConfigOutput,
|
|
|
|
EnvVar: "K3S_KUBECONFIG_OUTPUT",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "write-kubeconfig-mode",
|
|
|
|
Usage: "Write kubeconfig with this mode",
|
|
|
|
Destination: &ServerConfig.KubeConfigMode,
|
|
|
|
EnvVar: "K3S_KUBECONFIG_MODE",
|
|
|
|
},
|
2019-03-23 17:34:55 +00:00
|
|
|
cli.StringSliceFlag{
|
2019-03-25 04:54:52 +00:00
|
|
|
Name: "tls-san",
|
|
|
|
Usage: "Add additional hostname or IP as a Subject Alternative Name in the TLS cert",
|
2019-05-29 18:53:51 +00:00
|
|
|
Value: &ServerConfig.TLSSan,
|
2019-03-18 08:21:55 +00:00
|
|
|
},
|
2019-04-05 00:43:00 +00:00
|
|
|
cli.StringSliceFlag{
|
|
|
|
Name: "kube-apiserver-arg",
|
|
|
|
Usage: "Customized flag for kube-apiserver process",
|
|
|
|
Value: &ServerConfig.ExtraAPIArgs,
|
|
|
|
},
|
|
|
|
cli.StringSliceFlag{
|
|
|
|
Name: "kube-scheduler-arg",
|
|
|
|
Usage: "Customized flag for kube-scheduler process",
|
|
|
|
Value: &ServerConfig.ExtraSchedulerArgs,
|
|
|
|
},
|
|
|
|
cli.StringSliceFlag{
|
|
|
|
Name: "kube-controller-arg",
|
|
|
|
Usage: "Customized flag for kube-controller-manager process",
|
|
|
|
Value: &ServerConfig.ExtraControllerArgs,
|
|
|
|
},
|
2019-03-08 22:47:44 +00:00
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "rootless",
|
|
|
|
Usage: "(experimental) Run rootless",
|
|
|
|
Destination: &ServerConfig.Rootless,
|
|
|
|
},
|
2019-08-25 05:27:24 +00:00
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "bootstrap-save",
|
|
|
|
Usage: "(experimental) Save bootstrap information in the storage endpoint",
|
|
|
|
Hidden: true,
|
|
|
|
Destination: &ServerConfig.StoreBootstrap,
|
|
|
|
},
|
2019-05-15 23:05:24 +00:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "storage-endpoint",
|
2019-06-11 22:48:47 +00:00
|
|
|
Usage: "Specify etcd, Mysql, Postgres, or Sqlite (default) data source name",
|
2019-05-15 23:05:24 +00:00
|
|
|
Destination: &ServerConfig.StorageEndpoint,
|
|
|
|
EnvVar: "K3S_STORAGE_ENDPOINT",
|
|
|
|
},
|
2019-06-11 22:48:47 +00:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "storage-cafile",
|
|
|
|
Usage: "SSL Certificate Authority file used to secure storage backend communication",
|
|
|
|
Destination: &ServerConfig.StorageCAFile,
|
|
|
|
EnvVar: "K3S_STORAGE_CAFILE",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "storage-certfile",
|
|
|
|
Usage: "SSL certification file used to secure storage backend communication",
|
|
|
|
Destination: &ServerConfig.StorageCertFile,
|
|
|
|
EnvVar: "K3S_STORAGE_CERTFILE",
|
|
|
|
},
|
|
|
|
cli.StringFlag{
|
|
|
|
Name: "storage-keyfile",
|
|
|
|
Usage: "SSL key file used to secure storage backend communication",
|
|
|
|
Destination: &ServerConfig.StorageKeyFile,
|
|
|
|
EnvVar: "K3S_STORAGE_KEYFILE",
|
|
|
|
},
|
2019-05-29 18:53:51 +00:00
|
|
|
cli.StringFlag{
|
|
|
|
Name: "advertise-address",
|
|
|
|
Usage: "IP address that apiserver uses to advertise to members of the cluster",
|
|
|
|
Destination: &ServerConfig.AdvertiseIP,
|
|
|
|
},
|
|
|
|
cli.IntFlag{
|
|
|
|
Name: "advertise-port",
|
|
|
|
Usage: "Port that apiserver uses to advertise to members of the cluster",
|
|
|
|
Value: 0,
|
|
|
|
Destination: &ServerConfig.AdvertisePort,
|
|
|
|
},
|
2019-07-12 16:59:03 +00:00
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "disable-scheduler",
|
|
|
|
Usage: "Disable Kubernetes default scheduler",
|
|
|
|
Destination: &ServerConfig.DisableScheduler,
|
|
|
|
},
|
2019-01-09 16:54:15 +00:00
|
|
|
NodeIPFlag,
|
|
|
|
NodeNameFlag,
|
2019-03-02 00:10:18 +00:00
|
|
|
DockerFlag,
|
|
|
|
FlannelFlag,
|
2019-03-19 23:28:43 +00:00
|
|
|
FlannelIfaceFlag,
|
2019-08-08 05:56:09 +00:00
|
|
|
FlannelConfFlag,
|
2019-03-04 06:29:06 +00:00
|
|
|
CRIEndpointFlag,
|
2019-05-03 17:36:12 +00:00
|
|
|
PauseImageFlag,
|
2019-03-26 22:15:16 +00:00
|
|
|
ResolvConfFlag,
|
2019-04-05 00:43:00 +00:00
|
|
|
ExtraKubeletArgs,
|
|
|
|
ExtraKubeProxyArgs,
|
2019-05-07 23:47:07 +00:00
|
|
|
NodeLabels,
|
|
|
|
NodeTaints,
|
2019-01-09 16:54:15 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|