sparse-intern-71089
01/24/2019, 8:30 PMgorgeous-egg-16927
01/24/2019, 8:43 PMwhite-balloon-205
white-ghost-79509
01/24/2019, 9:01 PMmost-pager-38056
01/25/2019, 12:14 AMaws-alb-ingress-controller
chart (thanks to this amazing Pulumi feature!). It looks like this:
export const albChart = new k8s.helm.v2.Chart(
'alb-ingress-controller',
{
chart: 'aws-alb-ingress-controller',
values: {
clusterName: cluster.eksCluster.name,
autoDiscoverAwsRegion: true,
autoDiscoverAwsVpcID: true,
},
fetchOpts: {
repo: '<http://storage.googleapis.com/kubernetes-charts-incubator>',
},
},
{
providers: { kubernetes: cluster.provider },
},
);
And a policy attachment, as suggested by @white-balloon-205:
export const albPolicyAttachment = new RolePolicyAttachment(
'alb-ingress-controller-policy-attachment',
{
policyArn:
'arn:aws:iam::ACCOUNT_ID:policy/AmazonEKSALBIngressControllerPolicy',
role: cluster.instanceRole,
},
);
Our policy is not created inside our stack. We were using a single AWS account for both stage/prod environment, so we decided to create the policy manually by using the IAM dashboard. Here is the policy we used: https://raw.githubusercontent.com/kubernetes-sigs/aws-alb-ingress-controller/master/docs/examples/iam-policy.json
Now we can create a ingress inside our cluster, that’s how it looks like:
export const ingress = new k8s.extensions.v1beta1.Ingress(
`${appName}-ingress`,
{
metadata: {
annotations: {
'<http://kubernetes.io/ingress.class|kubernetes.io/ingress.class>': 'alb',
'<http://alb.ingress.kubernetes.io/scheme|alb.ingress.kubernetes.io/scheme>': 'internet-facing',
'<http://alb.ingress.kubernetes.io/subnets|alb.ingress.kubernetes.io/subnets>': coreStackReference.outputs.apply(
outputs => outputs.subnetIds.join(', '),
),
'<http://alb.ingress.kubernetes.io/certificate-arn|alb.ingress.kubernetes.io/certificate-arn>': coreStackReference.outputs.apply(
outputs => outputs.originCertificateArn,
),
},
},
spec: {
// ingress spec...
},
},
{
provider: cluster.provider,
},
);
Notice that both origin certificate ARN and subnet ids should be specified, so the ALB can map the nodes to the load balancer. We decided to use the concept of a “core-stack” (with vpc, ssl certificates, etc) to avoid recreating these resources in every stack we wanted to use ALB.
That’s it. 🙂