Amazon EKS:将 Pod 从一个节点组移动到另一个节点组

Amazon EKS:将 Pod 从一个节点组移动到另一个节点组

我目前有一个为我的 EKS 集群提供服务的托管节点组,并且添加了另一个:

  • NodeGroup1 [当前 - 20gb ec2 磁盘]
  • NodeGroup2 [新 - 80gb ec2 磁盘]

我想将当前的 pod 从节点组 1 迁移到节点组 2,以便为工作节点提供更多的磁盘大小,然后停止使用节点组 1。 节点组图像

我已经创建了新的节点组:

eksctl create nodegroup --cluster prod --name NodeGroup2 --node-type t3.medium --nodes 2 --nodes-min 0 --nodes-max 4 --enable-ssm --managed --node-volume-size 80

我设置了 Pod 中断预算,但目前我可以容忍停机时间。只要一切都从一个托管节点组转移到新节点组,我就很高兴了。

我可以简单地这样做eksctl delete nodegroup NodeGroup1并将所有内容移动到第二个节点组吗?

我的节点组、部署和 pod 如下所示:

~$ eksctl get nodegroups --cluster prod -o json
[
    {
        "StackName": "",
        "Cluster": "prod",
        "Name": "NodeGroup2",
        "Status": "ACTIVE",
        "MaxSize": 4,
        "MinSize": 0,
        "DesiredCapacity": 2,
        "InstanceType": "t3.medium",
        "ImageID": "AL2_x86_64",
        "CreationTime": "2021-11-07T04:15:49.595Z",
        "NodeInstanceRoleARN": "arn:aws:iam::redacted:role/eks-node-group",
        "AutoScalingGroupName": "eks-...1d",
        "Version": "1.20"
    },
    {
        "StackName": "",
        "Cluster": "prod",
        "Name": "NodeGroup1",
        "Status": "ACTIVE",
        "MaxSize": 4,
        "MinSize": 0,
        "DesiredCapacity": 2,
        "InstanceType": "t3.medium",
        "ImageID": "AL2_x86_64",
        "CreationTime": "2021-05-25T06:52:25.437Z",
        "NodeInstanceRoleARN": "arn:aws:iam::redacted:role/eks-node-group",
        "AutoScalingGroupName": "eks-...01",
        "Version": "1.20"
    }
    
~$ kubectl get pods -A    

NAMESPACE              NAME                                            READY   STATUS    RESTARTS   AGE
default                grafana-agent                                   1/1     Running   0          2d23h
default                promtail-2a23                                   1/1     Running   0          3d
default                promtail-2vg2                                   1/1     Running   0          3d
default                prod-application-34                             1/1     Running   0          3d
default                prod-applicationworker-6l                       1/1     Running   0          3d
kube-system            aws-load-balancer-controller                    1/1     Running   0          2d23h
kube-system            aws-node-5rzk3                                  1/1     Running   0          3d
kube-system            aws-node-keljg                                  1/1     Running   0          3d
kube-system            cluster-autoscaler                              1/1     Running   0          2d23h
kube-system            coredns-3254s                                   1/1     Running   0          3d
kube-system            coredns-48grd                                   1/1     Running   0          2d23h
kube-system            kube-proxy-6vx89                                1/1     Running   0          3d
kube-system            kube-proxy-rqb23                                1/1     Running   0          3d
kube-system            metrics-server                                  1/1     Running   0          2d23h
kubernetes-dashboard   dashboard-metrics-scraper                       1/1     Running   0          2d23h
kubernetes-dashboard   kubernetes-dashboard                            1/1     Running   0          2d23h

~$ kubectl get deployments -A
NAMESPACE              NAME                           READY   UP-TO-DATE   AVAILABLE   AGE
default                grafana-agent                  1/1     1            1           5d23h
default                prod-application               1/1     1            1           160d
default                prod-applicationworker         1/1     1            1           37d
kube-system            aws-load-balancer-controller   1/1     1            1           166d
kube-system            cluster-autoscaler             1/1     1            1           166d
kube-system            coredns                        2/2     2            2           167d
kube-system            metrics-server                 1/1     1            1           166d
kubernetes-dashboard   dashboard-metrics-scraper      1/1     1            1           165d
kubernetes-dashboard   kubernetes-dashboard           1/1     1            1           165d

如果有一种方法可以让我暂时封锁整个节点组,然后将其转移到另一个节点组(在我删除第一个节点组之前),那就太棒了。

抱歉,这是一个简单的问题,但我最终阅读了许多相互略有矛盾的文献。

干杯,迈克。

相关内容