如何在AWS上通过kops安装的k8s集群自动扩展器?

问题描述 投票:1回答:1

按照本指南在AWS上创建集群自动缩放器:https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/cloudprovider/aws

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: cluster-autoscaler
  namespace: kube-system
  labels:
    app: cluster-autoscaler
spec:
  replicas: 1
  selector:
    matchLabels:
      app: cluster-autoscaler
  template:
    metadata:
      labels:
        app: cluster-autoscaler
    spec:
      containers:
        - image: gcr.io/google_containers/cluster-autoscaler:v0.6.0
          name: cluster-autoscaler
          resources:
            limits:
              cpu: 100m
              memory: 300Mi
            requests:
              cpu: 100m
              memory: 300Mi
          command:
            - ./cluster-autoscaler
            - --v=4
            - --stderrthreshold=info
            - --cloud-provider=aws
            - --skip-nodes-with-local-storage=false
            - --nodes=2:4:k8s-worker-asg-1
          env:
            - name: AWS_REGION
              value: us-east-1
          volumeMounts:
            - name: ssl-certs
              mountPath: /etc/ssl/certs/ca-certificates.crt
              readOnly: true
          imagePullPolicy: "Always"
      volumes:
        - name: ssl-certs
          hostPath:
            path: "/etc/ssl/certs/ca-certificates.crt"

我已将k8s-worker-asg-1更改为由kops创建的当前ASG名称。但是当运行kubectl apply -f deployment.yaml并检查pods kubectl get pods -n=kube-system时,返回:

NAME                                                                      READY     STATUS             RESTARTS   AGE
cluster-autoscaler-75ccf5b9c9-lhts8                                       0/1       CrashLoopBackOff   6          8m

我试图看到它的日志kubectl logs cluster-autoscaler-75ccf5b9c9-lhts8 -n=kube-system,返回:

failed to open log file "/var/log/pods/8edc3073-dc0b-11e7-a6e5-06361ac15b44/cluster-autoscaler_4.log": open /var/log/pods/8edc3073-dc0b-11e7-a6e5-06361ac15b44/cluster-autoscaler_4.log: no such file or directory

我也尝试描述pod kubectl describe cluster-autoscaler-75ccf5b9c9-lhts8 -n=kube-system,返回:

the server doesn't have a resource type "cluster-autoscaler-75ccf5b9c9-lhts8"

那么如何调试问题呢?会是什么原因?是否需要在AWS上存储?我还没有在AWS上创建任何存储。


顺便说一句,我有另一个问题。如果使用kops在AWS上创建k8s群集,则将maxSizeminSize更改为节点大小:

$ kops edit ig nodes
> maxSize: 2
> minSize: 2
$ kops update cluster ${CLUSTER_FULL_NAME} --yes

到目前为止,AWS上的Auto Scaling Groups已经成为qazxsw poi qazxsw poi。

是否有必要再次运行此部署? Min:2

kops不能同时改变ASG和k8s集群吗?为什么要将Max:4设置为https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/cloudprovider/aws命名空间?

cluster-autoscaler
amazon-web-services kubernetes cluster-computing autoscaling kops
1个回答
0
投票

我从K8s存储库中尝试过这个官方解决方案。您还需要添加其他IAM策略以访问AWS Autoscaling资源。然后,修改kube-system中的脚本以在K8s群集上安装Cluster Autoscaler。请注意,您可能想要更改NAME READY STATUS RESTARTS AGE cluster-autoscaler-75ccf5b9c9-lhts8 0/1 CrashLoopBackOff 6 8m https://github.com/kubernetes/kops/tree/master/addons/cluster-autoscaler,可能还需要更改AWS_REGIONGROUP_NAME。我为我工作过。

MIN_NODES
© www.soinside.com 2019 - 2024. All rights reserved.