-
-
Save mumoshu/e6d97b273eec57d4ec700a80bca111c7 to your computer and use it in GitHub Desktop.
ek
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env variant | |
mixins: | |
cluster: &cluster | |
type: object | |
properties: | |
vpc-private-subnets: | |
type: array | |
vpc-public-subnets: | |
type: array | |
vpc-node-role-policies: | |
type: array | |
node-labels: | |
type: array | |
parameters: | |
- name: sandbox | |
<<: *cluster | |
- name: environment | |
type: string | |
default: sandbox | |
required: true | |
- name: bucket | |
required: true | |
tasks: | |
write: | |
parameters: | |
- name: file | |
- name: content | |
script: | | |
cat <<EOF > {{ get "file" }} | |
{{ get "content" }} | |
EOF | |
diff: | |
steps: | |
- task: write | |
arguments: | |
file: current.yaml | |
content: | | |
{{ get "environment" | get | toYaml }} | |
- task: write | |
arguments: | |
file: desired.yaml | |
content: | | |
{{ get "environment" | get | toYaml }} | |
- script: | | |
diff --unified current.yaml desired.yaml | |
apply: | |
steps: | |
- or: | |
- task: diff | |
- task: put | |
- task: reconcile | |
put: | |
parameters: | |
- name: file | |
type: string | |
script: | | |
{{ $env := get "environment" }} | |
{{ $state := merge (get $env) (get "file" | readFile | fromYaml) }} | |
{{ $name := $state | dig "name" }} | |
{{ $bucket := get "bucket" }} | |
{{ $ns := $state | dig "namespace" }} | |
cat <<EOF > state.yaml | |
{{ $state | toYaml }} | |
EOF | |
aws s3 cp state.yaml s3://{{ $bucket }}/eks/environments/{{ $env }}/namespaces/{{ $ns }}/{{ $name }}/state.yaml | |
reconcile: | |
script: | | |
echo ./eksctl create cluster '{{ "environment" | get | get | toFlags }}' | |
get: | |
parameters: | |
- name: name | |
- name: namespace | |
script: | | |
{{ $env := get "environment" }} | |
{{ $name := get "name" }} | |
{{ $bucket := get "bucket" }} | |
{{ $ns := get "namespace" }} | |
aws s3 cp s3://{{ $bucket }}/eks/environments/{{ $env }}/namespaces/{{ $ns }}/{{{ $name }}/state.yaml state.yaml | |
cat state.yaml | |
test: | |
parameters: | |
- name: sandbox2 | |
<<: *cluster | |
script: | | |
echo '{{ "sandbox2" | get | toFlags }}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sandbox: | |
vpc-private-subnets: | |
- subnet-ID | |
- subnet-ID | |
vpc-public-subnets: | |
- subnet-ID | |
- subnet-ID | |
vpc-node-role-policies: | |
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy | |
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy | |
- arn:aws:iam::AWS_ACCOUNT_ID:policy/codedeploy-node | |
- arn:aws:iam::aws:policy/service-role/AmazonEC2RoleforSSM | |
- arn:aws:iam::AWS_ACCOUNT_ID:policy/codedeploy-namespacesandbox | |
node-security-groups: | |
- sg-ID | |
node-labels: | |
- mylabel1=myvalue1 | |
# node-role-name: eksctl-blue | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment