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

Add root workflow, handle user-input as k8s secret #124

Merged
merged 6 commits into from
Feb 16, 2021

Conversation

mszostok
Copy link
Member

@mszostok mszostok commented Feb 11, 2021

Description

Changes proposed in this pull request:

  • Add our root workflow to allow us injecting input arguments
  • Change the user input from plain text to k8s secret
  • Add proper support for Jira install input params After Damian's PR Add Content Creation guide #116 I had to revert that.
  • Remove hard-coded password from Jira workflow will be done as a part of: https://cshark.atlassian.net/browse/SV-231
  • Make the postgresSQL password as optional
  • Add missing create-db method in Jira manifests
  • Test manifests e2e after rebase with master and fix found bugs

Testing

  1. Run
ENABLE_POPULATOR=false make dev-cluster
  1. Populate data:
kubectl -n neo4j port-forward svc/neo4j-neo4j 7687:7687

APP_JSONPUBLISHADDR=http://{ip} APP_LOGGER_DEV_MODE=true go run cmd/populator/main.go .
  1. Navigate to https://gateway.voltron.local.

  2. Copy graphql calls

mutation CreateActionForPostgres($postgresAction: String!) {
    createAction(
        in: {
            name: $postgresAction
            actionRef: {
                path: "cap.interface.database.postgresql.install"
                revision: "0.1.0"
            }
            dryRun: false
            advancedRendering: false
            input: {
                parameters: "{\r\n  \"superuser\": {\r\n    \"username\": \"postgres\",\r\n    \"password\": \"s3cr3t\"\r\n  },\r\n  \"defaultDBName\": \"test\"\r\n}"
            }
        }
    ) {
        name
    		input {
          parameters
        }
    }
}

mutation CreateActionForJira($jiraAction: String!) {
    createAction(
        in: {
            name: $jiraAction
            actionRef: {
                path: "cap.interface.productivity.jira.install"
            }
            dryRun: false
            advancedRendering: false
            input: {
                parameters: "{ \"host\": \"jira-cloud.voltron.local\" }"
            }
        }
    ) {
        name
    		input {
          parameters
        }
    }
}


query GetActions {
  actions {
    name
    createdAt
    input {
      parameters
    }
    renderedAction
    status {
      phase
      message
    }
  }
}

mutation RunPostgresAction($postgresAction: String!) {
    runAction(name: $postgresAction) {
        name
    }
}

mutation RunJiraAction($jiraAction: String!) {
    runAction(name: $jiraAction) {
        name
    }
}
  1. Copy variables
{ 
  "postgresAction": "postgres-install",
  "jiraAction": "jira-install"
}
  1. Execute CreateActionForPostgres
  2. Execute RunPostgresAction
  3. Execute CreateActionForJira
  4. Execute RunJiraAction

Both project should be installed.

Example workflow execution for Jira install:

Name:                jira-install
Namespace:           default
ServiceAccount:      jira-install
Status:              Succeeded
Conditions:
 Completed           True
Created:             Fri Feb 12 11:36:21 +0100 (7 minutes ago)
Started:             Fri Feb 12 11:36:21 +0100 (7 minutes ago)
Finished:            Fri Feb 12 11:43:52 +0100 (now)
Duration:            7 minutes 31 seconds
ResourcesDuration:   13m59s*(1 cpu),11m23s*(100Mi memory)
Output Artifacts:
  runner-context:    &S3Artifact{S3Bucket:S3Bucket{Endpoint:argo-minio.argo.svc.cluster.local:9000,Bucket:argo-artifacts,Region:,Insecure:*true,AccessKeySecret:{{argo-minio} accesskey <nil>},SecretKeySecret:{{argo-minio} secretkey <nil>},RoleARN:,UseSDKCreds:false,},Key:jira-install/jira-install-3499815058/runner-context.tgz,}
  jira-install-install-db-postgres-install-helm-run-helm-release: &S3Artifact{S3Bucket:S3Bucket{Endpoint:argo-minio.argo.svc.cluster.local:9000,Bucket:argo-artifacts,Region:,Insecure:*true,AccessKeySecret:{{argo-minio} accesskey <nil>},SecretKeySecret:{{argo-minio} secretkey <nil>},RoleARN:,UseSDKCreds:false,},Key:jira-install/jira-install-3358105751/helm-release.tgz,}
  jira-install-install-db-postgres-install-helm-run-additional: &S3Artifact{S3Bucket:S3Bucket{Endpoint:argo-minio.argo.svc.cluster.local:9000,Bucket:argo-artifacts,Region:,Insecure:*true,AccessKeySecret:{{argo-minio} accesskey <nil>},SecretKeySecret:{{argo-minio} secretkey <nil>},RoleARN:,UseSDKCreds:false,},Key:jira-install/jira-install-3358105751/additional.tgz,}
  jira-install-install-db-postgresql: &S3Artifact{S3Bucket:S3Bucket{Endpoint:argo-minio.argo.svc.cluster.local:9000,Bucket:argo-artifacts,Region:,Insecure:*true,AccessKeySecret:{{argo-minio} accesskey <nil>},SecretKeySecret:{{argo-minio} secretkey <nil>},RoleARN:,UseSDKCreds:false,},Key:jira-install/jira-install-1414881020/postgresql.tgz,}
  jira-install-install-db-psql-helm-release: &S3Artifact{S3Bucket:S3Bucket{Endpoint:argo-minio.argo.svc.cluster.local:9000,Bucket:argo-artifacts,Region:,Insecure:*true,AccessKeySecret:{{argo-minio} accesskey <nil>},SecretKeySecret:{{argo-minio} secretkey <nil>},RoleARN:,UseSDKCreds:false,},Key:jira-install/jira-install-2007023450/psql-helm-release.tgz,}
  jira-install-helm-run-helm-release: &S3Artifact{S3Bucket:S3Bucket{Endpoint:argo-minio.argo.svc.cluster.local:9000,Bucket:argo-artifacts,Region:,Insecure:*true,AccessKeySecret:{{argo-minio} accesskey <nil>},SecretKeySecret:{{argo-minio} secretkey <nil>},RoleARN:,UseSDKCreds:false,},Key:jira-install/jira-install-1944108654/helm-release.tgz,}
  jira-install-helm-run-additional: &S3Artifact{S3Bucket:S3Bucket{Endpoint:argo-minio.argo.svc.cluster.local:9000,Bucket:argo-artifacts,Region:,Insecure:*true,AccessKeySecret:{{argo-minio} accesskey <nil>},SecretKeySecret:{{argo-minio} secretkey <nil>},RoleARN:,UseSDKCreds:false,},Key:jira-install/jira-install-1944108654/additional.tgz,}
  jira-config:       &S3Artifact{S3Bucket:S3Bucket{Endpoint:argo-minio.argo.svc.cluster.local:9000,Bucket:argo-artifacts,Region:,Insecure:*true,AccessKeySecret:{{argo-minio} accesskey <nil>},SecretKeySecret:{{argo-minio} secretkey <nil>},RoleARN:,UseSDKCreds:false,},Key:jira-install/jira-install-2027337476/jira-config.tgz,}
  jira-helm-release: &S3Artifact{S3Bucket:S3Bucket{Endpoint:argo-minio.argo.svc.cluster.local:9000,Bucket:argo-artifacts,Region:,Insecure:*true,AccessKeySecret:{{argo-minio} accesskey <nil>},SecretKeySecret:{{argo-minio} secretkey <nil>},RoleARN:,UseSDKCreds:false,},Key:jira-install/jira-install-2878607363/jira-helm-release.tgz,}

STEP                                     TEMPLATE                                                            PODNAME                  DURATION  MESSAGE
 ✔ jira-install                          voltron-root
 ├---✔ inject-runner-context-step        inject-runner-context                                               jira-install-3499815058  3s
 ├---✔ populate-user-input-step          populate-user-input                                                 jira-install-2589070152  3s
 └---✔ start-entrypoint                  jira-install
     ├---✔ install-db                    jira-install-install-db-postgres-install
     |   ├---✔ create-helm-args          jira-install-install-db-postgres-install-create-helm-args-template  jira-install-220715739   4s
     |   ├---✔ helm-run                  jira-install-install-db-postgres-install-helm-run-helm              jira-install-3358105751  23s
     |   ├---✔ output-postgresql         jira-install-install-db-output-postgresql                           jira-install-1414881020  3s
     |   └---✔ output-psql-helm-release  jira-install-install-db-output-psql-helm-release                    jira-install-2007023450  4s
     ├---✔ create-helm-args              jira-install-create-helm-args-template                              jira-install-39921476    4s
     ├---✔ helm-run                      jira-install-helm-run-helm                                          jira-install-1944108654  6m
     ├---✔ output-jira-config            output-jira-config                                                  jira-install-2027337476  3s
     └---✔ output-jira-helm-release      output-jira-helm-release                                            jira-install-2878607363  3s

As you can see, we have now voltron-root step, which contains inject-runner-context and populate-user-input.
The real workflow starts as a part of start-entrypoint step with arguments from populate-user-input step.


Via helm get values you can check that password for standalone postgres-install is taken from the user input, but for jira-install it is generated.

@mszostok mszostok added the enhancement New feature or request label Feb 11, 2021
@mszostok mszostok force-pushed the global-to-local-inputs branch 2 times, most recently from fae7ece to da744ff Compare February 12, 2021 11:53
@mszostok
Copy link
Member Author

mszostok commented Feb 15, 2021

After Damina's PR: #116
I had to revert proper handling of input parameters for Jira workflow. Currently, it will require 3 levels of escaping for our Jinja2 template. I created a dedicated issue to resolve that problem.

After adding 3rd level of escaping the initial template becomes to complicated:

command: "install"
generateName: true
chart:
  name: "jira-software"
  repo: "https://helm.mox.sh"
output:
  {% raw -%}
  goTemplate:
    version: {{ '{% raw -%}"{{ .Values.image.tag }}"' }} `{{'{'}}% endraw -%{{` '}' }}
    host: {{ "'{{ template \"jira-software.fullname\" . }}'" }} # here is even harder as we already using both types of quote marks
  {% endraw -%}
values:
  postgresql:
    enabled: false
  databaseConnection:
    host: "{{ host }}"
    user: "{{ superuser.username }}"
    password: "{{ superuser.password }}"
    database: "{{ defaultDBName }}"
  ingress:
    enabled: true
    hosts:
    - host: {% raw %}{{ '"{{ host }}"' }}{% endraw %}
      paths: ['/']

We need to add an Action which consumes N input-parameters files.

  1. Currently, there is no way to easily aggregate output artifacts into a single step. Maybe we can use some hacks from map-reduce example: docs: Add map-reduce example. Closes #4165  argoproj/argo-workflows#4175
  2. We need to add logic which will merge input-parameters files as the Jinja2 template engine takes only one file with input data.

Copy link
Member

@pkosiec pkosiec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well 👍 Few small comments.

och-content/interface/productivity/jira/install.yaml Outdated Show resolved Hide resolved
och-content/implementation/atlassian/jira/install.yaml Outdated Show resolved Hide resolved
och-content/type/database/postgresql/install-input.yaml Outdated Show resolved Hide resolved
pkg/engine/k8s/api/v1alpha1/action_types.go Show resolved Hide resolved
pkg/sdk/renderer/argo/renderer.go Show resolved Hide resolved
pkg/sdk/renderer/argo/renderer.go Show resolved Hide resolved
pkg/sdk/renderer/argo/dedicated_renderer.go Show resolved Hide resolved
@mszostok mszostok merged commit 424f863 into master Feb 16, 2021
@mszostok mszostok deleted the global-to-local-inputs branch February 16, 2021 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants