Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor manifests to use yaml merger #17

Merged
merged 2 commits into from
Aug 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ atlassian-ide-plugin.xml
# UUID file created by `setup-gcloud` GitHub Action when `export_default_credentials` is enabled
# Read more at https://github.com/GoogleCloudPlatform/github-actions/tree/master/setup-gcloud
/[a-f,0-9]*-[a-f,0-9]*-[a-f,0-9]*-[a-f,0-9]*-[a-f,0-9]*

# vim
*.swp
*.swo
86 changes: 32 additions & 54 deletions manifests/implementation/aws/elasticsearch/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,44 +136,37 @@ spec:
raw:
data: |

- - name: fill-default-input
capact-action: jinja2.template
- - name: prepare-parameters
template: prepare-parameters
arguments:
artifacts:
- name: input-parameters
from: "{{inputs.artifacts.input-parameters}}"
- name: template
raw:
data: |
replicas: <@ input.replicas | default(3) @>
- name: configuration
raw:
data: |
prefix: input
- name: additional-parameters
from: "{{inputs.artifacts.additional-parameters}}"
optional: true
- name: aws
from: "{{workflow.outputs.artifacts.aws-credentials}}"
- name: basicAuth
from: "{{steps.decode-es-creds.outputs.artifacts.render}}"

- - name: create-module-args
capact-action: jinja2.template
arguments:
artifacts:
- name: input-parameters
from: "{{inputs.artifacts.additional-parameters}}"
- name: configuration
raw:
data: |
prefix: additionalinput
- name: template
raw:
data: |
variables: |+
region = "<@ additionalinput.region | default("eu-west-1") @>"
region = "<@ additionalinput.region | default('eu-west-1') @>"
domain_name = "<@ additionalinput.domain_name | default('elastic-' + random_word(length=12)) @>"

advanced_security_options_enabled = true
advanced_security_options_internal_user_database_enabled = true
advanced_security_options_master_user_username = "<@ basicAuth.username @>"
advanced_security_options_master_user_password = "<@ basicAuth.password @>"

cluster_config_instance_count = "<@ input.replicas @>"
cluster_config_instance_count = "<@ input.replicas | default(3) @>"

<% if additionalinput.elasticsearch_version -%>
elasticsearch_version = "<@ additionalinput.elasticsearch_version @>"
Expand Down Expand Up @@ -388,45 +381,11 @@ spec:
vpc_id: "{{ .vpc_options_vpc_id }}"
availability_zones: "{{ .vpc_options_availability_zones }}"
elasticsearch_version: "{{ .elasticsearch_version }}"

- - name: fill-input-params
capact-action: jinja2.template
arguments:
artifacts:
- name: template
from: "{{steps.create-module-args.outputs.artifacts.render}}"
- name: input-parameters
from: "{{steps.fill-default-input.outputs.artifacts.render}}"
from: "{{steps.prepare-parameters.outputs.artifacts.merged}}"
- name: configuration
raw:
data: |
prefix: input

- - name: fill-aws-params
capact-action: jinja2.template
arguments:
artifacts:
- name: template
from: "{{steps.fill-input-params.outputs.artifacts.render}}"
- name: input-parameters
from: "{{workflow.outputs.artifacts.aws-credentials}}"
- name: configuration
raw:
data: |
prefix: aws

- - name: fill-secret-in-helm
capact-action: jinja2.template
arguments:
artifacts:
- name: template
from: "{{steps.fill-aws-params.outputs.artifacts.render}}"
- name: input-parameters
from: "{{steps.decode-es-creds.outputs.artifacts.render}}"
- name: configuration
raw:
data: |
prefix: basicAuth

- - name: terraform-apply
capact-action: terraform.apply
Expand All @@ -438,7 +397,7 @@ spec:
arguments:
artifacts:
- name: input-parameters
from: "{{steps.fill-secret-in-helm.outputs.artifacts.render}}"
from: "{{steps.create-module-args.outputs.artifacts.render}}"
- name: runner-context
from: "{{workflow.outputs.artifacts.runner-context}}"

Expand Down Expand Up @@ -490,3 +449,22 @@ spec:
image: bitnami/kubectl:1.18
command: [sh, -c]
args: ["kubectl create -f {{inputs.artifacts.manifest.path}} --output=yaml > {{outputs.artifacts.manifest.path}}"]

- name: prepare-parameters
inputs:
artifacts:
- name: input-parameters
path: /yamls/input.yaml
- name: additional-parameters
path: /yamls/additionalinput.yaml
optional: true
- name: aws
path: /yamls/aws.yaml
- name: basicAuth
path: /yamls/basicAuth.yaml
container:
image: ghcr.io/capactio/pr/infra/merger:PR-428
outputs:
artifacts:
- name: merged
path: /merged.yaml
73 changes: 29 additions & 44 deletions manifests/implementation/aws/rds/postgresql/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,39 +94,28 @@ spec:
- name: rds-instance
from: "{{steps.render-rds.outputs.artifacts.render}}"
steps:
- - name: fill-default-input
capact-action: jinja2.template
- - name: prepare-parameters
template: prepare-parameters
arguments:
artifacts:
- name: input-parameters
from: "{{inputs.artifacts.input-parameters}}"
- name: template
raw:
data: |
superuser:
username: "<@ input.superuser.username | default('postgres') @>"
password: "<@ input.superuser.password | default(random_word(length=16)) @>"
- name: configuration
raw:
data: |
prefix: input
- name: additional-parameters
from: "{{inputs.artifacts.additional-parameters}}"
optional: true
- name: aws
from: "{{workflow.outputs.artifacts.aws-credentials}}"

- - name: create-module-args
capact-action: jinja2.template
arguments:
artifacts:
- name: input-parameters
from: "{{inputs.artifacts.additional-parameters}}"
- name: configuration
raw:
data: |
prefix: additionalinput
- name: template
raw:
data: |
variables: |+
user_name = "<@ input.superuser.username @>"
user_password = "<@ input.superuser.password @>"
user_name = "<@ input.superuser.username | default('postgres') @>"
user_password = "<@ input.superuser.password | default(random_word(length=16)) @>"

region = "<@ additionalinput.region | default('eu-west-1') @>"
ingress_rule_cidr_blocks = "<@ additionalinput.ingress_rule_cidr_blocks | default('0.0.0.0/0') @>"
Expand Down Expand Up @@ -206,32 +195,11 @@ spec:
identifier: "{{ .identifier }}"
availability_zone: "{{ .availability_zone }}"
class: "{{ .class }}"

- - name: fill-input-in-module-args
capact-action: jinja2.template
arguments:
artifacts:
- name: template
from: "{{steps.create-module-args.outputs.artifacts.render}}"
- name: input-parameters
from: "{{steps.fill-default-input.outputs.artifacts.render}}"
- name: configuration
raw:
data: |
prefix: input

- - name: fill-aws-params-in-module-args
capact-action: jinja2.template
arguments:
artifacts:
- name: template
from: "{{steps.fill-input-in-module-args.outputs.artifacts.render}}"
- name: input-parameters
from: "{{workflow.outputs.artifacts.aws-credentials}}"
from: "{{steps.prepare-parameters.outputs.artifacts.merged}}"
- name: configuration
raw:
data: |
prefix: aws
data:

- - name: terraform-apply
capact-action: terraform.apply
Expand All @@ -241,7 +209,7 @@ spec:
arguments:
artifacts:
- name: input-parameters
from: "{{steps.fill-aws-params-in-module-args.outputs.artifacts.render}}"
from: "{{steps.create-module-args.outputs.artifacts.render}}"
- name: runner-context
from: "{{workflow.outputs.artifacts.runner-context}}"

Expand Down Expand Up @@ -285,3 +253,20 @@ spec:
identifier: "<@ identifier @>"
availability_zone: "<@ availability_zone @>"
class: "<@ class @>"

- name: prepare-parameters
inputs:
artifacts:
- name: input-parameters
path: /yamls/input.yaml
- name: additional-parameters
path: /yamls/additionalinput.yaml
optional: true
- name: aws
path: /yamls/aws.yaml
container:
image: ghcr.io/capactio/pr/infra/merger:PR-428
outputs:
artifacts:
- name: merged
path: /merged.yaml
93 changes: 37 additions & 56 deletions manifests/implementation/bitnami/mongodb/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,46 +73,20 @@ spec:
- name: mongodb
from: "{{steps.helm-install.outputs.artifacts.additional}}"
steps:
- - name: fill-default-input
capact-action: jinja2.template
- - name: prepare-parameters
template: prepare-parameters
arguments:
artifacts:
- name: input-parameters
from: "{{inputs.artifacts.input-parameters}}"
- name: template
raw:
data: |
user:
username: "<@ input.user.username | default('mongo') @>"
password: "<@ input.user.password | default(random_word(length=16)) @>"
defaultDBName: "<@ input.defaultDBName | default('mongo') @>"
rootPassword: "<@ input.rootPassword | default(random_word(length=16)) @>"
replicas: <@ input.replicas | default(3) @>
replicaSetName: "<@ input.replicaSetName | default('rs0') @>"
replicaSetKey: "<@ input.replicaSetKey | default(random_word(length=16)) @>"
replicaSetHostnames: <@ input.replicaSetHostnames | default(true) | tojson @>
directoryPerDB: <@ input.directoryPerDB | default(false) | tojson @>
enableIPv6: <@ input.enableIPv6 | default(false) | tojson @>
systemLogVerbosity: <@ input.systemLogVerbosity | default(0) @>
disableSystemLog: <@ input.disableSystemLog | default(false) | tojson @>
configuration: "<@ input.configuration | default('') @>"
initdbScripts: <@ input.initdbScripts | default({}) | tojson @>
- name: configuration
raw:
data: |
prefix: input
- name: additional-parameters
from: "{{inputs.artifacts.additional-parameters}}"
optional: true

- - name: create-helm-args
- - name: render-helm-args
capact-action: jinja2.template
arguments:
artifacts:
- name: input-parameters
from: "{{inputs.artifacts.additional-parameters}}"
- name: configuration
raw:
data: |
prefix: additionalinput

- name: template
raw:
data: |
Expand All @@ -135,11 +109,11 @@ spec:

auth:
enabled: true
username: <@ input.user.username @>
password: <@ input.user.password @>
database: <@ input.defaultDBName @>
rootPassword: <@ input.rootPassword @>
replicaSetKey: "<@ input.replicaSetKey @>"
username: "<@ input.user.username | default('mongo') @>"
password: "<@ input.user.password | default(random_word(length=16)) @>"
database: "<@ input.defaultDBName | default('mongo') @>"
rootPassword: "<@ input.rootPassword | default(random_word(length=16)) @>"
replicaSetKey: "<@ input.replicaSetKey | default(random_word(length=16)) @>"

tls:
enabled: <@ additionalinput.tls.enabled | default(false) | tojson @>
Expand All @@ -151,19 +125,19 @@ spec:
tag: <@ additionalinput.tls.image.tag | default("1.19.5-debian-10-r19") @>
pullPolicy: <@ additionalinput.tls.image.pullPolicy | default("IfNotPresent") @>

replicaSetName: <@ input.replicaSetName @>
replicaSetHostnames: <@ input.replicaSetHostnames @>
enableIPv6: <@ input.enableIPv6 @>
directoryPerDB: <@ input.directoryPerDB @>
systemLogVerbosity: <@ input.systemLogVerbosity @>
disableSystemLog: <@ input.disableSystemLog @>
configuration: "<@ input.configuration @>"
initdbScripts: <@ input.initdbScripts @>
replicaSetName: "<@ input.replicaSetName | default('rs0') @>"
replicaSetHostnames: <@ input.replicaSetHostnames | default(true) | tojson @>
enableIPv6: <@ input.enableIPv6 | default(false) | tojson @>
directoryPerDB: <@ input.directoryPerDB | default(false) | tojson @>
systemLogVerbosity: <@ input.systemLogVerbosity | default(0) @>
disableSystemLog: <@ input.disableSystemLog | default(false) | tojson @>
configuration: "<@ input.configuration | default('') @>"
initdbScripts: <@ input.initdbScripts | default({}) | tojson @>
extraFlags: <@ additionalinput.extraFlags | default([]) @>
extraEnvVars: <@ additionalinput.extraEnvVars | default([]) @>
annotations: <@ additionalinput.annotations | default({}) @>
labels: <@ additionalinput.labels | default({}) @>
replicaCount: <@ input.replicas @>
replicaCount: <@ input.replicas | default(3) @>
strategyType: <@ additionalinput.strategyType | default("RollingUpdate") @>
podManagementPolicy: <@ additionalinput.podManagementPolicy | default("OrderedReady") @>
podAffinityPreset: "<@ additionalinput.podAffinityPreset | default("") @>"
Expand Down Expand Up @@ -382,19 +356,11 @@ spec:
user:
username: '{{ .Values.auth.username }}'
password: '{{ .Values.auth.password }}'

- - name: fill-input-in-module-args
capact-action: jinja2.template
arguments:
artifacts:
- name: template
from: "{{steps.create-helm-args.outputs.artifacts.render}}"
- name: input-parameters
from: "{{steps.fill-default-input.outputs.artifacts.render}}"
from: "{{steps.prepare-parameters.outputs.artifacts.merged}}"
- name: configuration
raw:
data: |
prefix: input

- - name: helm-install
capact-action: helm.install
Expand All @@ -406,6 +372,21 @@ spec:
arguments:
artifacts:
- name: input-parameters
from: "{{steps.fill-input-in-module-args.outputs.artifacts.render}}"
from: "{{steps.render-helm-args.outputs.artifacts.render}}"
- name: runner-context
from: "{{workflow.outputs.artifacts.runner-context}}"

- name: prepare-parameters
inputs:
artifacts:
- name: input-parameters
path: /yamls/input.yaml
- name: additional-parameters
path: /yamls/additionalInput.yaml
optional: true
container:
image: ghcr.io/capactio/pr/infra/merger:PR-428
outputs:
artifacts:
- name: merged
path: /merged.yaml
Loading