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

Dev #1

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Dev #1

wants to merge 8 commits into from

Conversation

Ishu27
Copy link
Contributor

@Ishu27 Ishu27 commented May 8, 2021

Addition of Event Templates

@Ishu27 Ishu27 requested a review from aelbarkani May 8, 2021 08:31
templates/workflow-template/workflow-template.yaml Outdated Show resolved Hide resolved
templates/workflow-template/workflow-template.yaml Outdated Show resolved Hide resolved
templates/workflow-template/workflow-template.yaml Outdated Show resolved Hide resolved
templates/workflow-template/workflow-template.yaml Outdated Show resolved Hide resolved
templates/workflow-template/workflow-template.yaml Outdated Show resolved Hide resolved
apiVersion: argoproj.io/v1alpha1
kind: WorkflowEventBinding
metadata:
name: event-bind-workflow
Copy link
Contributor

Choose a reason for hiding this comment

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

too much indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rectified Indentation

Copy link
Contributor

Choose a reason for hiding this comment

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

seems there is still too much indentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the first commit (the outdated one ), I have made a different commit named "Minor Changes".

@Ishu27 Ishu27 requested a review from aelbarkani May 10, 2021 09:34
templates/secrets/secret-role-binding.yaml Outdated Show resolved Hide resolved
apiVersion: v1
kind: ServiceAccount
metadata:
name: github.com
Copy link
Contributor

Choose a reason for hiding this comment

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

too much indentation

container:
image: alpine/helm
command: [sh, -c]
args: ["apk add --update git; git clone {{ workflow.parameters.github }}; DIR_TEST=$(ls) && cd $DIR_TEST && ls && export HELM_EXPERIMENTAL_OCI=1 && echo {{ inputs.parameters.token }} | helm registry login --username AWS --password-stdin {{ workflow.parameters.registry }}; helm chart save . {{ workflow.parameters.imagename }} && helm chart push {{ workflow.parameters.imagename }}"]
Copy link
Contributor

Choose a reason for hiding this comment

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

apk add should not be used, nor any package manager, since the image should not be root so these command should not be able to work. so this step should be splitted into more steps, one with git image and another with helm.
And by the way, how did this work ? Did you use an SCC or something ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the apk and added an extra step for git . No, I did not use any SCC. This would just pull the repo package it and push it to the Registry. Also there needs to be a webhook created for the repository so that it could be the trigger point

value: <secret_key>
- name: access
value: <access_key>
- name: github
Copy link
Contributor

Choose a reason for hiding this comment

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

should be a generic git url, not only github

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it and passed it on k8s secret

value: <aws_region>
- name: registry
value: "<registry_name>"
- name: imagename
Copy link
Contributor

Choose a reason for hiding this comment

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

chart name instead of imagename

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to imagename


- name: gen-token-bash
script:
image: amazon/aws-cli
Copy link
Contributor

Choose a reason for hiding this comment

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

we should have an image with a tag (specific version), not latest

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the image tag specific

templates:
- name: generate-token
steps:
- - name: generate
Copy link
Contributor

Choose a reason for hiding this comment

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

we need a more specific name for this step, "generate" is too generic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed generate to "create-token"

image: amazon/aws-cli
command: [bash]
source: |
export AWS_ACCESS_KEY_ID={{ workflow.parameters.access }} && export AWS_SECRET_ACCESS_KEY={{ workflow.parameters.secret }} && export AWS_DEFAULT_REGION={{ workflow.parameters.region }} && /usr/local/bin/aws ecr-public get-login-password --region {{ workflow.parameters.region }}
Copy link
Contributor

Choose a reason for hiding this comment

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

there are several security issues here. secrets should not be exposed like this in CLI

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Passed access-keys and all secrets into k8s secrets

container:
image: alpine/helm
command: [sh, -c]
args: ["apk add --update git; git clone {{ workflow.parameters.github }}; DIR_TEST=$(ls) && cd $DIR_TEST && ls && export HELM_EXPERIMENTAL_OCI=1 && echo {{ inputs.parameters.token }} | helm registry login --username AWS --password-stdin {{ workflow.parameters.registry }}; helm chart save . {{ workflow.parameters.imagename }} && helm chart push {{ workflow.parameters.imagename }}"]
Copy link
Contributor

Choose a reason for hiding this comment

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

DIR_TEST: is it really a directory for test ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed DIR_TEST

container:
image: alpine/helm
command: [sh, -c]
args: ["apk add --update git; git clone {{ workflow.parameters.github }}; DIR_TEST=$(ls) && cd $DIR_TEST && ls && export HELM_EXPERIMENTAL_OCI=1 && echo {{ inputs.parameters.token }} | helm registry login --username AWS --password-stdin {{ workflow.parameters.registry }}; helm chart save . {{ workflow.parameters.imagename }} && helm chart push {{ workflow.parameters.imagename }}"]
Copy link
Contributor

Choose a reason for hiding this comment

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

how do you manage git clone git repos that are not public which needs an authentication ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have taken a user input if repo is private or public , if private then user will have to create a secret whose template also I have added.

@Ishu27 Ishu27 requested a review from aelbarkani May 13, 2021 05:37
value: private # Can be private or public accordingly, private creds to be stored in a secret .

- name: public-url
value: "https://github.com/Ishu27/test-argo-workflow.git"
Copy link
Contributor

Choose a reason for hiding this comment

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

these examples should be removed, we need something clean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed examples and changed variable to git-url

value: us-east-1

- name: registry
value: "public.ecr.aws/h8x3r6g1"
Copy link
Contributor

Choose a reason for hiding this comment

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

these examples should be removed, we need something clean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed example and added simple registry_name instead.

- name: registry
value: "public.ecr.aws/h8x3r6g1"
- name: chartname
value: "public.ecr.aws/h8x3r6g1/test-argo:v2"
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be removed, we need something clean

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed and renamed

- name: workdir
mountPath: /mnt/vol

- name: others
Copy link
Contributor

Choose a reason for hiding this comment

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

"others" is too generic. step names should be specific and self-explanatory about the function of that step, like you did for other steps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to private-registry

metadata:
name: push-to-registry-template
spec:
arguments:
Copy link
Contributor

Choose a reason for hiding this comment

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

is arguments field necessary or can it be removed ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Parameters needs to be passed which are under arguments

templates:
- name: generate-token
steps:
- - name: pull-public-repo
Copy link
Contributor

Choose a reason for hiding this comment

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

this should be simplified. we should only have one "pull-repo" step, which should check in bash script whether git credentials have been provided. if yes, then they should be used. if not, then the script should assume that it's a public repo

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed the code and used a single step pull-repo

image: alpine/helm:3.5.4
imagePullPolicy: IfNotPresent
command: [sh, -c]
args: ["export HELM_EXPERIMENTAL_OCI=1 && helm registry login {{ workflow.parameters.registry }} --username $registry_username --password $registry_password ; cd /mnt/vol/git-local-dir && helm chart save . {{ workflow.parameters.chartname }} && helm chart push {{ workflow.parameters.chartname }} "]
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use "script" step to make the code more readable instead of using "&&" a lot. you can find an example here: https://argoproj.github.io/argo-workflows/examples/#scripts-results

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed and used script

image: amazon/aws-cli:2.2.4
imagePullPolicy: IfNotPresent
command: [sh, -c]
args: ["export AWS_ACCESS_KEY_ID=$access_key && export AWS_SECRET_ACCESS_KEY=$secret_key && export AWS_DEFAULT_REGION={{ workflow.parameters.region }} && /usr/local/bin/aws ecr-public get-login-password --region {{ workflow.parameters.region }}"]
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use "script" step to make the code more readable instead of using "&&" a lot. you can find an example here: https://argoproj.github.io/argo-workflows/examples/#scripts-results

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed and used script

image: alpine/helm:3.5.4
imagePullPolicy: IfNotPresent
command: [sh, -c]
args: ["export HELM_EXPERIMENTAL_OCI=1 && echo {{ inputs.parameters.token }} | helm registry login --username AWS --password-stdin {{ workflow.parameters.registry }}; cd /mnt/vol/git-local-dir && helm chart save . {{ workflow.parameters.chartname }} && helm chart push {{ workflow.parameters.chartname }}"]
Copy link
Contributor

Choose a reason for hiding this comment

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

you can use "script" step to make the code more readable instead of using "&&" a lot. you can find an example here: https://argoproj.github.io/argo-workflows/examples/#scripts-results

@Ishu27 Ishu27 requested a review from aelbarkani May 14, 2021 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants