From ce8759f406135709967985a8bc40b7af05384364 Mon Sep 17 00:00:00 2001 From: Ole Markus With Date: Wed, 7 Oct 2020 20:01:22 +0200 Subject: [PATCH] Add metrics-server addon --- k8s/crds/kops.k8s.io_clusters.yaml | 10 + pkg/apis/kops/cluster.go | 2 + pkg/apis/kops/componentconfig.go | 10 + pkg/apis/kops/v1alpha2/cluster.go | 2 + pkg/apis/kops/v1alpha2/componentconfig.go | 10 + .../kops/v1alpha2/zz_generated.conversion.go | 50 +++++ .../kops/v1alpha2/zz_generated.deepcopy.go | 31 +++ pkg/apis/kops/zz_generated.deepcopy.go | 31 +++ upup/models/bindata.go | 184 ++++++++++++++++++ .../k8s-1.11.yaml.template | 163 ++++++++++++++++ .../pkg/fi/cloudup/bootstrapchannelbuilder.go | 21 ++ 11 files changed, 514 insertions(+) create mode 100644 upup/models/cloudup/resources/addons/metrics-server.addons.k8s.io/k8s-1.11.yaml.template diff --git a/k8s/crds/kops.k8s.io_clusters.yaml b/k8s/crds/kops.k8s.io_clusters.yaml index 7f0bda9dc20c7..af5288f37a0bc 100644 --- a/k8s/crds/kops.k8s.io_clusters.yaml +++ b/k8s/crds/kops.k8s.io_clusters.yaml @@ -2082,6 +2082,16 @@ spec: masterPublicName: description: MasterPublicName is the external DNS name for the master nodes type: string + metricsServer: + description: MetricsServerConfig determines the metrics server configuration. + properties: + enabled: + description: 'Enabled enables the metrics server. Default: false' + type: boolean + image: + description: 'Image is the docker container used. Default: the latest supported image for the specified kubernetes version.' + type: string + type: object networkCIDR: 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. type: string diff --git a/pkg/apis/kops/cluster.go b/pkg/apis/kops/cluster.go index 9fbd531bba12c..90c073380e1a3 100644 --- a/pkg/apis/kops/cluster.go +++ b/pkg/apis/kops/cluster.go @@ -160,6 +160,8 @@ type ClusterSpec struct { // NodeTerminationHandlerConfig determines the cluster autoscaler configuration. NodeTerminationHandler *NodeTerminationHandlerConfig `json:"nodeTerminationHandler,omitempty"` + // MetricsServerConfig determines the metrics server configuration. + MetricsServer *MetricsServerConfig `json:"metricsServer,omitempty"` // Networking configuration Networking *NetworkingSpec `json:"networking,omitempty"` diff --git a/pkg/apis/kops/componentconfig.go b/pkg/apis/kops/componentconfig.go index afa46bd445ed6..bc8fbb1e0cdd2 100644 --- a/pkg/apis/kops/componentconfig.go +++ b/pkg/apis/kops/componentconfig.go @@ -801,6 +801,16 @@ type ClusterAutoscalerConfig struct { Image *string `json:"image,omitempty"` } +// MetricsServerConfig determines the metrics server configuration. +type MetricsServerConfig struct { + // Enabled enables the metrics server. + // Default: false + Enabled *bool `json:"enabled,omitempty"` + // Image is the docker container used. + // Default: the latest supported image for the specified kubernetes version. + Image *string `json:"image,omitempty"` +} + // HasAdmissionController checks if a specific admission controller is enabled func (c *KubeAPIServerConfig) HasAdmissionController(name string) bool { for _, x := range c.AdmissionControl { diff --git a/pkg/apis/kops/v1alpha2/cluster.go b/pkg/apis/kops/v1alpha2/cluster.go index 9bd1a9625d5a9..6e2721f87b09c 100644 --- a/pkg/apis/kops/v1alpha2/cluster.go +++ b/pkg/apis/kops/v1alpha2/cluster.go @@ -159,6 +159,8 @@ type ClusterSpec struct { // NodeTerminationHandlerConfig determines the cluster autoscaler configuration. NodeTerminationHandler *NodeTerminationHandlerConfig `json:"nodeTerminationHandler,omitempty"` + // MetricsServerConfig determines the metrics server configuration. + MetricsServer *MetricsServerConfig `json:"metricsServer,omitempty"` // Networking configuration Networking *NetworkingSpec `json:"networking,omitempty"` diff --git a/pkg/apis/kops/v1alpha2/componentconfig.go b/pkg/apis/kops/v1alpha2/componentconfig.go index ed9bbe4dde35b..6ca5ff1dc303a 100644 --- a/pkg/apis/kops/v1alpha2/componentconfig.go +++ b/pkg/apis/kops/v1alpha2/componentconfig.go @@ -802,6 +802,16 @@ type ClusterAutoscalerConfig struct { Image *string `json:"image,omitempty"` } +// MetricsServerConfig determines the metrics server configuration. +type MetricsServerConfig struct { + // Enabled enables the metrics server. + // Default: false + Enabled *bool `json:"enabled,omitempty"` + // Image is the docker container used. + // Default: the latest supported image for the specified kubernetes version. + Image *string `json:"image,omitempty"` +} + // HasAdmissionController checks if a specific admission controller is enabled func (c *KubeAPIServerConfig) HasAdmissionController(name string) bool { for _, x := range c.AdmissionControl { diff --git a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go index e4a77b4433147..8aafe1d88a7f9 100644 --- a/pkg/apis/kops/v1alpha2/zz_generated.conversion.go +++ b/pkg/apis/kops/v1alpha2/zz_generated.conversion.go @@ -693,6 +693,16 @@ func RegisterConversions(s *runtime.Scheme) error { }); err != nil { return err } + if err := s.AddGeneratedConversionFunc((*MetricsServerConfig)(nil), (*kops.MetricsServerConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_v1alpha2_MetricsServerConfig_To_kops_MetricsServerConfig(a.(*MetricsServerConfig), b.(*kops.MetricsServerConfig), scope) + }); err != nil { + return err + } + if err := s.AddGeneratedConversionFunc((*kops.MetricsServerConfig)(nil), (*MetricsServerConfig)(nil), func(a, b interface{}, scope conversion.Scope) error { + return Convert_kops_MetricsServerConfig_To_v1alpha2_MetricsServerConfig(a.(*kops.MetricsServerConfig), b.(*MetricsServerConfig), scope) + }); err != nil { + return err + } if err := s.AddGeneratedConversionFunc((*MixedInstancesPolicySpec)(nil), (*kops.MixedInstancesPolicySpec)(nil), func(a, b interface{}, scope conversion.Scope) error { return Convert_v1alpha2_MixedInstancesPolicySpec_To_kops_MixedInstancesPolicySpec(a.(*MixedInstancesPolicySpec), b.(*kops.MixedInstancesPolicySpec), scope) }); err != nil { @@ -2064,6 +2074,15 @@ func autoConvert_v1alpha2_ClusterSpec_To_kops_ClusterSpec(in *ClusterSpec, out * } else { out.NodeTerminationHandler = nil } + if in.MetricsServer != nil { + in, out := &in.MetricsServer, &out.MetricsServer + *out = new(kops.MetricsServerConfig) + if err := Convert_v1alpha2_MetricsServerConfig_To_kops_MetricsServerConfig(*in, *out, s); err != nil { + return err + } + } else { + out.MetricsServer = nil + } if in.Networking != nil { in, out := &in.Networking, &out.Networking *out = new(kops.NetworkingSpec) @@ -2404,6 +2423,15 @@ func autoConvert_kops_ClusterSpec_To_v1alpha2_ClusterSpec(in *kops.ClusterSpec, } else { out.NodeTerminationHandler = nil } + if in.MetricsServer != nil { + in, out := &in.MetricsServer, &out.MetricsServer + *out = new(MetricsServerConfig) + if err := Convert_kops_MetricsServerConfig_To_v1alpha2_MetricsServerConfig(*in, *out, s); err != nil { + return err + } + } else { + out.MetricsServer = nil + } if in.Networking != nil { in, out := &in.Networking, &out.Networking *out = new(NetworkingSpec) @@ -4682,6 +4710,28 @@ func Convert_kops_LyftVPCNetworkingSpec_To_v1alpha2_LyftVPCNetworkingSpec(in *ko return autoConvert_kops_LyftVPCNetworkingSpec_To_v1alpha2_LyftVPCNetworkingSpec(in, out, s) } +func autoConvert_v1alpha2_MetricsServerConfig_To_kops_MetricsServerConfig(in *MetricsServerConfig, out *kops.MetricsServerConfig, s conversion.Scope) error { + out.Enabled = in.Enabled + out.Image = in.Image + return nil +} + +// Convert_v1alpha2_MetricsServerConfig_To_kops_MetricsServerConfig is an autogenerated conversion function. +func Convert_v1alpha2_MetricsServerConfig_To_kops_MetricsServerConfig(in *MetricsServerConfig, out *kops.MetricsServerConfig, s conversion.Scope) error { + return autoConvert_v1alpha2_MetricsServerConfig_To_kops_MetricsServerConfig(in, out, s) +} + +func autoConvert_kops_MetricsServerConfig_To_v1alpha2_MetricsServerConfig(in *kops.MetricsServerConfig, out *MetricsServerConfig, s conversion.Scope) error { + out.Enabled = in.Enabled + out.Image = in.Image + return nil +} + +// Convert_kops_MetricsServerConfig_To_v1alpha2_MetricsServerConfig is an autogenerated conversion function. +func Convert_kops_MetricsServerConfig_To_v1alpha2_MetricsServerConfig(in *kops.MetricsServerConfig, out *MetricsServerConfig, s conversion.Scope) error { + return autoConvert_kops_MetricsServerConfig_To_v1alpha2_MetricsServerConfig(in, out, s) +} + func autoConvert_v1alpha2_MixedInstancesPolicySpec_To_kops_MixedInstancesPolicySpec(in *MixedInstancesPolicySpec, out *kops.MixedInstancesPolicySpec, s conversion.Scope) error { out.Instances = in.Instances out.OnDemandAllocationStrategy = in.OnDemandAllocationStrategy diff --git a/pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go b/pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go index ca20fa07155e2..5940b7a144bb5 100644 --- a/pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go +++ b/pkg/apis/kops/v1alpha2/zz_generated.deepcopy.go @@ -845,6 +845,11 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { *out = new(NodeTerminationHandlerConfig) (*in).DeepCopyInto(*out) } + if in.MetricsServer != nil { + in, out := &in.MetricsServer, &out.MetricsServer + *out = new(MetricsServerConfig) + (*in).DeepCopyInto(*out) + } if in.Networking != nil { in, out := &in.Networking, &out.Networking *out = new(NetworkingSpec) @@ -3164,6 +3169,32 @@ func (in *LyftVPCNetworkingSpec) DeepCopy() *LyftVPCNetworkingSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricsServerConfig) DeepCopyInto(out *MetricsServerConfig) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.Image != nil { + in, out := &in.Image, &out.Image + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsServerConfig. +func (in *MetricsServerConfig) DeepCopy() *MetricsServerConfig { + if in == nil { + return nil + } + out := new(MetricsServerConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MixedInstancesPolicySpec) DeepCopyInto(out *MixedInstancesPolicySpec) { *out = *in diff --git a/pkg/apis/kops/zz_generated.deepcopy.go b/pkg/apis/kops/zz_generated.deepcopy.go index 7cc4d1e603b4c..ef000a2326262 100644 --- a/pkg/apis/kops/zz_generated.deepcopy.go +++ b/pkg/apis/kops/zz_generated.deepcopy.go @@ -945,6 +945,11 @@ func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { *out = new(NodeTerminationHandlerConfig) (*in).DeepCopyInto(*out) } + if in.MetricsServer != nil { + in, out := &in.MetricsServer, &out.MetricsServer + *out = new(MetricsServerConfig) + (*in).DeepCopyInto(*out) + } if in.Networking != nil { in, out := &in.Networking, &out.Networking *out = new(NetworkingSpec) @@ -3362,6 +3367,32 @@ func (in *LyftVPCNetworkingSpec) DeepCopy() *LyftVPCNetworkingSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MetricsServerConfig) DeepCopyInto(out *MetricsServerConfig) { + *out = *in + if in.Enabled != nil { + in, out := &in.Enabled, &out.Enabled + *out = new(bool) + **out = **in + } + if in.Image != nil { + in, out := &in.Image, &out.Image + *out = new(string) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MetricsServerConfig. +func (in *MetricsServerConfig) DeepCopy() *MetricsServerConfig { + if in == nil { + return nil + } + out := new(MetricsServerConfig) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MixedInstancesPolicySpec) DeepCopyInto(out *MixedInstancesPolicySpec) { *out = *in diff --git a/upup/models/bindata.go b/upup/models/bindata.go index 63648353949b6..e39fd263d41df 100644 --- a/upup/models/bindata.go +++ b/upup/models/bindata.go @@ -27,6 +27,7 @@ // upup/models/cloudup/resources/addons/limit-range.addons.k8s.io/v1.5.0.yaml // upup/models/cloudup/resources/addons/metadata-proxy.addons.k8s.io/addon.yaml // upup/models/cloudup/resources/addons/metadata-proxy.addons.k8s.io/v0.1.12.yaml +// upup/models/cloudup/resources/addons/metrics-server.addons.k8s.io/k8s-1.11.yaml.template // upup/models/cloudup/resources/addons/networking.amazon-vpc-routed-eni/k8s-1.10.yaml.template // upup/models/cloudup/resources/addons/networking.amazon-vpc-routed-eni/k8s-1.12.yaml.template // upup/models/cloudup/resources/addons/networking.amazon-vpc-routed-eni/k8s-1.16.yaml.template @@ -3838,6 +3839,185 @@ func cloudupResourcesAddonsMetadataProxyAddonsK8sIoV0112Yaml() (*asset, error) { return a, nil } +var _cloudupResourcesAddonsMetricsServerAddonsK8sIoK8s111YamlTemplate = []byte(`# sourced from https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.3.7/components.yaml +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: system:aggregated-metrics-reader + labels: + rbac.authorization.k8s.io/aggregate-to-view: "true" + rbac.authorization.k8s.io/aggregate-to-edit: "true" + rbac.authorization.k8s.io/aggregate-to-admin: "true" +rules: +- apiGroups: ["metrics.k8s.io"] + resources: ["pods", "nodes"] + verbs: ["get", "list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: metrics-server:system:auth-delegator +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:auth-delegator +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: metrics-server-auth-reader + namespace: kube-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: extension-apiserver-authentication-reader +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: apiregistration.k8s.io/v1beta1 +kind: APIService +metadata: + name: v1beta1.metrics.k8s.io +spec: + service: + name: metrics-server + namespace: kube-system + group: metrics.k8s.io + version: v1beta1 + insecureSkipTLSVerify: true + groupPriorityMinimum: 100 + versionPriority: 100 +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: metrics-server + namespace: kube-system +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: metrics-server + namespace: kube-system + labels: + k8s-app: metrics-server +spec: + replicas: 2 + selector: + matchLabels: + k8s-app: metrics-server + template: + metadata: + name: metrics-server + labels: + k8s-app: metrics-server + spec: + serviceAccountName: metrics-server + volumes: + # mount in tmp so we can safely use from-scratch images and/or read-only containers + - name: tmp-dir + emptyDir: {} + containers: + - name: metrics-server + image: {{ or .MetricsServer.Image "k8s.gcr.io/metrics-server/metrics-server:v0.3.7" }} + imagePullPolicy: IfNotPresent + args: + - --cert-dir=/tmp + - --secure-port=4443 + ports: + - name: main-port + containerPort: 4443 + protocol: TCP + securityContext: + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 1000 + volumeMounts: + - name: tmp-dir + mountPath: /tmp +--- +apiVersion: v1 +kind: Service +metadata: + name: metrics-server + namespace: kube-system + labels: + kubernetes.io/name: "Metrics-server" + kubernetes.io/cluster-service: "true" +spec: + selector: + k8s-app: metrics-server + ports: + - port: 443 + protocol: TCP + targetPort: main-port +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: system:metrics-server +rules: +- apiGroups: + - "" + resources: + - pods + - nodes + - nodes/stats + - namespaces + - configmaps + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: system:metrics-server +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:metrics-server +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + name: metrics-server + namespace: kube-system + labels: + k8s-app: metrics-server +spec: + minAvailable: 1 + selector: + matchLabels: + k8s-app: metrics-server`) + +func cloudupResourcesAddonsMetricsServerAddonsK8sIoK8s111YamlTemplateBytes() ([]byte, error) { + return _cloudupResourcesAddonsMetricsServerAddonsK8sIoK8s111YamlTemplate, nil +} + +func cloudupResourcesAddonsMetricsServerAddonsK8sIoK8s111YamlTemplate() (*asset, error) { + bytes, err := cloudupResourcesAddonsMetricsServerAddonsK8sIoK8s111YamlTemplateBytes() + if err != nil { + return nil, err + } + + info := bindataFileInfo{name: "cloudup/resources/addons/metrics-server.addons.k8s.io/k8s-1.11.yaml.template", size: 0, mode: os.FileMode(0), modTime: time.Unix(0, 0)} + a := &asset{bytes: bytes, info: info} + return a, nil +} + var _cloudupResourcesAddonsNetworkingAmazonVpcRoutedEniK8s110YamlTemplate = []byte(`# Vendored from https://github.com/aws/amazon-vpc-cni-k8s/blob/v1.3.3/config/v1.3/aws-k8s-cni.yaml apiVersion: rbac.authorization.k8s.io/v1 @@ -20684,6 +20864,7 @@ var _bindata = map[string]func() (*asset, error){ "cloudup/resources/addons/limit-range.addons.k8s.io/v1.5.0.yaml": cloudupResourcesAddonsLimitRangeAddonsK8sIoV150Yaml, "cloudup/resources/addons/metadata-proxy.addons.k8s.io/addon.yaml": cloudupResourcesAddonsMetadataProxyAddonsK8sIoAddonYaml, "cloudup/resources/addons/metadata-proxy.addons.k8s.io/v0.1.12.yaml": cloudupResourcesAddonsMetadataProxyAddonsK8sIoV0112Yaml, + "cloudup/resources/addons/metrics-server.addons.k8s.io/k8s-1.11.yaml.template": cloudupResourcesAddonsMetricsServerAddonsK8sIoK8s111YamlTemplate, "cloudup/resources/addons/networking.amazon-vpc-routed-eni/k8s-1.10.yaml.template": cloudupResourcesAddonsNetworkingAmazonVpcRoutedEniK8s110YamlTemplate, "cloudup/resources/addons/networking.amazon-vpc-routed-eni/k8s-1.12.yaml.template": cloudupResourcesAddonsNetworkingAmazonVpcRoutedEniK8s112YamlTemplate, "cloudup/resources/addons/networking.amazon-vpc-routed-eni/k8s-1.16.yaml.template": cloudupResourcesAddonsNetworkingAmazonVpcRoutedEniK8s116YamlTemplate, @@ -20822,6 +21003,9 @@ var _bintree = &bintree{nil, map[string]*bintree{ "addon.yaml": {cloudupResourcesAddonsMetadataProxyAddonsK8sIoAddonYaml, map[string]*bintree{}}, "v0.1.12.yaml": {cloudupResourcesAddonsMetadataProxyAddonsK8sIoV0112Yaml, map[string]*bintree{}}, }}, + "metrics-server.addons.k8s.io": {nil, map[string]*bintree{ + "k8s-1.11.yaml.template": {cloudupResourcesAddonsMetricsServerAddonsK8sIoK8s111YamlTemplate, map[string]*bintree{}}, + }}, "networking.amazon-vpc-routed-eni": {nil, map[string]*bintree{ "k8s-1.10.yaml.template": {cloudupResourcesAddonsNetworkingAmazonVpcRoutedEniK8s110YamlTemplate, map[string]*bintree{}}, "k8s-1.12.yaml.template": {cloudupResourcesAddonsNetworkingAmazonVpcRoutedEniK8s112YamlTemplate, map[string]*bintree{}}, diff --git a/upup/models/cloudup/resources/addons/metrics-server.addons.k8s.io/k8s-1.11.yaml.template b/upup/models/cloudup/resources/addons/metrics-server.addons.k8s.io/k8s-1.11.yaml.template new file mode 100644 index 0000000000000..ef5bfbf3237fd --- /dev/null +++ b/upup/models/cloudup/resources/addons/metrics-server.addons.k8s.io/k8s-1.11.yaml.template @@ -0,0 +1,163 @@ +# sourced from https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.3.7/components.yaml +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: system:aggregated-metrics-reader + labels: + rbac.authorization.k8s.io/aggregate-to-view: "true" + rbac.authorization.k8s.io/aggregate-to-edit: "true" + rbac.authorization.k8s.io/aggregate-to-admin: "true" +rules: +- apiGroups: ["metrics.k8s.io"] + resources: ["pods", "nodes"] + verbs: ["get", "list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: metrics-server:system:auth-delegator +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:auth-delegator +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: metrics-server-auth-reader + namespace: kube-system +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: extension-apiserver-authentication-reader +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: apiregistration.k8s.io/v1beta1 +kind: APIService +metadata: + name: v1beta1.metrics.k8s.io +spec: + service: + name: metrics-server + namespace: kube-system + group: metrics.k8s.io + version: v1beta1 + insecureSkipTLSVerify: true + groupPriorityMinimum: 100 + versionPriority: 100 +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: metrics-server + namespace: kube-system +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: metrics-server + namespace: kube-system + labels: + k8s-app: metrics-server +spec: + replicas: 2 + selector: + matchLabels: + k8s-app: metrics-server + template: + metadata: + name: metrics-server + labels: + k8s-app: metrics-server + spec: + serviceAccountName: metrics-server + volumes: + # mount in tmp so we can safely use from-scratch images and/or read-only containers + - name: tmp-dir + emptyDir: {} + containers: + - name: metrics-server + image: {{ or .MetricsServer.Image "k8s.gcr.io/metrics-server/metrics-server:v0.3.7" }} + imagePullPolicy: IfNotPresent + args: + - --cert-dir=/tmp + - --secure-port=4443 + ports: + - name: main-port + containerPort: 4443 + protocol: TCP + securityContext: + readOnlyRootFilesystem: true + runAsNonRoot: true + runAsUser: 1000 + volumeMounts: + - name: tmp-dir + mountPath: /tmp +--- +apiVersion: v1 +kind: Service +metadata: + name: metrics-server + namespace: kube-system + labels: + kubernetes.io/name: "Metrics-server" + kubernetes.io/cluster-service: "true" +spec: + selector: + k8s-app: metrics-server + ports: + - port: 443 + protocol: TCP + targetPort: main-port +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: system:metrics-server +rules: +- apiGroups: + - "" + resources: + - pods + - nodes + - nodes/stats + - namespaces + - configmaps + verbs: + - get + - list + - watch +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: system:metrics-server +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: system:metrics-server +subjects: +- kind: ServiceAccount + name: metrics-server + namespace: kube-system +--- +apiVersion: policy/v1beta1 +kind: PodDisruptionBudget +metadata: + name: metrics-server + namespace: kube-system + labels: + k8s-app: metrics-server +spec: + minAvailable: 1 + selector: + matchLabels: + k8s-app: metrics-server \ No newline at end of file diff --git a/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go b/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go index 55a3f6b2ab563..f8a6dffafa2b1 100644 --- a/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go +++ b/upup/pkg/fi/cloudup/bootstrapchannelbuilder.go @@ -563,6 +563,27 @@ func (b *BootstrapChannelBuilder) buildAddons(c *fi.ModelBuilderContext) (*chann } } + if b.Cluster.Spec.MetricsServer != nil && fi.BoolValue(b.Cluster.Spec.MetricsServer.Enabled) { + { + key := "metrics-server.addons.k8s.io" + version := "1.19.0" + + { + location := key + "/k8s-1.11.yaml" + id := "k8s-1.11" + + addons.Spec.Addons = append(addons.Spec.Addons, &channelsapi.AddonSpec{ + Name: fi.String(key), + Version: fi.String(version), + Selector: map[string]string{"k8s-app": "metrics-server"}, + Manifest: fi.String(location), + KubernetesVersion: ">=1.11.0", + Id: id, + }) + } + } + } + nth := b.Cluster.Spec.NodeTerminationHandler if nth != nil && fi.BoolValue(nth.Enabled) {