-
Notifications
You must be signed in to change notification settings - Fork 0
/
dynamic-pipeline.yfg.yaml
112 lines (106 loc) · 3.05 KB
/
dynamic-pipeline.yfg.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# In this example, parts of the pipeline will be determined dynamically by
# generating pipelines from generators and using their values
pipeline:
# Dynamically render a sub-pipeline that will render a different pipeline based
# on the configuration options specified in file/dynamic-config.yaml
- name: dynamic-fetch-ami-id
gotemplate:
refVars:
config:
file: files/dynamic-config.yaml
template:
value: |
{{ if eq .config.amiID.method "static" }}
# Return the AMI ID specified in the configuration directly
generator:
value:
input:
value: '{{ .config.amiID.static }}'
{{ else if eq .config.amiID.method "ssmParameter" }}
# dynamically fetch the AMI ID from an ssm parameter
pipeline:
- name: fetch-ami-id
exec:
command: /bin/bash
args:
- -c
- |
aws ssm get-parameter --name '{{ .config.amiID.ssmParameter }}' --output json --query 'Parameter.Value'
- name: extract-ami-id
jq:
input:
ref: fetch-ami-id
expr: '. | fromjson | .image_id'
{{ else }}
{{ printf "invalid amiID.method: %q" .config.amiID.method | fail }}
{{ end }}
# Get the AMI ID using the pipeline that was created above
- name: ami-id
pipeline:
import:
ref: dynamic-fetch-ami-id
- name: karpenter-values
gotemplate:
refVars:
eks:
file: ../files/eks-vars.yaml
template:
value:
serviceAccount:
annotations:
eks.amazonaws.com/role-arn: "{{ .eks.roleARN }}"
settings:
clusterName: "{{ .eks.clusterName }}"
clusterEndpoint: "{{ .eks.clusterEndpoint }}"
interruptionQueue: "{{ .eks.clusterName }}"
- name: helm
helm:
chart: oci://public.ecr.aws/karpenter/karpenter
version: 1.0.0
releaseName: karpenter
namespace: karpenter
includeCRDs: true
values:
- ref: karpenter-values
- name: karpenter-node-pool
gotemplate:
refVars:
eks:
file: ../files/eks-vars.yaml
amiID:
ref: ami-id
template:
value: |
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: default
spec:
template:
spec:
nodeClassRef:
group: karpenter.k8s.aws
kind: EC2NodeClass
name: default
---
apiVersion: karpenter.k8s.aws/v1
kind: EC2NodeClass
metadata:
name: default
spec:
role: "{{ .eks.nodeClassRole }}"
amiSelectorTerms:
- id: "{{ .amiID }}"
securityGroupSelectorTerms:
- tags:
karpenter.sh/discovery: "{{ .eks.clusterName }}"
subnetSelectorTerms:
- tags:
karpenter.sh/discovery: "{{ .eks.clusterName }}"
tags:
managed-by: karpenter
- name: output
yaml:
input:
- ref: helm
- ref: karpenter-node-pool