取消注册Job Defination
:
aws batch deregister-job-definition --job-definition ${JD_CPI_NAME}:1
删除 ECR 存储库:
aws ecr delete-repository --repository-name ${ECR_REPO_NAME_CPI} --force
删除 EKS IAM 服务账户和 IAM 角色:
eksctl delete iamserviceaccount \
--name ${BATCH_EKS_ECR_SA_NAME} \
--namespace ${BATCH_EKS_NAMESPACE} \
--cluster ${BATCH_EKS_CLUSTER_NAME} \
--wait
aws iam delete-policy --policy-arn ${BATCH_EKS_ECR_POLICY_ARN}
执行以下命令:
# disable the JQ and CE
aws batch update-job-queue --job-queue ${BATCH_EKS_JQ_NAME} --state DISABLED
aws batch update-compute-environment --compute-environment ${BATCH_EKS_CE_NAME} --state DISABLED
# wait for the JQ and CE to disable, then delete the JQ
sleep 30
aws batch delete-job-queue --job-queue ${BATCH_EKS_JQ_NAME}
# wait for the JQ to delete and then delete the CE
sleep 60
aws batch delete-compute-environment --compute-environment ${BATCH_EKS_CE_NAME}
# if the last step failed, wait a few seconds and re-issue the last command
删除与 Batch 相关的 EKS 资源:
# use eksctl to delete the identity mapping
eksctl delete iamidentitymapping \
--cluster ${BATCH_EKS_CLUSTER_NAME} \
--arn "arn:aws:iam::${ACCOUNT_ID}:role/aws-service-role/batch.amazonaws.com/AWSServiceRoleForBatch" \
--region ${AWS_REGION}
# use kubectl to remove the Kubernetes permissions.
kubectl delete rolebinding aws-batch-compute-environment-role-binding -n ${BATCH_EKS_NAMESPACE}
kubectl delete role aws-batch-compute-environment-role -n ${BATCH_EKS_NAMESPACE}
kubectl delete clusterrolebindings.rbac.authorization.k8s.io aws-batch-cluster-role-binding
kubectl delete clusterroles.rbac.authorization.k8s.io aws-batch-cluster-role