Skip to content

Commit 3fb31d2

Browse files
sugymtpavansaikrishna78
authored andcommitted
Add --disable-coredns-log flag (kubernetes#20992)
1 parent d6c138d commit 3fb31d2

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

cmd/minikube/cmd/start_flags.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ const (
139139
binaryMirror = "binary-mirror"
140140
disableOptimizations = "disable-optimizations"
141141
disableMetrics = "disable-metrics"
142+
disableCoreDNSLog = "disable-coredns-log"
142143
qemuFirmwarePath = "qemu-firmware-path"
143144
socketVMnetClientPath = "socket-vmnet-client-path"
144145
socketVMnetPath = "socket-vmnet-path"
@@ -206,6 +207,7 @@ func initMinikubeFlags() {
206207
startCmd.Flags().String(binaryMirror, "", "Location to fetch kubectl, kubelet, & kubeadm binaries from.")
207208
startCmd.Flags().Bool(disableOptimizations, false, "If set, disables optimizations that are set for local Kubernetes. Including decreasing CoreDNS replicas from 2 to 1. Defaults to false.")
208209
startCmd.Flags().Bool(disableMetrics, false, "If set, disables metrics reporting (CPU and memory usage), this can improve CPU usage. Defaults to false.")
210+
startCmd.Flags().Bool(disableCoreDNSLog, false, "If set, disable CoreDNS verbose logging. Defaults to false.")
209211
startCmd.Flags().String(staticIP, "", "Set a static IP for the minikube cluster, the IP must be: private, IPv4, and the last octet must be between 2 and 254, for example 192.168.200.200 (Docker and Podman drivers only)")
210212
startCmd.Flags().StringP(gpus, "g", "", "Allow pods to use your GPUs. Options include: [all,nvidia,amd] (Docker driver with Docker container-runtime only)")
211213
startCmd.Flags().Duration(autoPauseInterval, time.Minute*1, "Duration of inactivity before the minikube VM is paused (default 1m0s)")
@@ -625,6 +627,7 @@ func generateNewConfigFromFlags(cmd *cobra.Command, k8sVersion string, rtime str
625627
BinaryMirror: viper.GetString(binaryMirror),
626628
DisableOptimizations: viper.GetBool(disableOptimizations),
627629
DisableMetrics: viper.GetBool(disableMetrics),
630+
DisableCoreDNSLog: viper.GetBool(disableCoreDNSLog),
628631
CustomQemuFirmwarePath: viper.GetString(qemuFirmwarePath),
629632
SocketVMnetClientPath: detect.SocketVMNetClientPath(),
630633
SocketVMnetPath: detect.SocketVMNetPath(),

pkg/minikube/config/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ type ClusterConfig struct {
101101
BinaryMirror string // Mirror location for kube binaries (kubectl, kubelet, & kubeadm)
102102
DisableOptimizations bool
103103
DisableMetrics bool
104+
DisableCoreDNSLog bool
104105
CustomQemuFirmwarePath string
105106
SocketVMnetClientPath string
106107
SocketVMnetPath string

pkg/minikube/node/start.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -956,11 +956,15 @@ func addCoreDNSEntry(runner command.Runner, name, ip string, cc config.ClusterCo
956956
sed = fmt.Sprintf("sed -e '/^ hosts {.*/a \\ %s %s'", ip, name)
957957
}
958958

959-
// check if logging is already enabled (via log plugin) in coredns configmap, so not to duplicate it
960-
regex := regexp.MustCompile(`(?smU)^ *log *$`)
961-
if !regex.MatchString(cm) {
962-
// inject log plugin into coredns configmap
963-
sed = fmt.Sprintf("%s -e '/^ errors *$/i \\ log'", sed)
959+
if cc.DisableCoreDNSLog {
960+
sed = fmt.Sprintf("%s -e '/^ log *$/d'", sed)
961+
} else {
962+
// check if logging is already enabled (via log plugin) in coredns configmap, so not to duplicate it
963+
regex := regexp.MustCompile(`(?smU)^ *log *$`)
964+
if !regex.MatchString(cm) {
965+
// inject log plugin into coredns configmap
966+
sed = fmt.Sprintf("%s -e '/^ errors *$/i \\ log'", sed)
967+
}
964968
}
965969

966970
// replace coredns configmap via kubectl

0 commit comments

Comments
 (0)