chi*_*mar 5 amazon-web-services aws-cloudformation kubernetes amazon-eks aws-cloudformation-custom-resource
我们有 Cloudformation 模板,通过它我们可以为我们的产品部署基础设施资源。以下是通过 CF 模板创建的 AWS 组件: 1. 网络组件。如 VPC、子网、安全组等。 2. IAM 角色和策略。3. EMR 4. EKS 5. MSK 6. RDS 7. 弹性疼痛
此外,在我们的 Cloudformation 模板中,我们几乎没有自定义资源,例如“Custom::KubeManifest”。我们通过它在 AWS EKS 集群中部署对象。我们的 kubernetes 对象之一是“Service”对象。它为内部服务创建一个服务端点,以便来自公共网络的请求可以到达我们的 kubernetes 集群。
我们想要检查是否可以在 Cloudformation 模板中引用现有的 ELB DNS 名称,以便我们可以将 ELB DnsName 显示为输出。
例如,当我们调用“Custom::KubeManifest”资源时,如下模板:
ServiceDeployment:
Type: "Custom::KubeManifest"
Version: '1.0'
Properties:
ServiceToken: !Ref KubeManifestLambdaArn
KubeConfigPath: !Sub "s3://${KubeConfigS3Bucket}/${KubeConfigS3Key}"
KubeConfigKmsContext: !Ref KmsContext
Manifest:
apiVersion: v1
kind: Service
metadata:
name: test
labels:
app: client
tier: master
spec:
selector:
app: client
tier: master
ports:
- name: client-api
port: 9877
protocol: TCP
- name: client-snapshots
port: 9878
protocol: TCP
- name: client-support
port: 9881
protocol: TCP
UiDeployment:
Type: "Custom::KubeManifest"
Version: '1.0'
Properties:
ServiceToken: !Ref KubeManifestLambdaArn
KubeConfigPath: !Sub "s3://${KubeConfigS3Bucket}/${KubeConfigS3Key}"
KubeConfigKmsContext: !Ref KmsContext
Manifest:
apiVersion: v1
kind: Service
metadata:
name: client-ui
annotations:
service.beta.kubernetes.io/aws-load-balancer-internal: 0.0.0.0/0
service.beta.kubernetes.io/aws-load-balancer-proxy-protocol: '*'
service.beta.kubernetes.io/aws-load-balancer-type: nlb
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: 'tcp'
service.beta.kubernetes.io/aws-load-balancer-ssl-ports: "tcp"
service.beta.kubernetes.io/aws-load-balancer-connection-idle-timeout: "60"
labels:
app: client
tier: master
spec:
type: LoadBalancer
selector:
app: client
tier: master
ports:
- name: client-ui
port: 80
protocol: TCP
targetPort: 8800
- name: client-ui-https
port: 443
protocol: TCP
targetPort: 8800
Run Code Online (Sandbox Code Playgroud)
它在 AWS 账户中创建一个 ELB,并将其与 EKS 集群中的服务端点进行映射。现在我们想知道是否可以通过任何函数引用新创建的 ELB DnsNames 并将其显示为输出。
这是我的 YAML 示例
Resources:
LoadBalancer:
Type: AWS::ElasticLoadBalancingV2::LoadBalancer
Properties:
Name: !Ref EnvironmentName
Subnets: !Ref Subnets
SecurityGroups:
- !Ref SecurityGroup
Tags:
- Key: Name
Value: !Ref EnvironmentName
LoadBalancerListener:
Type: AWS::ElasticLoadBalancingV2::Listener
Properties:
LoadBalancerArn: !Ref LoadBalancer
Port: 80
Protocol: HTTP
DefaultActions:
- Type: forward
TargetGroupArn: !Ref DefaultTargetGroup
Run Code Online (Sandbox Code Playgroud)
两者LoadBalancer都LoadBAlanceListener 必须包括在内。然后,您必须添加输出来声明您希望可用于描述堆栈 API 调用的值。
Outputs:
LoadBalancer:
Description: A reference to the Application Load Balancer
Value: !Ref LoadBalancer
LoadBalancerUrl:
Description: The URL of the ALB
Value: !GetAtt LoadBalancer.DNSName
Listener:
Description: A reference to a port 80 listener
Value: !Ref LoadBalancerListener
Run Code Online (Sandbox Code Playgroud)
我们查看了帖子: aws-quickstart-examples-eks
我们可以使用以下命令获取新创建的 loadBalancer 的 DnsNames,该负载均衡器映射到服务端点
自定义::KubeGet
资源。
| 归档时间: |
|
| 查看次数: |
5469 次 |
| 最近记录: |