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 kubernetes actions task in kubectl #367

Merged
merged 1 commit into from
Jul 21, 2020

Conversation

vinamra28
Copy link
Member

@vinamra28 vinamra28 commented Jun 16, 2020

Changes

The task kubectl-actions is a generic task which can be used to perform k8s-actions. We take the whole script as a params whereas the existing task kubectl-deploy only works for deploying the pod and fulfills the specific criteria #233

The following PR also contains a task which can be used to patch image deployment as a part of example.

Signed-off-by: vinamra28 [email protected]

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • Yaml file complies with yamllint rules.
  • Complies with Catalog Orgainization TEP, see example. Note An issue has been filed to automate this validation
    • File path follows <kind>/<name>/<version>/name.yaml

    • Has README.md at <kind>/<name>/<version>/README.md

    • Has mandatory metadata.labels - app.kubernetes.io/version the same as the <version> of the resource

    • Has mandatory metadata.annotations tekton.dev/pipelines.minVersion

    • mandatory spec.description follows the convention

        ```
      
        spec:
          description: >-
            one line summary of the resource
      
            Paragraph(s) to describe the resource.
        ```
      

See the contribution guide
for more details.


@tekton-robot
Copy link

Hi @vinamra28. Thanks for your PR.

I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot tekton-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 16, 2020
@vinamra28
Copy link
Member Author

@chmouel could you please have a look at this PR 🙂

@vinamra28
Copy link
Member Author

@vdemeester could you please take a look at this PR 😅

@vdemeester
Copy link
Member

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 18, 2020
@vdemeester vdemeester changed the base branch from v1beta1 to master June 19, 2020 14:13
@vdemeester
Copy link
Member

@vinamra28 switched the base branch to master as it got merged with v1beta1 now 👼

@vinamra28
Copy link
Member Author

/test pull-tekton-catalog-integration-tests

1 similar comment
@vinamra28
Copy link
Member Author

/test pull-tekton-catalog-integration-tests

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

/meow

@tekton-robot
Copy link

@vdemeester: cat image

In response to this:

/meow

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@tekton-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vdemeester

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 24, 2020
kubectl/README.md Outdated Show resolved Hide resolved
@savitaashture
Copy link
Contributor

savitaashture commented Jun 26, 2020

@vinamra28 can you rebase your PR

@vinamra28 vinamra28 force-pushed the vinamra28/k8s-actions branch 3 times, most recently from 6a5e8fa to c5c982a Compare June 26, 2020 15:14
@vinamra28
Copy link
Member Author

/test pull-tekton-catalog-integration-tests

@vinamra28 vinamra28 mentioned this pull request Jun 29, 2020
3 tasks
@a-roberts
Copy link
Member

Thanks for pointing me to this @vinamra28! I have some feedback

  1. the image in use here is not the lachlevenson one and it's therefore over 681 mb and not 18 mb - any reasons/advantages with this one? lachlanevenson/k8s-kubectl specifically, Add kubectl from path task #393 for reference

  2. why does this PR (like the original kubectl commit) contain anything to do with RBAC? I feel like that's beyond the scope of catalog items personally and it's up to users to do that

  3. - **manifest-dir**: Manifest files can be provided via the workspaces.(Default: _emptyDir:{}_ in case no manifest is provided) so I can't provide a URL? That's a big drawback if so and a deal-breaker IMO

@vinamra28
Copy link
Member Author

Thanks @a-roberts for the reviews.

  1. the image in use here is not the lachlevenson one and it's therefore over 681 mb and not 18 mb - any reasons/advantages with this one? lachlanevenson/k8s-kubectl specifically, Add kubectl from path task #393 for reference

I have parameterized the image so if you want to use another image then you can use it freely and also the image used was an official one from cloud-builders that's why I used it.

  1. why does this PR (like the original kubectl commit) contain anything to do with RBAC? I feel like that's beyond the scope of catalog items personally and it's up to users to do that

The RBAC is a part of the existing kubectl task present and the task which I added basically is this: https://github.com/vinamra28/catalog/blob/vinamra28/k8s-actions/kubectl/kubectl-actions.yaml

  1. - **manifest-dir**: Manifest files can be provided via the workspaces.(Default: _emptyDir:{}_ in case no manifest is provided) so I can't provide a URL? That's a big drawback if so and a deal-breaker IMO

Manifest via the URL can be provided in the script itself. For example :-

uapiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  name: kubectl-run
spec:
  taskRef:
    name: kubectl-actions
  params:
    - name: script
      value: |
        kubectl apply -f https://raw.githubusercontent.com/vinamra28/social-client/master/k8s/deployment.yaml
        ----------
        kubectll get deployment
  workspaces:
    - name: kubeconfig-dir
      emptyDir: {}
    - name: manifest-dir
      emptyDir: {}

Also as I can see in your task #393 that task is totally dependent on path of the manifest so if in case you want to delete the deployment or pod without using that manifest then this task can be useful. For example :-

kubectl delete deploy deployname -n namespace

@a-roberts
Copy link
Member

a-roberts commented Jun 30, 2020

Thanks @a-roberts for the reviews.

  1. the image in use here is not the lachlevenson one and it's therefore over 681 mb and not 18 mb - any reasons/advantages with this one? lachlanevenson/k8s-kubectl specifically, Add kubectl from path task #393 for reference

I have parameterized the image so if you want to use another image then you can use it freely and also the image used was an official one from cloud-builders that's why I used it.

Perhaps we add a comment saying (if you want to use something smaller, but not official, the lachlevenson image would also work)?

  1. why does this PR (like the original kubectl commit) contain anything to do with RBAC? I feel like that's beyond the scope of catalog items personally and it's up to users to do that

The RBAC is a part of the existing kubectl task present and the task which I added basically is this: https://github.com/vinamra28/catalog/blob/vinamra28/k8s-actions/kubectl/kubectl-actions.yaml

I don't feel strongly enough to contend this, so that's fair 😄

  1. - **manifest-dir**: Manifest files can be provided via the workspaces.(Default: _emptyDir:{}_ in case no manifest is provided) so I can't provide a URL? That's a big drawback if so and a deal-breaker IMO

Manifest via the URL can be provided in the script itself. For example :-

uapiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
  name: kubectl-run
spec:
  taskRef:
    name: kubectl-actions
  params:
    - name: script
      value: |
        kubectl apply -f https://raw.githubusercontent.com/vinamra28/social-client/master/k8s/deployment.yaml
        ----------
        kubectll get deployment
  workspaces:
    - name: kubeconfig-dir
      emptyDir: {}
    - name: manifest-dir
      emptyDir: {}

Also as I can see in your task #393 that task is totally dependent on path of the manifest so if in case you want to delete the deployment or pod without using that manifest then this task can be useful. For example :-

kubectl delete deploy deployname -n namespace

I was unaware you could do that, could you add something into the docs & task yaml so users know too? That would satisfy the use case I have I think, thanks!

@vinamra28 vinamra28 force-pushed the vinamra28/k8s-actions branch 2 times, most recently from b54479d to d9a6a43 Compare July 5, 2020 08:05
@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 11, 2020
kubectl/kubectl-actions.yaml Outdated Show resolved Hide resolved
@PuneetPunamiya
Copy link
Member

@vinamra28

  • It would be nice if you could add the task with all the files in the task directory
  ./task/         👈 the kind of the resource 
      /argocd       👈 definition file must have same name
        /0.1
          /README.md     👈 [optional] since there can be a fallback
          /argocd.yaml   👈 the file name must be resource name
        /0.2/...
      /golang-build
        /0.1
          /README.md
          /golang-build.yaml

Please see : #389

@vinamra28 vinamra28 force-pushed the vinamra28/k8s-actions branch 3 times, most recently from 859eae9 to 844e6ef Compare July 16, 2020 09:35
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 16, 2020
@vinamra28
Copy link
Member Author

/test pull-tekton-catalog-build-tests

@vinamra28
Copy link
Member Author

/test pull-tekton-catalog-build-tests

@chmouel
Copy link
Member

chmouel commented Jul 20, 2020

CI error should be addressed by @vdemeester's tektoncd/plumbing#485

@vinamra28
Copy link
Member Author

/test pull-tekton-catalog-build-tests

The task `kubectl-actions` is a generic task which can be used to perform k8s-actions. We take the whole script as a `params` whereas the existing task `kubectl-deploy` only works for deploying the pod and fulfills the specific criteria.

Signed-off-by: vinamra28 <[email protected]>
Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 21, 2020
@tekton-robot tekton-robot merged commit 457f4ef into tektoncd:master Jul 21, 2020
@vinamra28 vinamra28 deleted the vinamra28/k8s-actions branch July 30, 2020 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants