2016-10-10 08:22:15 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"text/template"
|
|
|
|
|
|
|
|
"github.com/kubernetes-incubator/cri-o/server"
|
|
|
|
"github.com/urfave/cli"
|
|
|
|
)
|
|
|
|
|
|
|
|
var commentedConfigTemplate = template.Must(template.New("config").Parse(`
|
2017-05-12 13:36:15 +00:00
|
|
|
# The "crio" table contains all of the server options.
|
|
|
|
[crio]
|
2016-10-10 08:22:15 +00:00
|
|
|
|
2017-05-15 22:05:58 +00:00
|
|
|
# root is a path to the "root directory". CRIO stores all of its data,
|
2016-10-18 14:48:33 +00:00
|
|
|
# including container images, in this directory.
|
2016-10-10 08:22:15 +00:00
|
|
|
root = "{{ .Root }}"
|
|
|
|
|
2017-05-15 22:05:58 +00:00
|
|
|
# run is a path to the "run directory". CRIO stores all of its state
|
2016-10-18 14:48:33 +00:00
|
|
|
# in this directory.
|
|
|
|
runroot = "{{ .RunRoot }}"
|
2016-10-10 08:22:15 +00:00
|
|
|
|
2016-10-18 14:48:33 +00:00
|
|
|
# storage_driver select which storage driver is used to manage storage
|
|
|
|
# of images and containers.
|
|
|
|
storage_driver = "{{ .Storage }}"
|
|
|
|
|
|
|
|
# storage_option is used to pass an option to the storage driver.
|
|
|
|
storage_option = [
|
|
|
|
{{ range $opt := .StorageOptions }}{{ printf "\t%q,\n" $opt }}{{ end }}]
|
2016-10-10 08:22:15 +00:00
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
# The "crio.api" table contains settings for the kubelet/gRPC
|
|
|
|
# interface (which is also used by crioctl).
|
|
|
|
[crio.api]
|
2016-10-10 08:22:15 +00:00
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
# listen is the path to the AF_LOCAL socket on which crio will listen.
|
2016-10-10 08:22:15 +00:00
|
|
|
listen = "{{ .Listen }}"
|
|
|
|
|
2017-06-12 22:31:16 +00:00
|
|
|
# stream_address is the IP address on which the stream server will listen
|
|
|
|
stream_address = "{{ .StreamAddress }}"
|
|
|
|
|
|
|
|
# stream_port is the port on which the stream server will listen
|
|
|
|
stream_port = "{{ .StreamPort }}"
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
# The "crio.runtime" table contains settings pertaining to the OCI
|
2016-10-10 08:22:15 +00:00
|
|
|
# runtime used and options for how to set up and manage the OCI runtime.
|
2017-05-12 13:36:15 +00:00
|
|
|
[crio.runtime]
|
2016-10-10 08:22:15 +00:00
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
# runtime is a path to the OCI runtime which crio will be using.
|
2016-10-10 08:22:15 +00:00
|
|
|
runtime = "{{ .Runtime }}"
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
# runtime_host_privileged is a path to the OCI runtime which crio
|
2017-02-20 23:33:01 +00:00
|
|
|
# will be using for host privileged operations.
|
2017-05-12 13:36:15 +00:00
|
|
|
# If this string is empty, crio will not try to use the "runtime"
|
2017-02-20 23:33:01 +00:00
|
|
|
# for all operations.
|
|
|
|
runtime_host_privileged = "{{ .RuntimeHostPrivileged }}"
|
|
|
|
|
2016-10-10 08:22:15 +00:00
|
|
|
# conmon is the path to conmon binary, used for managing the runtime.
|
|
|
|
conmon = "{{ .Conmon }}"
|
|
|
|
|
2016-10-17 07:44:27 +00:00
|
|
|
# conmon_env is the environment variable list for conmon process,
|
|
|
|
# used for passing necessary environment variable to conmon or runtime.
|
|
|
|
conmon_env = [
|
|
|
|
{{ range $env := .ConmonEnv }}{{ printf "\t%q,\n" $env }}{{ end }}]
|
|
|
|
|
2016-10-10 08:22:15 +00:00
|
|
|
# selinux indicates whether or not SELinux will be used for pod
|
|
|
|
# separation on the host. If you enable this flag, SELinux must be running
|
|
|
|
# on the host.
|
|
|
|
selinux = {{ .SELinux }}
|
|
|
|
|
2016-11-23 09:41:48 +00:00
|
|
|
# seccomp_profile is the seccomp json profile path which is used as the
|
|
|
|
# default for the runtime.
|
|
|
|
seccomp_profile = "{{ .SeccompProfile }}"
|
|
|
|
|
2016-11-30 08:19:36 +00:00
|
|
|
# apparmor_profile is the apparmor profile name which is used as the
|
|
|
|
# default for the runtime.
|
|
|
|
apparmor_profile = "{{ .ApparmorProfile }}"
|
|
|
|
|
2016-12-19 23:01:27 +00:00
|
|
|
# cgroup_manager is the cgroup management implementation to be used
|
|
|
|
# for the runtime.
|
|
|
|
cgroup_manager = "{{ .CgroupManager }}"
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
# The "crio.image" table contains settings pertaining to the
|
2016-10-10 08:22:15 +00:00
|
|
|
# management of OCI images.
|
2017-05-12 13:36:15 +00:00
|
|
|
[crio.image]
|
2016-10-10 08:22:15 +00:00
|
|
|
|
2016-10-18 14:48:33 +00:00
|
|
|
# default_transport is the prefix we try prepending to an image name if the
|
|
|
|
# image name as we receive it can't be parsed as a valid source reference
|
|
|
|
default_transport = "{{ .DefaultTransport }}"
|
|
|
|
|
|
|
|
# pause_image is the image which we use to instantiate infra containers.
|
|
|
|
pause_image = "{{ .PauseImage }}"
|
|
|
|
|
|
|
|
# pause_command is the command to run in a pause_image to have a container just
|
|
|
|
# sit there. If the image contains the necessary information, this value need
|
|
|
|
# not be specified.
|
|
|
|
pause_command = "{{ .PauseCommand }}"
|
|
|
|
|
|
|
|
# signature_policy is the name of the file which decides what sort of policy we
|
|
|
|
# use when deciding whether or not to trust an image that we've pulled.
|
|
|
|
# Outside of testing situations, it is strongly advised that this be left
|
|
|
|
# unspecified so that the default system-wide policy will be used.
|
|
|
|
signature_policy = "{{ .SignaturePolicyPath }}"
|
2016-12-17 11:23:07 +00:00
|
|
|
|
2017-06-08 13:45:34 +00:00
|
|
|
# insecure_registries is used to skip TLS verification when pulling images.
|
|
|
|
insecure_registries = [
|
|
|
|
{{ range $opt := .InsecureRegistries }}{{ printf "\t%q,\n" $opt }}{{ end }}]
|
|
|
|
|
2017-05-12 13:36:15 +00:00
|
|
|
# The "crio.network" table contains settings pertaining to the
|
2016-12-17 11:23:07 +00:00
|
|
|
# management of CNI plugins.
|
2017-05-12 13:36:15 +00:00
|
|
|
[crio.network]
|
2016-12-17 11:23:07 +00:00
|
|
|
|
|
|
|
# network_dir is is where CNI network configuration
|
|
|
|
# files are stored.
|
|
|
|
network_dir = "{{ .NetworkDir }}"
|
|
|
|
|
|
|
|
# plugin_dir is is where CNI plugin binaries are stored.
|
|
|
|
plugin_dir = "{{ .PluginDir }}"
|
2016-10-10 08:22:15 +00:00
|
|
|
`))
|
|
|
|
|
2016-10-21 09:50:49 +00:00
|
|
|
// TODO: Currently ImageDir isn't really used, so we haven't added it to this
|
|
|
|
// template. Add it once the storage code has been merged.
|
|
|
|
|
2016-10-10 08:22:15 +00:00
|
|
|
var configCommand = cli.Command{
|
|
|
|
Name: "config",
|
2017-05-12 13:36:15 +00:00
|
|
|
Usage: "generate crio configuration files",
|
2016-10-10 08:22:15 +00:00
|
|
|
Flags: []cli.Flag{
|
|
|
|
cli.BoolFlag{
|
|
|
|
Name: "default",
|
|
|
|
Usage: "output the default configuration",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Action: func(c *cli.Context) error {
|
|
|
|
// At this point, app.Before has already parsed the user's chosen
|
|
|
|
// config file. So no need to handle that here.
|
|
|
|
config := c.App.Metadata["config"].(*server.Config)
|
|
|
|
if c.Bool("default") {
|
2017-01-17 00:20:35 +00:00
|
|
|
config = server.DefaultConfig()
|
2016-10-10 08:22:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Output the commented config.
|
|
|
|
return commentedConfigTemplate.ExecuteTemplate(os.Stdout, "config", config)
|
|
|
|
},
|
|
|
|
}
|