Skip to content

Commit 3ed490d

Browse files
authored
Merge pull request #44 from ttsuuubasa/docs-settings
docs: Add settings.md and script for auto-generating this doc
2 parents 90d40fd + 6d22897 commit 3ed490d

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

docs/docs/settings.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Settings
2+
3+
[comment]: <> (the content below is generated from hack/docs/settings_gen/main.go)
4+
5+
Karpenter exposes environment variables and CLI flags that allow you to configure controller behavior. The available settings are outlined below.
6+
7+
| Environment Variable | CLI Flag | Description |
8+
|--|--|--|
9+
| BATCH_IDLE_DURATION | \-\-batch-idle-duration | The maximum amount of time with no new pending pods that if exceeded ends the current batching window. If pods arrive faster than this time, the batching window will be extended up to the maxDuration. If they arrive slower, the pods will be batched separately. (default = 1s)|
10+
| BATCH_MAX_DURATION | \-\-batch-max-duration | The maximum length of a batch window. The longer this is, the more pods we can consider for provisioning at one time which usually results in fewer but larger nodes. (default = 10s)|
11+
| CLUSTER_API_CERTIFICATE_AUTHORITY_DATA | \-\-cluster-api-certificate-authority-data | The cert certificate authority of the cluster api manager cluster|
12+
| CLUSTER_API_KUBECONFIG | \-\-cluster-api-kubeconfig | The path to the cluster api manager cluster kubeconfig file. Defaults to service account credentials if not specified.|
13+
| CLUSTER_API_SKIP_TLS_VERIFY | \-\-cluster-api-skip-tls-verify | Skip the check for certificate for validity of the cluster api manager cluster. This will make HTTPS connections insecure|
14+
| CLUSTER_API_TOKEN | \-\-cluster-api-token | The Bearer token for authentication of the cluster api manager cluster|
15+
| CLUSTER_API_URL | \-\-cluster-api-url | The url of the cluster api manager cluster|
16+
| DISABLE_LEADER_ELECTION | \-\-disable-leader-election | Disable the leader election client before executing the main loop. Disable when running replicated components for high availability is not desired.|
17+
| ENABLE_PROFILING | \-\-enable-profiling | Enable the profiling on the metric endpoint|
18+
| FEATURE_GATES | \-\-feature-gates | Optional features can be enabled / disabled using feature gates. Current options are: NodeRepair, ReservedCapacity, and SpotToSpotConsolidation (default = NodeRepair=false,ReservedCapacity=false,SpotToSpotConsolidation=false)|
19+
| HEALTH_PROBE_PORT | \-\-health-probe-port | The port the health probe endpoint binds to for reporting controller health (default = 8081)|
20+
| KARPENTER_SERVICE | \-\-karpenter-service | The Karpenter Service name for the dynamic webhook certificate|
21+
| KUBE_CLIENT_BURST | \-\-kube-client-burst | The maximum allowed burst of queries to the kube-apiserver (default = 300)|
22+
| KUBE_CLIENT_QPS | \-\-kube-client-qps | The smoothed rate of qps to kube-apiserver (default = 200)|
23+
| LEADER_ELECTION_NAME | \-\-leader-election-name | Leader election name to create and monitor the lease if running outside the cluster (default = karpenter-leader-election)|
24+
| LEADER_ELECTION_NAMESPACE | \-\-leader-election-namespace | Leader election namespace to create and monitor the lease if running outside the cluster|
25+
| LOG_ERROR_OUTPUT_PATHS | \-\-log-error-output-paths | Optional comma separated paths for logging error output (default = stderr)|
26+
| LOG_LEVEL | \-\-log-level | Log verbosity level. Can be one of 'debug', 'info', or 'error' (default = info)|
27+
| LOG_OUTPUT_PATHS | \-\-log-output-paths | Optional comma separated paths for directing log output (default = stdout)|
28+
| MEMORY_LIMIT | \-\-memory-limit | Memory limit on the container running the controller. The GC soft memory limit is set to 90% of this value. (default = -1)|
29+
| METRICS_PORT | \-\-metrics-port | The port the metric endpoint binds to for operating metrics about the controller itself (default = 8080)|
30+
| PREFERENCE_POLICY | \-\-preference-policy | How the Karpenter scheduler should treat preferences. Preferences include preferredDuringSchedulingIgnoreDuringExecution node and pod affinities/anti-affinities and ScheduleAnyways topologySpreadConstraints. Can be one of 'Ignore' and 'Respect' (default = Respect)|

hack/docs/settings_gen/main.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"flag"
21+
"fmt"
22+
"log"
23+
"os"
24+
"strings"
25+
26+
"sigs.k8s.io/karpenter-provider-cluster-api/pkg/operator/options"
27+
coreoptions "sigs.k8s.io/karpenter/pkg/operator/options"
28+
)
29+
30+
func main() {
31+
if len(os.Args) != 2 {
32+
log.Fatalf("Usage: go run main.go <path/to/settings.md>")
33+
}
34+
outputFileName := os.Args[1]
35+
36+
title := "# Settings\n\n"
37+
comment := "[comment]: <> (the content below is generated from hack/docs/settings_gen/main.go)\n\n"
38+
description := "Karpenter exposes environment variables and CLI flags that allow you to configure controller behavior. The available settings are outlined below.\n\n"
39+
40+
fs := &coreoptions.FlagSet{
41+
FlagSet: flag.NewFlagSet("karpenter", flag.ContinueOnError),
42+
}
43+
(&coreoptions.Options{}).AddFlags(fs)
44+
(&options.Options{}).AddFlags(fs)
45+
46+
envVarsTable := "| Environment Variable | CLI Flag | Description |\n"
47+
envVarsTable += "|--|--|--|\n"
48+
fs.VisitAll(func(f *flag.Flag) {
49+
if f.DefValue == "" {
50+
envVarsTable += fmt.Sprintf("| %s | %s | %s|\n", strings.ReplaceAll(strings.ToUpper(f.Name), "-", "_"), "\\-\\-"+f.Name, f.Usage)
51+
} else {
52+
envVarsTable += fmt.Sprintf("| %s | %s | %s (default = %s)|\n", strings.ReplaceAll(strings.ToUpper(f.Name), "-", "_"), "\\-\\-"+f.Name, f.Usage, f.DefValue)
53+
}
54+
})
55+
56+
log.Println("writing output to", outputFileName)
57+
err := os.WriteFile(outputFileName, []byte(title+comment+description+envVarsTable), 0644)
58+
if err != nil {
59+
log.Fatalf("failed to write file %s, %s", outputFileName, err)
60+
}
61+
}

0 commit comments

Comments
 (0)