[英]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集群,则将maxSize
, minSize
更改为节点大小:
$ 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_REGION
和GROUP_NAME
,并且可能要更改MIN_NODES
和MAX_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.