Skip to content

Commit

Permalink
Add support for enable-cadvisor-json-endpoints with Kubelet
Browse files Browse the repository at this point in the history
Kubernetes 1.18 disables this by default.
For backwards compatibility with monitoring tools, it would be nice to
be able to re-enable this.

kubernetes/kubernetes#68522
  • Loading branch information
adrianmoisey committed Mar 3, 2021
1 parent a0c58e9 commit 9e18928
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions k8s/crds/kops.k8s.io_clusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2318,6 +2318,10 @@ spec:
description: DockerDisableSharedPID uses a shared PID namespace
for containers in a pod.
type: boolean
enableCadvisorJsonEndpoints:
description: EnableCadvisorJsonEndpoints enables cAdvisor json
`/spec` and `/stats/*` endpoints. Defaults to False.
type: boolean
enableCustomMetrics:
description: Enable gathering custom metrics.
type: boolean
Expand Down Expand Up @@ -2720,6 +2724,10 @@ spec:
description: DockerDisableSharedPID uses a shared PID namespace
for containers in a pod.
type: boolean
enableCadvisorJsonEndpoints:
description: EnableCadvisorJsonEndpoints enables cAdvisor json
`/spec` and `/stats/*` endpoints. Defaults to False.
type: boolean
enableCustomMetrics:
description: Enable gathering custom metrics.
type: boolean
Expand Down
4 changes: 4 additions & 0 deletions k8s/crds/kops.k8s.io_instancegroups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ spec:
description: DockerDisableSharedPID uses a shared PID namespace
for containers in a pod.
type: boolean
enableCadvisorJsonEndpoints:
description: EnableCadvisorJsonEndpoints enables cAdvisor json
`/spec` and `/stats/*` endpoints. Defaults to False.
type: boolean
enableCustomMetrics:
description: Enable gathering custom metrics.
type: boolean
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ type KubeletConfigSpec struct {
ContainerLogMaxSize string `json:"containerLogMaxSize,omitempty" flag:"container-log-max-size"`
// ContainerLogMaxFiles is the maximum number of container log files that can be present for a container. The number must be >= 2.
ContainerLogMaxFiles *int32 `json:"containerLogMaxFiles,omitempty" flag:"container-log-max-files"`
// EnableCadvisorJsonEndpoints enables cAdvisor json `/spec` and `/stats/*` endpoints. Defaults to False.
EnableCadvisorJsonEndpoints *bool `json:"enableCadvisorJsonEndpoints,omitempty" flag:"enable-cadvisor-json-endpoints"`
}

// KubeProxyConfig defines the configuration for a proxy
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/componentconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ type KubeletConfigSpec struct {
ContainerLogMaxSize string `json:"containerLogMaxSize,omitempty" flag:"container-log-max-size"`
// ContainerLogMaxFiles is the maximum number of container log files that can be present for a container. The number must be >= 2.
ContainerLogMaxFiles *int32 `json:"containerLogMaxFiles,omitempty" flag:"container-log-max-files"`
// EnableCadvisorJsonEndpoints enables cAdvisor json `/spec` and `/stats/*` endpoints. Defaults to False.
EnableCadvisorJsonEndpoints *bool `json:"enableCadvisorJsonEndpoints,omitempty" flag:"enable-cadvisor-json-endpoints"`
}

// KubeProxyConfig defines the configuration for a proxy
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.conversion.go

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

5 changes: 5 additions & 0 deletions pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

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

6 changes: 6 additions & 0 deletions pkg/apis/kops/validation/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,12 @@ func validateKubelet(k *kops.KubeletConfigSpec, c *kops.Cluster, kubeletPath *fi
}
}

if k.EnableCadvisorJsonEndpoints != nil {
if c.IsKubernetesLT("1.18") && c.IsKubernetesGTE("1.21") {
allErrs = append(allErrs, field.Forbidden(kubeletPath.Child("enableCadvisorJsonEndpoints"), "enableCadvisorJsonEndpoints requires Kubernetes 1.18-1.20"))
}
}

}
return allErrs
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/kops/zz_generated.deepcopy.go

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

0 comments on commit 9e18928

Please sign in to comment.