k0s icon indicating copy to clipboard operation
k0s copied to clipboard

Generate a commented default config

Open kke opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe.

In many software packages, the first and often the only necessary point of configuration documentation is the default configuration file.

Take sshd for example:

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

Apache httpd:

# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk.  If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
ServerRoot "/usr/local"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80
Listen 443

Influxdb:

### Welcome to the InfluxDB configuration file.

# Once every 24 hours InfluxDB will report anonymous data to m.influxdb.com
# The data includes raft id (random 8 bytes), os, arch, version, and metadata.
# We don't track ip addresses of servers reporting. This is only used
# to track the number of instances running and the versions, which
# is very helpful for us.
# Change this option to true to enable reporting.
reporting-enabled = false

# we'll try to get the hostname automatically, but if it the os returns something
# that isn't resolvable by other servers in the cluster, use this option to
# manually set the hostname
# hostname = "localhost"

[meta]
  # Controls if this node should run the metaservice and participate in the Raft group
  enabled = true

  # Where the metadata/raft database is stored
  dir = "/var/lib/influxdb/meta"

Etcd:

# This is the configuration file for the etcd server.

# Human-readable name for this member.
name: 'default'

# Path to the data directory.
data-dir:

# Number of committed transactions to trigger a snapshot to disk.
snapshot-count: 10000

# Time (in milliseconds) of a heartbeat interval.
heartbeat-interval: 100

For k0s however:

apiVersion: k0s.k0sproject.io/v1beta1
kind: ClusterConfig
metadata:
  creationTimestamp: null
  name: k0s
spec:
  api:
    address: 10.2.3.4
    k0sApiPort: 9443
    port: 6443
    sans:
    - 172.19.0.1
    - 172.18.0.1
    - 172.20.0.1
    - 172.17.0.1
    tunneledNetworkingMode: false
  controllerManager: {}
  ....
  ....
  ....

Some of the available settings are not even listed at all in the generated config (for example extraArgs because it has omitempty):

	// Map of key-values (strings) for any extra arguments to pass down to Kubernetes api-server process
	ExtraArgs map[string]string `json:"extraArgs,omitempty"`

Somewhat related: #1551

Describe the solution you would like

The output of k0s config create should also be like this.

Something like:

spec:
  api:
    # The port kubernetes API listens on
    port: 6443
    # The port k0s API listens on
    k0sApiPort: 9443

It is possible to use go tags and then programmatically generate the doc-comments or it could be hand-written and then maintained manually. Also the CRD could be utilized:

                  extraArgs:
                    additionalProperties:
                      type: string
                    description: Map of key-values (strings) for any extra arguments
                      to pass down to Kubernetes api-server process
                    type: object
                  k0sApiPort:
                    description: 'Custom port for k0s-api server to listen on (default:
                      9443)'
                    type: integer
                  port:
                    description: 'Custom port for kube-api server to listen on (default:
                      6443)'
                    type: integer

Describe alternatives you've considered

The example at https://docs.k0sproject.io/main/configuration/#configuration-file-reference could be manually documented. It's not auto-generated so we should be updating it whenever there are any changes to the config anyway.

Additional context

  • http://www.catb.org/~esr/writings/taoup/html/configurationchapter.html
  • https://en.wikipedia.org/wiki/Configuration_file

kke avatar Feb 22 '22 08:02 kke