Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ GO_BUILD_FLAGS :=-tags 'include_gcs include_oss containers_image_openpgp gssapi
GO_TEST_FLAGS=$(GO_BUILD_FLAGS)
GO_TEST_PACKAGES=./cmd/... ./pkg/...

all: microshift etcd
all: generate-config microshift etcd

# target "build:" defined in vendor/github.com/openshift/build-machinery-go/make/targets/golang/build.mk
# Disable CGO when building microshift binary
Expand All @@ -121,7 +121,7 @@ verify: verify-fast

# Fast verification checks that developers can/should run locally
.PHONY: verify-fast
verify-fast: verify-go verify-assets verify-sh verify-py
verify-fast: verify-go verify-assets verify-sh verify-py verify-config

# Full verification checks that should run in CI
.PHONY: verify-ci
Expand Down Expand Up @@ -312,3 +312,12 @@ vendor-etcd:
verify: verify-vendor-etcd
verify-vendor-etcd: vendor-etcd
./hack/verify-vendor-etcd.sh

# Use helper `go generate script` to dynamically config information into packaging info as well as documentation.
.PHONY: generate-config verify-config
generate-config:
./scripts/fetch_tools.sh controller-gen && \
go generate -mod vendor ./pkg/config

verify-config: generate-config
./hack/verify-config.sh
132 changes: 132 additions & 0 deletions cockpit-plugin/packaging/config-openapi-spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
{
"type": "object",
"required": [
"apiServer",
"debugging",
"dns",
"etcd",
"network",
"node"
],
"properties": {
"apiServer": {
"type": "object",
"required": [
"subjectAltNames"
],
"properties": {
"advertiseAddress": {
"description": "Kube apiserver advertise address to work around the certificates issue when requiring external access using the node IP. This will turn into the IP configured in the endpoint slice for kubernetes service. Must be a reachable IP from pods. Defaults to service network CIDR first address.",
"type": "string"
},
"subjectAltNames": {
"description": "SubjectAltNames added to API server certs",
"type": "array",
"items": {
"type": "string"
}
}
}
},
"debugging": {
"type": "object",
"required": [
"logLevel"
],
"properties": {
"logLevel": {
"description": "Valid values are: \"Normal\", \"Debug\", \"Trace\", \"TraceAll\". Defaults to \"Normal\".",
"type": "string",
"default": "Normal"
}
}
},
"dns": {
"type": "object",
"required": [
"baseDomain"
],
"properties": {
"baseDomain": {
"description": "baseDomain is the base domain of the cluster. All managed DNS records will be sub-domains of this base. \n For example, given the base domain `example.com`, router exposed domains will be formed as `*.apps.example.com` by default, and API service will have a DNS entry for `api.example.com`, as well as \"api-int.example.com\" for internal k8s API access. \n Once set, this field cannot be changed.",
"type": "string",
"default": "example.com",
"example": "microshift.example.com"
}
}
},
"etcd": {
"type": "object",
"required": [
"memoryLimitMB"
],
"properties": {
"memoryLimitMB": {
"description": "Set a memory limit on the etcd process; etcd will begin paging memory when it gets to this value. 0 means no limit.",
"type": "integer",
"format": "int64"
}
}
},
"network": {
"type": "object",
"required": [
"clusterNetwork",
"serviceNetwork",
"serviceNodePortRange"
],
"properties": {
"clusterNetwork": {
"description": "IP address pool to use for pod IPs. This field is immutable after installation.",
"type": "array",
"items": {
"type": "object",
"required": [
"cidr"
],
"properties": {
"cidr": {
"description": "The complete block for pod IPs.",
"type": "string",
"default": "10.42.0.0/16"
}
}
}
},
"serviceNetwork": {
"description": "IP address pool for services. Currently, we only support a single entry here. This field is immutable after installation.",
"type": "array",
"default": [
"10.43.0.0/16"
],
"items": {
"type": "string"
}
},
"serviceNodePortRange": {
"description": "The port range allowed for Services of type NodePort. If not specified, the default of 30000-32767 will be used. Such Services without a NodePort specified will have one automatically allocated from this range. This parameter can be updated after the cluster is installed.",
"type": "string",
"default": "30000-32767",
"pattern": "^([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])-([0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5])$"
}
}
},
"node": {
"type": "object",
"required": [
"hostnameOverride",
"nodeIP"
],
"properties": {
"hostnameOverride": {
"description": "If non-empty, will use this string to identify the node instead of the hostname",
"type": "string"
},
"nodeIP": {
"description": "IP address of the node, passed to the kubelet. If not specified, kubelet will use the node's default IP address.",
"type": "string"
}
}
}
}
}
79 changes: 48 additions & 31 deletions docs/howto_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,68 @@
The MicroShift configuration file must be located at `/etc/microshift/config.yaml`. A sample `/etc/microshift/config.yaml.default` configuration file is installed by the MicroShift RPM and it can be used as a template when customizing MicroShift.

The format of the `config.yaml` configuration file is as follows.

<!---
{{- template "docsReplaceBasic" . }}
{{- with deleteCurrent -}}
--->
```yaml
dns:
baseDomain: ""
network:
clusterNetwork:
- cidr: ""
serviceNetwork:
- ""
serviceNodePortRange: ""
node:
hostnameOverride: ""
nodeIP: ""
apiServer:
subjectAltNames:
- ""
advertiseAddress: ""
subjectAltNames:
- ""
debugging:
logLevel: ""
logLevel: ""
dns:
baseDomain: ""
etcd:
memoryLimitMB: 0
memoryLimitMB: 0
network:
clusterNetwork:
- cidr: ""
serviceNetwork:
- ""
serviceNodePortRange: ""
node:
hostnameOverride: ""
nodeIP: ""

```
<!---
{{- end }}
--->

## Default Settings

In case `config.yaml` is not provided, the following default settings will be used.

<!---
{{- template "docsReplaceFull" . }}
{{- with deleteCurrent -}}
--->
```yaml
dns:
baseDomain: microshift.example.com
network:
clusterNetwork:
- cidr: 10.42.0.0/16
serviceNetwork:
- 10.43.0.0/16
serviceNodePortRange: 30000-32767
node:
hostnameOverride: ""
nodeIP: ''
apiServer:
subjectAltNames: []
advertiseAddress: ""
subjectAltNames:
- ""
debugging:
logLevel: "Normal"
logLevel: Normal
dns:
baseDomain: example.com
etcd:
memoryLimitMB: 0
memoryLimitMB: 0
network:
clusterNetwork:
- cidr: 10.42.0.0/16
serviceNetwork:
- 10.43.0.0/16
serviceNodePortRange: 30000-32767
node:
hostnameOverride: ""
nodeIP: ""

```
<!---
{{- end }}
--->

## Service NodePort range

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions etcd/vendor/github.com/openshift/microshift/pkg/config/dns.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions hack/config-gen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Config-Gen

This is a simple generator tool that will read files for a specific struct and generate a yaml representation of it with comments to help keep things in sync. This is meant to be used as part of the `//go:generate` command but can also be installed and used as a stand alone binary.

### Install

```sh
go install .
```

### Usage

CLI flags.

```sh
Usage:
config-gen [flags]

Flags:
-a, --api-output string output path for openapi spec if desired
-f, --file string default is stdin
-h, --help help for config-gen
-o, --output string output path, default is stdout
-t, --template string template file to use
-v, --v Level number for the log level verbosity
```

Use as a go generate command example
```go
//go:generate sh -c "controller-gen crd paths=../../hack/config-gen/configcrd output:stdout | go run -mod vendor ../../hack/config-gen -a ../../cockpit-plugin/packaging/config-openapi-spec.json -o ../../packaging/microshift/config.yaml"
//go:generate sh -c "controller-gen crd paths=../../hack/config-gen/configcrd output:stdout | go run -mod vendor ../../hack/config-gen -o ../../docs/howto_config.md -t ../../docs/howto_config.md"
```

Use the example test to see it in action, run the command from the `hack/config-gen` directory.

```sh
controller-gen crd paths=../../hack/config-gen/configcrd output:stdout | go run -mod vendor ../../hack/config-gen
```

The sample output should be.
```yaml
#!! Do Not Edit
#!! This is a generated file
apiServer:
# Kube apiserver advertise address to work around the certificates issue when requiring external access using the node IP. This will turn into the IP configured in the endpoint slice for kubernetes service. Must be a reachable IP from pods. Defaults to service network CIDR first address.
advertiseAddress: ""
# SubjectAltNames added to API server certs
subjectAltNames:
- ""
debugging:
# Valid values are: "Normal", "Debug", "Trace", "TraceAll". Defaults to "Normal".
logLevel: Normal
dns:
# baseDomain is the base domain of the cluster. All managed DNS records will be sub-domains of this base.
# For example, given the base domain `example.com`, router exposed domains will be formed as `*.apps.example.com` by default, and API service will have a DNS entry for `api.example.com`, as well as "api-int.example.com" for internal k8s API access.
# Once set, this field cannot be changed.
# example:
# microshift.example.com
baseDomain: example.com
etcd:
# Set a memory limit on the etcd process; etcd will begin paging memory when it gets to this value. 0 means no limit.
memoryLimitMB: 0
network:
# IP address pool to use for pod IPs. This field is immutable after installation.
clusterNetwork:
- # The complete block for pod IPs.
cidr: 10.42.0.0/16
# IP address pool for services. Currently, we only support a single entry here. This field is immutable after installation.
serviceNetwork:
- ""
# The port range allowed for Services of type NodePort. If not specified, the default of 30000-32767 will be used. Such Services without a NodePort specified will have one automatically allocated from this range. This parameter can be updated after the cluster is installed.
serviceNodePortRange: 30000-32767
node:
# If non-empty, will use this string to identify the node instead of the hostname
hostnameOverride: ""
# IP address of the node, passed to the kubelet. If not specified, kubelet will use the node's default IP address.
nodeIP: ""
```
Loading