简体   繁体   English

如何为kops在AWS上安装的k8集群自动定标器?

[英]How to do cluster autoscaler for k8s which installed by kops on AWS?

Follow this guide to create cluster autoscaler on AWS: https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/cloudprovider/aws 遵循此指南在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"

I have changed k8s-worker-asg-1 to my current ASG name which created by kops . 我已经改变k8s-worker-asg-1其通过创建我现在的ASG名kops But when run kubectl apply -f deployment.yaml and check pods kubectl get pods -n=kube-system , return: 但是当运行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

I tried to see its logs kubectl logs cluster-autoscaler-75ccf5b9c9-lhts8 -n=kube-system , return: 我试图查看其日志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

I also tried to describe the pod kubectl describe cluster-autoscaler-75ccf5b9c9-lhts8 -n=kube-system , return: 我还尝试描述pod kubectl describe cluster-autoscaler-75ccf5b9c9-lhts8 -n=kube-system ,返回:

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

So how to debug the issue? 那么如何调试问题呢? What will be the reason? 会是什么原因? Is it need storage on AWS? 是否需要在AWS上存储? I didn't create any storage on AWS yet. 我尚未在AWS上创建任何存储。


By the way, I have another question. 顺便说一句,我还有一个问题。 If use kops create a k8s cluster on AWS, then change maxSize , minSize for nodes size: 如果使用kops在AWS上创建一个k8s集群,则将maxSizeminSize更改为节点大小:

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

Until now the Auto Scaling Groups on AWS has already became Min:2 Max:4 . 到目前为止,AWS上的Auto Scaling Groups已经变成Min:2 Max:4

Is it necessary to run this deployment again? 是否需要再次运行此部署? https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/cloudprovider/aws https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/cloudprovider/aws

Does kops can't change both ASG and k8s cluster? kops不能同时更改ASG和k8s集群吗? Why do another step to set cluster-autoscaler to kube-system namespace? 为什么还要执行另一步骤来将cluster-autoscaler kube-system设置为kube-system名称空间?

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

I have tried this official solution from K8s repositories. 我已经尝试过从K8s存储库中获得此​​官方解决方案。 You also need to add additional IAM policies for accessing to AWS Autoscaling resources. 您还需要添加其他IAM策略以访问AWS Autoscaling资源。 Then, modify the script in https://github.com/kubernetes/kops/tree/master/addons/cluster-autoscaler to install Cluster Autoscaler on your K8s cluster. 然后,在https://github.com/kubernetes/kops/tree/master/addons/cluster-autoscaler中修改脚本,以在K8s集群上安装Cluster Autoscaler。 Note that you likely want to change AWS_REGION and GROUP_NAME , and probably MIN_NODES and MAX_NODES . 请注意,您可能想更改AWS_REGIONGROUP_NAME ,并且可能要更改MIN_NODESMAX_NODES I worked for me. 我为我工作。

spec:
  api:
    loadBalancer:
      type: Public
  authorization:
    rbac: {}
  additionalPolicies:
    node: |
      [
        {
          "Effect": "Allow",
          "Action": [
            "autoscaling:DescribeAutoScalingGroups",
            "autoscaling:DescribeAutoScalingInstances",
            "autoscaling:SetDesiredCapacity",
            "autoscaling:TerminateInstanceInAutoScalingGroup"
          ],
          "Resource": ["*"]
        }
      ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在kops在AWS上安装的k8s集群中使用alb-ingress-controller? - How to use alb-ingress-controller in k8s cluster which installed by kops on AWS? 如何使用Kops,Cluster-Autoscaler自动调整K8s群集的大小以动态增加Masters - How to resize K8s cluster with kops, cluster-autoscaler to dynamically increase Masters 如何最小化 AWS k8s 的 Kops 的 IAM 角色权限 - How to minimize IAM role permission for Kops of AWS k8s 使外部DNS与Kops AWS 1.7 K8s集群中的入口对象一起使用 - Getting External-DNS to work with Ingress Objects in Kops AWS 1.7 K8s Cluster 通过使用kops创建的AWS群集上的入口使k8s服务可用 - Make k8s services available via ingress on an AWS cluster created with kops 将手动创建的K8s集群导入KOps - Import manually created K8s cluster into KOps 正确设置AWS k8的kops权限 - Correct setup of kops permissions for AWS k8s 哪种监控工具更适合在AWS for k8s集群上使用? - Which monitoring tool is better to use on AWS for k8s cluster? 如何修复''无法找到“kope.io/k8s ...”的图像,当运行kops更新群集$ {NAME}时 - - How to fix ''could not find Image for “kope.io/k8s…” when running kops update cluster ${NAME} --yes 审计 AWS 上的 k8s 集群事件 - Audit k8s cluster events on AWS
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM