本指南将引导您配置一个弹性Kubernetes服务(EKS)集群。如果您需要更多信息,请参考创建一个Amazon EKS集群
在终端中配置AWS凭证。
aws configure
创建一个名为cluster-config.yaml
的新文件,并将以下内容添加到其中,将[your_cluster_name]
、[your_cluster_region]
和[your_k8s_version]
替换为相应的值:
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: [your_cluster_name]
region: [your_cluster_region]
version: [your_k8s_version]
tags:
karpenter.sh/discovery: [your_cluster_name]
iam:
withOIDC: true
managedNodeGroups:
- name: mng-od-4vcpu-8gb
desiredCapacity: 2
minSize: 1
maxSize: 5
instanceType: c5.xlarge
privateNetworking: true
addons:
- name: vpc-cni
attachPolicyARNs:
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
- name: coredns
version: latest
- name: kube-proxy
version: latest
- name: aws-ebs-csi-driver
wellKnownPolicies:
ebsCSIController: true
通过运行以下命令创建集群:
eksctl create cluster -f cluster.yaml
验证kubectl上下文:
kubectl config current-context
更新安全组规则,创建端口4000的入站规则,以允许EKS集群与Dapr sidecar通信。
aws ec2 authorize-security-group-ingress --region [your_aws_region] \
--group-id [your_security_group] \
--protocol tcp \
--port 4000 \
--source-group [your_security_group]
如果没有默认存储类,请添加一个:
kubectl patch storageclass gp2 -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
运行以下命令安装Dapr:
dapr init -k
您应该看到以下响应:
⌛ Making the jump to hyperspace...
ℹ️ Note: To install Dapr using Helm, see here: https://docs.dapr.io/getting-started/install-dapr-kubernetes/#install-with-helm-advanced
ℹ️ Container images will be pulled from Docker Hub
✅ Deploying the Dapr control plane with latest version to your cluster...
✅ Deploying the Dapr dashboard with latest version to your cluster...
✅ Success! Dapr has been installed to namespace dapr-system. To verify, run `dapr status -k' in your terminal. To get started, go here: https://docs.dapr.io/getting-started
如果您遇到访问权限问题,请确保您使用的是创建集群时使用的相同AWS配置文件。如有需要,使用正确的配置文件更新kubectl配置。更多信息请参考这里:
aws eks --region [your_aws_region] update-kubeconfig --name [your_eks_cluster_name] --profile [your_profile_name]