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

Implement working Task that deploys to k8s using helm #63

Closed
bobcatfish opened this issue Sep 21, 2018 · 10 comments
Closed

Implement working Task that deploys to k8s using helm #63

bobcatfish opened this issue Sep 21, 2018 · 10 comments
Labels
meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given

Comments

@bobcatfish
Copy link
Collaborator

Expected Behavior

Once we have implemented a simple hellworld Task (#59) a user should be able to define a Task that can deploy at a k8s resource using helm.

This would mean that:

  • Templating is in place that allows for the Task to use the image and registry values specified in the input image resource in the steps of the Task as arguments to the helm commands
  • Any required service account needed for accessing to the cluster is available to the Task
  • Any logic needed to support the cluster type (see Add cluster and cluster bindings #60) is implemented

To try this out manually, you'll need a k8s cluster has been setup that you can deploy to.

Should include:

  • Expanding the docs about how to write a Task that uses an k8s cluster resource, and how to set up the service account correctly
  • Add docs on how to debug this when it doesn't work
  • Test coverage, unit and also integration if possible (see Setup PR testing for build-pipeline integration tests #16)

Actual Behavior

We have no logic currently for even running a task, but #59 will add basic logic. #62 will expand on this but shouldn't block this task.

Steps to Reproduce the Problem

  1. Deploy the Pipeline CRD + related CRDs to your cluster (note: should be docs on how to do this post kubebuilder)
  2. Create a Resource like this (you can use a public image such as the kritis one in this example or you can use any other image):
apiVersion: pipeline.knative.dev/v1beta1
kind: Resource
metadata:
  name: helm-resources
  namespace: default
spec:
  resources:
    - name: kritis-app-github-resource
      type: github
      params:
      - name: url
        value: https://github.com/grafeas/kritis
      - name: revision
        value: master
    - name: kritis-server
      type: image
      params:
        - name: url
          value: gcr.io/kritis-project
  1. Create a Task like this:
apiVersion: pipeline.knative.dev/v1beta1
kind: Task
metadata:
  name: helm
  namespace: default
spec:
    inputs:
        resources:
            - name: workspace
              type: github
            - name: imageToDeploy
              type: image
        params:
            - name: pathToHelmCharts
              value: string
            - name: helmArgs
              value: string
        cluster:
            - name: clusterToDeployTo
    buildSpec:
        steps:
        - name: deploy
          image: kubernetes-helm
          args: ['deploy', '--path=${pathToHelmChart}', '--set image=${imageToDeploy.Url}.${imageToDeploy.Name}', '${helmArgs}', '--cluster=${clusterToDeployTo.Endpoint}']

(Note I am pretty much making up the helm command here, please replace it with something that actually works and makes sense!)

  1. Create a TaskRun like this:
apiVersion: pipeline.knative.dev/v1beta1
kind: TaskRun
metadata:
  name: helm-run-0
spec:
    taskRef:
        name: helm
    resourceRef:
       name: helm-resources
    trigger:
        triggerRef:
            type: manual
  1. Look at the logs from the running container (Note the best docs we have on this at the moment are some of the steps in the Build quick start) to see that the helm command was successful (or not successful)
  2. Observe that the status of the TaskRun has been updated appropriately, e.g. see this example which contains:
  • Outcomes of individual steps
  • Started, Completed, and Successful conditions
  1. Look at the cluster itself and verify that the image has been deployed to it

Additional Info

@bobcatfish bobcatfish added this to the Mid October Demo milestone Sep 21, 2018
@nader-ziada
Copy link
Member

Should we consider this as a resource since it is the output of a Task?

@bobcatfish
Copy link
Collaborator Author

Should we consider this as a resource since it is the output of a Task?

By "this" do you mean the cluster than gets deployed to? Definitely!

Or do you mean the deployment itself? b/c that's an interesting idea that I don't think we'd thought of!

@nader-ziada
Copy link
Member

I meant the deployment of the chart, a helm resource that knows how to deploy similar to how the image resource knows how to upload the image to a registry

@bobcatfish
Copy link
Collaborator Author

I meant the deployment of the chart, a helm resource that knows how to deploy similar to how the image resource knows how to upload the image to a registry

Oooo neat! I think that's a cool idea, and makes a lot of sense since deployments will probably be a big part of what I imagine folks would want to use Pipelines for. Would you be interested in throwing together an issue to look into designing a Deployment resource?

@nader-ziada
Copy link
Member

Sure, I'll write up an issue for it

@bobcatfish
Copy link
Collaborator Author

Note: for milestone 1, we should go ahead and implement this before #68

@nader-ziada
Copy link
Member

/assign @pivotal-nader-ziada

@imjasonh
Copy link
Member

If it helps, Helm's founder contributed and maintains a container image that runs helm, with GKE integration, here.

@bobcatfish bobcatfish added the meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given label Oct 12, 2018
nader-ziada added a commit to nader-ziada/pipeline that referenced this issue Oct 17, 2018
 - tektoncd#63
 - create a pipeline of two tasks,
   - first task build and push an image
   - second task helm deploys that image
 - verify the service created is reachable
nader-ziada added a commit to nader-ziada/pipeline that referenced this issue Oct 17, 2018
 - tektoncd#63
 - create a pipeline of two tasks,
   - first task build and push an image
   - second task helm deploys that image
 - verify the service created is reachable
nader-ziada added a commit to nader-ziada/pipeline that referenced this issue Oct 18, 2018
 - tektoncd#63
 - create a pipeline of two tasks,
   - first task build and push an image
   - second task helm deploys that image
 - verify the service created is reachable
nader-ziada added a commit to nader-ziada/pipeline that referenced this issue Oct 19, 2018
 - tektoncd#63
 - create a pipeline of two tasks,
   - first task build and push an image
   - second task helm deploys that image
 - verify the service created is reachable
knative-prow-robot pushed a commit that referenced this issue Oct 20, 2018
 - #63
 - create a pipeline of two tasks,
   - first task build and push an image
   - second task helm deploys that image
 - verify the service created is reachable
@nader-ziada
Copy link
Member

nader-ziada commented Oct 22, 2018

@bobcatfish can you please close this issue, thanks

addressed by PR: #160
Will address the cluster selection by another issue and pr

@bobcatfish
Copy link
Collaborator Author

Okay I created #177 to add support for clusters, closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meaty-juicy-coding-work This task is mostly about implementation!!! And docs and tests of course but that's a given
Projects
None yet
Development

No branches or pull requests

3 participants