按照本指南在 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
为我当前的 ASG 名称,该名称由kops
. 但是当运行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 集群,则更改maxSize
,minSize
以获取节点大小:
$ kops edit ig nodes
> maxSize: 2
> minSize: 2
$ kops update cluster ${CLUSTER_FULL_NAME} --yes
到目前为止,AWS 上的 Auto Scaling 组已经成为Min:2
Max:4
.
是否有必要再次运行此部署? https://github.com/kubernetes/autoscaler/tree/master/cluster-autoscaler/cloudprovider/aws
kops 不能同时改变 ASG 和 k8s 集群吗?为什么要做另一个步骤来设置cluster-autoscaler
命名kube-system
空间?
NAME READY STATUS RESTARTS AGE
cluster-autoscaler-75ccf5b9c9-lhts8 0/1 CrashLoopBackOff 6 8m