我正在尝试使用 kops 工具在 AWS 上创建 Kubernetes 集群。集群创建后,我运行命令来验证它,但该命令无效。
$ kops validate cluster
Using cluster from kubectl context: devops23.k8s.local
Validating cluster devops23.k8s.local
INSTANCE GROUPS
NAME ROLE MACHINETYPE MIN MAX SUBNETS
control-plane-us-east-2a ControlPlane t2.small 1 1 us-east-2a
control-plane-us-east-2b ControlPlane t2.small 1 1 us-east-2b
control-plane-us-east-2c ControlPlane t2.small 1 1 us-east-2c
nodes-us-east-2a Node t2.small 1 1 us-east-2a
nodes-us-east-2b Node t2.small 0 0 us-east-2b
nodes-us-east-2c Node t2.small 0 0 us-east-2c
NODE STATUS
NAME ROLE READY
i-04979e16868806652 control-plane True
i-098e4ca3ad7ee246d control-plane True
i-0d1819f232278b049 control-plane True
i-0f3b8414ecd1ef5eb node True
VALIDATION ERRORS
KIND NAME MESSAGE
Pod kube-system/kops-controller-p5rz4 system-cluster-critical pod "kops-controller-p5rz4" is pending
Validation Failed
Error: validation failed: cluster not yet healthy
这是我用来创建集群的命令
kops create cluster \
--name $NAME \
--master-count 3 \
--node-count 1 \
--node-size t2.small \
--master-size t2.small \
--zones $ZONES \
--master-zones $ZONES \
--ssh-public-key devops23.pub \
--networking kubenet \
--yes
$ echo $NAME
devops23.k8s.local
$ echo $ZONES
us-east-2a,us-east-2b,us-east-2c
$ kops version
Client version: 1.27.0 (git-v1.27.0)
通过运行
kubectl -n kube-system get po
我看到 3 个 kops 控制器中有 2 个正在运行,1 个处于“待处理”状态
ebs-csi-node-bwvff 3/3 Running 0 159m
ebs-csi-node-q4vxg 3/3 Running 0 158m
ebs-csi-node-sk4gc 3/3 Running 0 157m
etcd-manager-events-i-04979e16868806652 1/1 Running 0 158m
etcd-manager-events-i-098e4ca3ad7ee246d 1/1 Running 0 158m
etcd-manager-events-i-0d1819f232278b049 1/1 Running 0 156m
etcd-manager-main-i-04979e16868806652 1/1 Running 0 158m
etcd-manager-main-i-098e4ca3ad7ee246d 1/1 Running 0 158m
etcd-manager-main-i-0d1819f232278b049 1/1 Running 0 155m
kops-controller-5fpxq 1/1 Running 0 157m
kops-controller-p5rz4 0/1 Pending 0 158m
kops-controller-w9fhg 1/1 Running 0 159m
kube-apiserver-i-04979e16868806652 2/2 Running 4 (161m ago) 158m
kube-apiserver-i-098e4ca3ad7ee246d 2/2 Running 4 (161m ago) 159m
kube-apiserver-i-0d1819f232278b049 2/2 Running 5 (159m ago) 156m
kube-controller-manager-i-04979e16868806652 1/1 Running 5 (161m ago) 159m
kube-controller-manager-i-098e4ca3ad7ee246d 1/1 Running 5 (161m ago) 159m
答案1
好的,当我在创建集群命令中添加 Kubernetes 版本时,问题已解决
kops create cluster \
--name $NAME \
--master-count 3 \
--node-count 1 \
--node-size t2.small \
--master-size t2.small \
--zones $ZONES \
--master-zones $ZONES \
--ssh-public-key devops23.pub \
--networking kubenet \
**--kubernetes-version v1.22.2** \
--yes
对于 kOps 版本 1.27,版本 1.22.2 是可以的,如果你有其他版本的 kOps,这里是兼容性表https://github.com/kubernetes/kops/blob/master/permalinks/upgrade_k8s.md#1.24.0