ACK 1.9已經超出技術支援期限,目前更新管控已經無法适配1.9更新,本文主要指導使用者修改1.9的相關配置,使其可以進行更新。
目前主要阻礙是1.9叢集内置的DNS服務元件為kube-dns,我們需要将其替換為CoreDNS,就可以使用容器服務提供的更新功能進行更新了。
首先,我們需要在叢集中部署CoreDNS服務。注意需要将image修改為您的叢集所在的regionid,如你的叢集在杭州則将
image: registry-vpc.YOUR-REGIONID.aliyuncs.com/acs/coredns:1.0.6
修改為
image: registry-vpc.cn-hangzhou.aliyuncs.com/acs/coredns:1.0.6
完整yaml檔案如下:
apiVersion: apps/v1
kind: Deployment
metadata:
name: coredns
namespace: kube-system
labels:
k8s-app: kube-dns
spec:
replicas: 2
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 1
selector:
matchLabels:
k8s-app: kube-dns
template:
metadata:
labels:
k8s-app: kube-dns
spec:
affinity:
podAntiAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 100
podAffinityTerm:
labelSelector:
matchExpressions:
- key: k8s-app
operator: In
values: ["kube-dns"]
topologyKey: kubernetes.io/hostname
serviceAccountName: coredns
tolerations:
- operator: Exists
nodeSelector:
beta.kubernetes.io/os: linux
containers:
- name: coredns
image: registry-vpc.YOUR-REGIONID.aliyuncs.com/acs/coredns:1.0.6
imagePullPolicy: IfNotPresent
resources:
limits:
memory: 170Mi
requests:
cpu: 100m
memory: 70Mi
args: [ "-conf", "/etc/coredns/Corefile" ]
volumeMounts:
- name: config-volume
mountPath: /etc/coredns
readOnly: true
ports:
- containerPort: 53
name: dns
protocol: UDP
- containerPort: 53
name: dns-tcp
protocol: TCP
- containerPort: 9153
name: metrics
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5
securityContext:
allowPrivilegeEscalation: false
capabilities:
add:
- NET_BIND_SERVICE
drop:
- all
readOnlyRootFilesystem: true
dnsPolicy: Default
volumes:
- name: config-volume
configMap:
name: coredns
items:
- key: Corefile
path: Corefile
---
apiVersion: v1
kind: ConfigMap
metadata:
name: coredns
namespace: kube-system
data:
Corefile: |
.:53 {
errors
health
kubernetes cluster.local in-addr.arpa ip6.arpa {
pods insecure
upstream
fallthrough in-addr.arpa ip6.arpa
}
prometheus :9153
proxy . /etc/resolv.conf
cache 30
loadbalance
}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: system:coredns
rules:
- apiGroups:
- ""
resources:
- endpoints
- services
- pods
- namespaces
verbs:
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: system:coredns
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: system:coredns
subjects:
- kind: ServiceAccount
name: coredns
namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: coredns
namespace: kube-system
使用該yaml建立CoreDNS服務後,需要觀察其是否可以正常運作。
确定CoreDNS正常運作之後,可以逐漸減少叢集中kube-dns的副本數(spec. replicas)。
最後在確定業務正常運作的前提下,我們可以删掉叢集中的kube-dns。
完成上述操作步驟之後,您就可以使用容器服務的叢集更新功能進行叢集更新了。
如果叢集更新之後又出現了kube-dns,您可以将其删除。