Skip to content

Commit cc41bba

Browse files
authored
Merge pull request #10022 from olemarkus/metrics-server
Kubelet serving certificate and metrics server addon
2 parents f819dce + fdaf5eb commit cc41bba

File tree

19 files changed

+597
-4
lines changed

19 files changed

+597
-4
lines changed

addons/metrics-server/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Kubernetes Metrics Server
22

3+
**This addon is deprecated. Set `spec.metricsServer.enabled: true` instead**
4+
35
## User guide
46

57
You can find the user guide in

cmd/kops-controller/pkg/server/server.go

+6
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ func (s *Server) issueCert(name string, pubKey string, id *fi.VerifyResult, vali
175175
CommonName: fmt.Sprintf("system:node:%s", id.NodeName),
176176
Organization: []string{rbac.NodesGroup},
177177
}
178+
case "kubelet-server":
179+
issueReq.Subject = pkix.Name{
180+
CommonName: id.NodeName,
181+
}
182+
issueReq.AlternateNames = []string{id.NodeName}
183+
issueReq.Type = "server"
178184
case "kube-proxy":
179185
issueReq.Subject = pkix.Name{
180186
CommonName: rbac.KubeProxy,

docs/releases/1.19-NOTES.md

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ The expiration times vary randomly so that nodes are likely to have their certs
4242

4343
* New command for deleting a single instance: [kops delete instance](/docs/cli/kops_delete_instance/)
4444

45+
* Metrics Server is now available as a configurable addon. Add `spec.metricsServer.enabled: true` to the cluster spec to enable.
46+
4547
# Breaking changes
4648

4749
* Support for Kubernetes 1.9 and 1.10 has been removed.
@@ -62,6 +64,8 @@ The expiration times vary randomly so that nodes are likely to have their certs
6264

6365
* Support for feature flag `Terraform-0.12` has been deprecated and will be removed in kops 1.20. All generated Terraform HCL2/JSON files will support versions `0.12.26+` and `0.13.0+`.
6466

67+
* The [manifest based metrics server addon](https://github.com/kubernetes/kops/tree/master/addons/metrics-server) has been deprecated in favour of a configurable addon.
68+
6569
# Full change list since 1.18.0 release
6670

6771
## v1.18.0-alpha.3 to v1.19.0-alpha.1

k8s/crds/kops.k8s.io_clusters.yaml

+10
Original file line numberDiff line numberDiff line change
@@ -2088,6 +2088,16 @@ spec:
20882088
masterPublicName:
20892089
description: MasterPublicName is the external DNS name for the master nodes
20902090
type: string
2091+
metricsServer:
2092+
description: MetricsServerConfig determines the metrics server configuration.
2093+
properties:
2094+
enabled:
2095+
description: 'Enabled enables the metrics server. Default: false'
2096+
type: boolean
2097+
image:
2098+
description: 'Image is the docker container used. Default: the latest supported image for the specified kubernetes version.'
2099+
type: string
2100+
type: object
20912101
networkCIDR:
20922102
description: NetworkCIDR is the CIDR used for the AWS VPC / GCE Network, or otherwise allocated to k8s This is a real CIDR, not the internal k8s network On AWS, it maps to the VPC CIDR. It is not required on GCE.
20932103
type: string

nodeup/pkg/model/kubelet.go

+58
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ var _ fi.ModelBuilder = &KubeletBuilder{}
5656

5757
// Build is responsible for building the kubelet configuration
5858
func (b *KubeletBuilder) Build(c *fi.ModelBuilderContext) error {
59+
60+
err := b.buildKubeletServingCertificate(c)
61+
if err != nil {
62+
return fmt.Errorf("error building kubelet server cert: %v", err)
63+
}
64+
5965
kubeletConfig, err := b.buildKubeletConfig()
6066
if err != nil {
6167
return fmt.Errorf("error building kubelet config: %v", err)
@@ -226,6 +232,11 @@ func (b *KubeletBuilder) buildSystemdEnvironmentFile(kubeletConfig *kops.Kubelet
226232
}
227233
}
228234

235+
if b.UseKopsControllerForNodeBootstrap() {
236+
flags += " --tls-cert-file=" + b.PathSrvKubernetes() + "/kubelet-server.crt"
237+
flags += " --tls-private-key-file=" + b.PathSrvKubernetes() + "/kubelet-server.key"
238+
}
239+
229240
sysconfig := "DAEMON_ARGS=\"" + flags + "\"\n"
230241
// Makes kubelet read /root/.docker/config.json properly
231242
sysconfig = sysconfig + "HOME=\"/root" + "\"\n"
@@ -538,3 +549,50 @@ func (b *KubeletBuilder) buildMasterKubeletKubeconfig(c *fi.ModelBuilderContext)
538549

539550
return b.BuildIssuedKubeconfig("kubelet", certName, c), nil
540551
}
552+
553+
func (b *KubeletBuilder) buildKubeletServingCertificate(c *fi.ModelBuilderContext) error {
554+
555+
if b.UseKopsControllerForNodeBootstrap() {
556+
name := "kubelet-server"
557+
dir := b.PathSrvKubernetes()
558+
signer := fi.CertificateIDCA
559+
560+
nodeName, err := b.NodeName()
561+
if err != nil {
562+
return err
563+
}
564+
565+
if !b.IsMaster {
566+
cert, key := b.GetBootstrapCert(name)
567+
568+
c.AddTask(&nodetasks.File{
569+
Path: filepath.Join(dir, name+".crt"),
570+
Contents: cert,
571+
Type: nodetasks.FileType_File,
572+
Mode: fi.String("0644"),
573+
})
574+
575+
c.AddTask(&nodetasks.File{
576+
Path: filepath.Join(dir, name+".key"),
577+
Contents: key,
578+
Type: nodetasks.FileType_File,
579+
Mode: fi.String("0400"),
580+
})
581+
582+
} else {
583+
issueCert := &nodetasks.IssueCert{
584+
Name: name,
585+
Signer: signer,
586+
Type: "server",
587+
Subject: nodetasks.PKIXName{
588+
CommonName: nodeName,
589+
},
590+
AlternateNames: []string{nodeName},
591+
}
592+
c.AddTask(issueCert)
593+
return issueCert.AddFileTasks(c, dir, name, "", nil)
594+
}
595+
}
596+
return nil
597+
598+
}

pkg/apis/kops/cluster.go

+2
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,8 @@ type ClusterSpec struct {
160160

161161
// NodeTerminationHandlerConfig determines the cluster autoscaler configuration.
162162
NodeTerminationHandler *NodeTerminationHandlerConfig `json:"nodeTerminationHandler,omitempty"`
163+
// MetricsServerConfig determines the metrics server configuration.
164+
MetricsServer *MetricsServerConfig `json:"metricsServer,omitempty"`
163165

164166
// Networking configuration
165167
Networking *NetworkingSpec `json:"networking,omitempty"`

pkg/apis/kops/componentconfig.go

+10
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,16 @@ type ClusterAutoscalerConfig struct {
803803
Image *string `json:"image,omitempty"`
804804
}
805805

806+
// MetricsServerConfig determines the metrics server configuration.
807+
type MetricsServerConfig struct {
808+
// Enabled enables the metrics server.
809+
// Default: false
810+
Enabled *bool `json:"enabled,omitempty"`
811+
// Image is the docker container used.
812+
// Default: the latest supported image for the specified kubernetes version.
813+
Image *string `json:"image,omitempty"`
814+
}
815+
806816
// HasAdmissionController checks if a specific admission controller is enabled
807817
func (c *KubeAPIServerConfig) HasAdmissionController(name string) bool {
808818
for _, x := range c.AdmissionControl {

pkg/apis/kops/v1alpha2/cluster.go

+2
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ type ClusterSpec struct {
159159

160160
// NodeTerminationHandlerConfig determines the cluster autoscaler configuration.
161161
NodeTerminationHandler *NodeTerminationHandlerConfig `json:"nodeTerminationHandler,omitempty"`
162+
// MetricsServerConfig determines the metrics server configuration.
163+
MetricsServer *MetricsServerConfig `json:"metricsServer,omitempty"`
162164

163165
// Networking configuration
164166
Networking *NetworkingSpec `json:"networking,omitempty"`

pkg/apis/kops/v1alpha2/componentconfig.go

+10
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,16 @@ type ClusterAutoscalerConfig struct {
804804
Image *string `json:"image,omitempty"`
805805
}
806806

807+
// MetricsServerConfig determines the metrics server configuration.
808+
type MetricsServerConfig struct {
809+
// Enabled enables the metrics server.
810+
// Default: false
811+
Enabled *bool `json:"enabled,omitempty"`
812+
// Image is the docker container used.
813+
// Default: the latest supported image for the specified kubernetes version.
814+
Image *string `json:"image,omitempty"`
815+
}
816+
807817
// HasAdmissionController checks if a specific admission controller is enabled
808818
func (c *KubeAPIServerConfig) HasAdmissionController(name string) bool {
809819
for _, x := range c.AdmissionControl {

pkg/apis/kops/v1alpha2/zz_generated.conversion.go

+50
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/kops/zz_generated.deepcopy.go

+31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)