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

Migrate our Tekton CD folder away from PipelineResources #887

Closed
6 tasks done
Tracked by #912
ghost opened this issue Sep 2, 2021 · 6 comments · Fixed by #1164
Closed
6 tasks done
Tracked by #912

Migrate our Tekton CD folder away from PipelineResources #887

ghost opened this issue Sep 2, 2021 · 6 comments · Fixed by #1164
Labels
area/dogfooding Indicates an issue on dogfooding (aka using Pipeline to test Pipeline) kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.

Comments

@ghost
Copy link

ghost commented Sep 2, 2021

Feature request

The Tasks and Pipelines we currently have in our cd directory utilize Cluster PipelineResources because they provide a way to include cluster secrets that won't expose them in logs.

This issue is to capture work to move away from PipelineResources in the resources from that directory. The current best alternative to the Cluster PipelineResource might be https://github.com/tektoncd/catalog/blob/main/task/kubeconfig-creator/0.1/kubeconfig-creator.yaml although that currently accepts credentials via param which is definitely not a secure approach.

@ghost ghost added the kind/feature Categorizes issue or PR as related to a new feature. label Sep 2, 2021
@tekton-robot
Copy link
Contributor

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 1, 2021
@afrittoli
Copy link
Member

/lifecycle frozen This is something that need to do in light of the deprecation of pipeline resources

@vdemeester
Copy link
Member

/lifecycle frozen

@tekton-robot tekton-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Dec 2, 2021
@afrittoli
Copy link
Member

afrittoli commented Jul 21, 2022

Current cluster resources in use:

$ tkn resource list -t cluster
NAME                           TYPE      DETAILS
dogfooding                     cluster   url: https://35.222.251.168
dogfooding-tekton-cd           cluster   url: https://35.222.251.168
dogfooding-tekton-ci-default   cluster   url: https://35.222.251.168
dogfooding-tekton-deployer     cluster   url: https://35.222.251.168
dogfooding-tektoncd-cleaner    cluster   url: https://35.222.251.168
dogfooding-tektonci-default    cluster   url: https://35.222.251.168
prow-cluster-config-bot        cluster   url: https://104.198.136.199
prow-github-admin-default      cluster   url: https://104.198.136.199
robocat-cadmin                 cluster   url: https://35.228.156.151
robocat-tekton-deployer        cluster   url: https://35.228.156.151

An alternative approach could be to generate a kubeconfig for each of these resources and store it in a secret on the cluster.
We can rewrite the CD template to accept a workspace as input and bind it to a different secret depending on the target cluster / service account.

If any of the clusters or service accounts is recreated, the secrets will have to be refreshed, which is true today as well.

@afrittoli
Copy link
Member

Tekton resources to convert:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: resource-converter
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  name: secret-creator
rules:
- apiGroups: [""]
  resources: ["secrets"]
  verbs: ["get", "list", "watch", "create", "patch", "update"]
- apiGroups: ["tekton.dev"]
  resources: ["PipelineResources"]
  verbs: ["get", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: resource-converter-secret-creator
subjects:
- kind: ServiceAccount
  name: resource-converter
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: secret-creator
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: resource-to-secret
spec:
  params:
    - name: targetSecret
  resources:
    inputs:
      - name: sourceResource
        type: cluster
  stepTemplate:
    env:
      - name: TARGET_SECRET
        value: $(params.targetSecret)
      - name: KUBECONFIG_PATH
        value: /workspace/$(resources.inputs.sourceResource.name)
  steps:
    - name: create-secret
      image: gcr.io/tekton-releases/dogfooding/kubectl
      script: |
        #!/bin/sh
        set -ex

        kubectl create secret generic "${TARGET_SECRET}" \
          --from-file="${KUBECONFIG_PATH}/kubeconfig" \
          --type=kubeconfig

        kubectl label "secret/${TARGET_SECRET}" app=tekton.cd

@afrittoli
Copy link
Member

Script to convert all resources:

#!/bin/sh 

tkn resource list -t cluster | awk '/cluster/{ print $1 }' | while read aa; do 
  tkn task start resource-to-secret -s resource-converter -i sourceResource=${aa} -p targetSecret=tektoncd-${aa}; 
done

Resulting secrets:

$ kubectl get secret -l app=tekton.cd
NAME                                    TYPE         DATA   AGE
tektoncd-dogfooding                     kubeconfig   1      18s
tektoncd-dogfooding-tekton-cd           kubeconfig   1      18s
tektoncd-dogfooding-tekton-ci-default   kubeconfig   1      15s
tektoncd-dogfooding-tektoncd-cleaner    kubeconfig   1      15s
tektoncd-dogfooding-tektonci-default    kubeconfig   1      11s
tektoncd-prow-cluster-config-bot        kubeconfig   1      13s
tektoncd-prow-github-admin-default      kubeconfig   1      11s
tektoncd-robocat-cadmin                 kubeconfig   1      9s
tektoncd-robocat-tekton-deployer        kubeconfig   1      8s

afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 21, 2022
Folder template relies on the cluster PipelineResource to target
deployments of resources and git PipelineResource to clone the
git repository.

Migrate that to workspaces:
- the git-clone task from the catalog is used to clone the repo
- a secret stored in the cluster bound through a workspace is
  used to target the deployment

Secrets have been preprovisioned on the cluster, their name is
tektoncd-<pipeline-resource-name>, their type is kubeconfig.
See tektoncd#887 for more
details.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 21, 2022
Folder template relies on the cluster PipelineResource to target
deployments of resources and git PipelineResource to clone the
git repository.

Migrate that to workspaces:
- the git-clone task from the catalog is used to clone the repo
- a secret stored in the cluster bound through a workspace is
  used to target the deployment

Secrets have been preprovisioned on the cluster, their name is
tektoncd-<pipeline-resource-name>, their type is kubeconfig.
See tektoncd#887 for more
details.

The interface of the trigger template is untouched, so existing
cronjobs will continue to work as they are.

Signed-off-by: Andrea Frittoli <[email protected]>
tekton-robot pushed a commit that referenced this issue Jul 21, 2022
Folder template relies on the cluster PipelineResource to target
deployments of resources and git PipelineResource to clone the
git repository.

Migrate that to workspaces:
- the git-clone task from the catalog is used to clone the repo
- a secret stored in the cluster bound through a workspace is
  used to target the deployment

Secrets have been preprovisioned on the cluster, their name is
tektoncd-<pipeline-resource-name>, their type is kubeconfig.
See #887 for more
details.

The interface of the trigger template is untouched, so existing
cronjobs will continue to work as they are.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 21, 2022
Namespace cleanup template relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 21, 2022
Configmap CD relies on the cluster PipelineResource to target
deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 21, 2022
Configmap CD relies on the cluster PipelineResource to target
deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 21, 2022
Configmap CD relies on the cluster PipelineResource to target
deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 21, 2022
Configmap CD relies on the cluster PipelineResource to target
deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid.

Signed-off-by: Andrea Frittoli <[email protected]>
tekton-robot pushed a commit that referenced this issue Jul 22, 2022
Namespace cleanup template relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See #887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 22, 2022
Configmap CD relies on the cluster PipelineResource to target
deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid.

Signed-off-by: Andrea Frittoli <[email protected]>
tekton-robot pushed a commit that referenced this issue Jul 22, 2022
Configmap CD relies on the cluster PipelineResource to target
deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See #887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 22, 2022
Helm chart deployment relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 22, 2022
Helm chart deployment relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 22, 2022
Install Tekton release relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid as well as
the deployment script.

Signed-off-by: Andrea Frittoli <[email protected]>
tekton-robot pushed a commit that referenced this issue Jul 22, 2022
Helm chart deployment relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See #887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 22, 2022
Install Tekton release relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid as well as
the deployment script.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 23, 2022
Install Tekton release relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid as well as
the deployment script.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 24, 2022
Install Tekton release relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid as well as
the deployment script.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 24, 2022
Install Tekton release relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid as well as
the deployment script.

Signed-off-by: Andrea Frittoli <[email protected]>
afrittoli added a commit to afrittoli/plumbing that referenced this issue Jul 24, 2022
Install Tekton release relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See tektoncd#887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid as well as
the deployment script.

Signed-off-by: Andrea Frittoli <[email protected]>
tekton-robot pushed a commit that referenced this issue Jul 27, 2022
Install Tekton release relies on the cluster PipelineResource
to target deployments of resources.

Migrate that to workspaces: a secret stored in the cluster bound
through a workspace is used to target the deployment.

Secrets have been preprovisioned on the cluster, their name is
tektoncd-, their type is kubeconfig.

See #887 for more details.

The change is implemented so that the template interface does not
change and thus all existing cronjobs are still valid as well as
the deployment script.

Signed-off-by: Andrea Frittoli <[email protected]>
@dibyom dibyom added the area/dogfooding Indicates an issue on dogfooding (aka using Pipeline to test Pipeline) label Aug 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/dogfooding Indicates an issue on dogfooding (aka using Pipeline to test Pipeline) kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants