ACK 最新版本K8S指导手册

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。

完成上述操作步骤之后,您就可以使用容器服务的集群升级功能进行集群升级了。

上一篇:揭秘多个创新细节 阿里云发布《企业物联网平台白皮书V1.0》


下一篇:如何使用NC反弹shell