Upgrade metrics-server before upgrading to v1.12
Before upgrading a cluster to v1.12, you must upgrade the metrics-server component. The upgrade process has three parts: switching the metric collector, switching the monitoring link, and adjusting component settings for compatibility.
Prerequisites
You have an ACK dedicated cluster that runs v1.12.6 or earlier.
Switch the metric collector
Create a file named metrics-server.yaml with the following content. Then, run the kubectl apply -f metrics-server.yaml command to switch the metric collector from Heapster to metrics-server.
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
name: admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin
namespace: kube-system
---
apiVersion: v1
kind: Service
metadata:
labels:
task: monitoring
# For use as a Cluster add-on (https://github.com/kubernetes/kubernetes/tree/master/cluster/addons)
# If you are NOT using this as an addon, you should comment out this line.
kubernetes.io/cluster-service: 'true'
kubernetes.io/name: metrics-server
name: heapster
namespace: kube-system
spec:
ports:
- port: 80
targetPort: 8082
selector:
k8s-app: metrics-server
---
apiVersion: v1
kind: Service
metadata:
name: metrics-server
namespace: kube-system
labels:
kubernetes.io/name: metrics-server
spec:
selector:
k8s-app: metrics-server
ports:
- port: 443
protocol: TCP
targetPort: 443
---
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: apps/v1
kind: Deployment
metadata:
name: metrics-server
namespace: kube-system
labels:
k8s-app: metrics-server
spec:
selector:
matchLabels:
k8s-app: metrics-server
template:
metadata:
name: metrics-server
labels:
k8s-app: metrics-server
spec:
serviceAccountName: admin
containers:
- name: metrics-server
image: registry.##REGION##.aliyuncs.com/acs/metrics-server:v0.2.1-9dd9511-aliyun
imagePullPolicy: Always
command:
- /metrics-server
- '--source=kubernetes:https://kubernetes.default'
- '--sink=socket:tcp://monitor.csk.##REGION##.aliyuncs.com:8093?clusterId=##CLUSTER_ID##
&public=true'
Replace ##REGION## with the region ID (for example, cn-hangzhou for China (Hangzhou)) and ##CLUSTER_ID## with your cluster ID.
Switch the monitoring link
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, click .
-
Find the three master nodes of the cluster. Click the instance ID of a master node.
-
On the Instance Details page, click Connect.
In the remote connection window, enter the remote connection password and click OK. After you log on, run the following command:
sed -i 's/--horizontal-pod-autoscaler-use-rest-clients=false/--horizontal-pod-autoscaler-use-rest-clients=true/' /etc/kubernetes/manifests/kube-controller-manager.yamlIn the Copy and Paste Command dialog box, paste the command and click OK.
-
Repeat this procedure on the other two master nodes.
After you execute the command, kubelet automatically restarts and updates the kube-controller-manager component.
Adjust components for compatibility
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, click .
-
From the Namespace drop-down list, select kube-system. Find the heapster Service and click View in YAML in the Actions column.
-
In the dialog box that appears, change the value of
k8s-appin theselectorsection tometrics-server. Click Update.apiVersion: v1 kind: Service metadata: creationTimestamp: '2019-01-14T09:38:56Z' name: heapster namespace: kube-system resourceVersion: '22030561' selfLink: /api/v1/namespaces/kube-system/services/heapster uid: 36b86a85-17e0-11e9-a14f-00163e06b896 spec: clusterIP: xxx.xxx.xxx.xxx ports: - port: 80 protocol: TCP targetPort: 8082 selector: k8s-app: metrics-server sessionAffinity: None type: ClusterIP status: loadBalancer: {} In the left navigation pane of the cluster management page, choose .
-
On the Deployments page, from the Namespace drop-down list, select kube-system.
-
Select the
heapsterandmonitoring-influxdbcomponents, and in the Actions column, choose . -
In the dialog box that appears, click OK.
NoteWhen you delete the
monitoring-influxdbcomponent, select the Delete the associated monitoring-influxdb Service checkbox in the Delete monitoring-influxdb dialog box and click OK. -
Verify the monitoring link switch.
Wait about 3 minutes for the monitoring link to initialize.
In the left-side navigation pane, choose . On the Pods page, if the CPU and Memory columns display values, the monitoring link switch is successful.
NoteIf the CPU and Memory values for all components are 0, it indicates an error.