Skip to content

Instantly share code, notes, and snippets.

@mumoshu mumoshu/eks
Last active Feb 1, 2019

Embed
What would you like to do?
ek
#!/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 }}'
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
You can’t perform that action at this time.