1. 创建新版本的EKS v1.28集群,内含EKS 集群创建Terrafrom 代码
Terraform 升級 AWS EKS版本_eks升级-CSDN博客
2. 检查新EKS 集群的健康状态
export AWS_ACCESS_KEY_ID="xxxxxx"
export AWS_SECRET_ACCESS_KEY="xxxxxxxxxx"
export AWS_DEFAULT_REGION="ap-east-1"
export KUBECONFIG=/home/ec2-user/.kube/devops-upgrade-eks
aws eks --region ap-east-1 update-kubeconfig --name devops-upgrade-eks
kubectl config current-context
kubectl get nodes
3. 在新的 v1.28 eks 中安装 velero 客户端 ctl 工具以恢复“devops-eks”
wget https://github.com/vmware-tanzu/velero/releases/download/v1.8.0/velero-v1.8.0-linux-amd64.tar.gz
tar -zxvf velero-v1.8.0-linux-amd64.tar.gz && cd velero-v1.8.0-linux-amd64
cp velero /usr/local/bin && chmod +x /usr/local/bin/velero
ln -s /usr/local/bin/velero /usr/bin/velero
velero version
4. 安装CSI快照crd
git clone https://github.com/kubernetes-csi/external-snapshotter.git
cd external-snapshotter/
git checkout release-6.3
git branch
kubectl kustomize client/config/crd | kubectl create -f -
kubectl -n kube-system kustomize deploy/kubernetes/snapshot-controller | kubectl create -f -
kubectl kustomize deploy/kubernetes/csi-snapshotter | kubectl create -f -
kubectl get crd -A
kubectl get apiservices -A
5. 安装快照CSI
git clone https://github.com/kubernetes-csi/external-snapshotter.git
cd external-snapshotter/
git checkout release-6.3
git branch
kubectl kustomize client/config/crd | kubectl create -f -
kubectl -n kube-system kustomize deploy/kubernetes/snapshot-controller | kubectl create -f -
kubectl kustomize deploy/kubernetes/csi-snapshotter | kubectl create -f -
kubectl get crd -A
kubectl get apiservices -A
6. 使用velero 安装新EKS 集群
vim credentials-velero
[default]
aws_access_key_id = xxxxx
aws_secret_access_key = xxxxxxxxx
export KUBECONFIG=/home/ec2-user/.kube/devops-upgrade-eks
kubectl delete ns velero
velero install \
--provider aws \
--plugins velero/velero-plugin-for-aws:v1.8.0 \
--bucket eks-velero-backups-devops \
--backup-location-config region=ap-southeast-1 \
--snapshot-location-config region=ap-east-1 \
--secret-file /home/ec2-user/credentials-velero \
restic/restic
kubectl get pods -n velero
kubectl logs velero-84958658d5-s5lh9 -n velero
kubectl delete secret bsl-credentials -n velero
kubectl create secret generic -n velero bsl-credentials --from-file=aws=./credentials-velero
velero backup-location get
7. 还原旧的EKS 集群到新的 EKS 集群上
velero restore create devops-eks-20240628173400-restore --from-backup devops-eks-20240628173400
8. 修复kong入口问题并安装新的kong版本
cat > default-secret-kong-kong-token.yaml <<EOF
apiVersion: v1
kind: Secret
type: kubernetes.io/service-account-token
metadata:
name: kong-kong-token
annotations:
kubernetes.io/service-account.name: "kong-kong"
EOF
kubectl apply -f default-secret-kong-kong-token.yaml
kubectl delete daemonset -n kube-system aws-node
helm get values kong > helm-default-kong-before.yaml
cp -a helm-default-kong-before.yaml helm-default-kong-after.yaml
helm repo add kong https://charts.konghq.com
helm repo update
helm search repo kong -l
helm uninstall kong
helm mapkubeapis kong --namespace default --dry-run
helm mapkubeapis kong --namespace default
helm install kongkong kong/kong --version 2.14.0 --values helm-default-kong-after.yaml
kubectl scale -n default deployment kong-kong --replicas=3