Skip to content

Commit

Permalink
Remove Cluster pipelineResources
Browse files Browse the repository at this point in the history
This commit removes the Cluster Resources support.
This PR removes `github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/cluster`
the kubeConfigWriter image and docs for cluseter resources.
Removal of `pipelineResources`, as in tektoncd#5967 has been broken up into removal
of each resources packages for the `small PR` code standard.
  • Loading branch information
JeromeJu committed Jan 18, 2023
1 parent a044400 commit 3e96dcd
Show file tree
Hide file tree
Showing 18 changed files with 3 additions and 1,331 deletions.
1 change: 0 additions & 1 deletion cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func main() {
flag.StringVar(&opts.Images.SidecarLogResultsImage, "sidecarlogresults-image", "", "The container image containing the binary for accessing results.")
flag.StringVar(&opts.Images.NopImage, "nop-image", "", "The container image used to stop sidecars")
flag.StringVar(&opts.Images.GitImage, "git-image", "", "The container image containing our Git binary.")
flag.StringVar(&opts.Images.KubeconfigWriterImage, "kubeconfig-writer-image", "", "The container image containing our kubeconfig writer binary.")
flag.StringVar(&opts.Images.ShellImage, "shell-image", "", "The container image containing a shell")
flag.StringVar(&opts.Images.ShellImageWin, "shell-image-win", "", "The container image containing a windows shell")
flag.StringVar(&opts.Images.GsutilImage, "gsutil-image", "", "The container image containing gsutil")
Expand Down
1 change: 0 additions & 1 deletion cmd/kubeconfigwriter/kodata/LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion cmd/kubeconfigwriter/kodata/third_party

This file was deleted.

118 changes: 0 additions & 118 deletions cmd/kubeconfigwriter/main.go

This file was deleted.

1 change: 0 additions & 1 deletion config/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ spec:
args: [
# These images are built on-demand by `ko resolve` and are replaced
# by image references by digest.
"-kubeconfig-writer-image", "ko://github.com/tektoncd/pipeline/cmd/kubeconfigwriter",
"-git-image", "ko://github.com/tektoncd/pipeline/cmd/git-init",
"-entrypoint-image", "ko://github.com/tektoncd/pipeline/cmd/entrypoint",
"-nop-image", "ko://github.com/tektoncd/pipeline/cmd/nop",
Expand Down
2 changes: 0 additions & 2 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,6 @@ list of image references with their digest as part of the `args`:
args: [
# These images are built on-demand by `ko resolve` and are replaced
# by image references by digest.
"-kubeconfig-writer-image",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/kubeconfigwriter:v0.28.1@sha256:55963ed3fb6157e5f8dac7a315a794ebe362e46714631f9c79d79d33fe769e4d",
"-git-image",
"gcr.io/tekton-releases/github.com/tektoncd/pipeline/cmd/git-init:v0.28.1@sha256:83d5ec6addece4aac79898c9631ee669f5fee5a710a2ed1f98a6d40c19fb88f7",
"-entrypoint-image",
Expand Down
161 changes: 0 additions & 161 deletions docs/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ For example:
- [Git Resource](#git-resource)
- [Pull Request Resource](#pull-request-resource)
- [Image Resource](#image-resource)
- [Cluster Resource](#cluster-resource)
- [Storage Resource](#storage-resource)
- [GCS Storage Resource](#gcs-storage-resource)
- [Cloud Event Resource](#cloud-event-resource)
Expand Down Expand Up @@ -668,166 +667,6 @@ status:
If the `index.json` file is not produced, the image digest will not be included
in the `taskRun` output.

### Cluster Resource

A `cluster` resource represents a Kubernetes cluster other than the current
cluster Tekton Pipelines is running on. A common use case for this resource is
to deploy your application/function on different clusters.

The resource will use the provided parameters to create a
[kubeconfig](https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/)
file that can be used by other steps in the pipeline `Task` to access the target
cluster. The kubeconfig will be placed in
`/workspace/<your-cluster-name>/kubeconfig` on your `Task` container

The Cluster resource has the following parameters:

- `url` (required): Host url of the master node
- `username` (required): the user with access to the cluster
- `password`: to be used for clusters with basic auth
- `namespace`: The namespace to target in the cluster
- `token`: to be used for authentication, if present will be used ahead of the
password
- `insecure`: to indicate server should be accessed without verifying the TLS
certificate.
- `cadata` (required): holds PEM-encoded bytes (typically read from a root
certificates bundle).
- `clientKeyData`: contains PEM-encoded data from a client key file
for TLS
- `clientCertificateData`: contains PEM-encoded data from a client cert file for TLS


Note: Since only one authentication technique is allowed per user, either a
`token` or a `password` should be provided, if both are provided, the `password`
will be ignored.

`clientKeyData` and `clientCertificateData` are only required if `token` or
`password` is not provided for authentication to cluster.

The following example shows the syntax and structure of a `cluster` resource:

```yaml
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: test-cluster
spec:
type: cluster
params:
- name: url
value: https://10.10.10.10 # url to the cluster master node
- name: cadata
value: LS0tLS1CRUdJTiBDRVJ.....
- name: token
value: ZXlKaGJHY2lPaU....
```

For added security, you can add the sensitive information in a Kubernetes
[Secret](https://kubernetes.io/docs/concepts/configuration/secret/) and populate
the kubeconfig from them.

For example, create a secret like the following example:

```yaml
apiVersion: v1
kind: Secret
metadata:
name: target-cluster-secrets
data:
cadatakey: LS0tLS1CRUdJTiBDRVJUSUZ......tLQo=
tokenkey: ZXlKaGJHY2lPaUpTVXpJMU5pSXNJbX....M2ZiCg==
```

and then apply secrets to the cluster resource

```yaml
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
name: test-cluster
spec:
type: cluster
params:
- name: url
value: https://10.10.10.10
- name: username
value: admin
secrets:
- fieldName: token
secretKey: tokenKey
secretName: target-cluster-secrets
- fieldName: cadata
secretKey: cadataKey
secretName: target-cluster-secrets
```

Example usage of the `cluster` resource in a `Task`, using
[variable substitution](tasks.md#variable-substitution):

```yaml
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: deploy-image
namespace: default
spec:
resources:
inputs:
- name: workspace
type: git
- name: dockerimage
type: image
- name: test-cluster
type: cluster
steps:
- name: deploy
image: image-with-kubectl
command: ["bash"]
args:
- "-c"
- kubectl --kubeconfig
/workspace/$(resources.inputs.test-cluster.name)/kubeconfig --context
$(resources.inputs.test-cluster.name) apply -f /workspace/service.yaml'
```

To use the `cluster` resource with Google Kubernetes Engine, you should use the
`cadata` authentication mechanism.

To determine the caData, you can use the following `gcloud` commands:

```shell
gcloud container clusters describe <cluster-name> --format='value(masterAuth.clusterCaCertificate)'
```

To create a secret with this information, you can use:

```shell
CADATA=$(gcloud container clusters describe <cluster-name> --format='value(masterAuth.clusterCaCertificate)')
kubectl create secret generic cluster-ca-data --from-literal=cadata=$CADATA
```

To retrieve the URL, you can use this gcloud command:

```shell
gcloud container clusters describe <cluster-name> --format='value(endpoint)'
```

Then to use these in a resource, reference the cadata from the secret you
created above, and use the IP address from the gcloud command as your url
(prefixed with https://):

```yaml
spec:
type: cluster
params:
- name: url
value: https://<ip address determined above>
secrets:
- fieldName: cadata
secretName: cluster-ca-data
secretKey: cadata
```

### Storage Resource

The `storage` resource represents blob storage, that contains either an object
Expand Down
1 change: 0 additions & 1 deletion pkg/apis/pipeline/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func (i Images) Validate() error {
{i.SidecarLogResultsImage, "sidecarlogresults-image"},
{i.NopImage, "nop-image"},
{i.GitImage, "git-image"},
{i.KubeconfigWriterImage, "kubeconfig-writer-image"},
{i.ShellImage, "shell-image"},
{i.ShellImageWin, "shell-image-win"},
{i.GsutilImage, "gsutil-image"},
Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/pipeline/v1beta1/resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ const (
// PipelineResourceTypeImage indicates that this source is a docker Image.
PipelineResourceTypeImage PipelineResourceType = resource.PipelineResourceTypeImage

// PipelineResourceTypeCluster indicates that this source is a k8s cluster Image.
PipelineResourceTypeCluster PipelineResourceType = resource.PipelineResourceTypeCluster

// PipelineResourceTypePullRequest indicates that this source is a SCM Pull Request.
PipelineResourceTypePullRequest PipelineResourceType = resource.PipelineResourceTypePullRequest

Expand Down
3 changes: 0 additions & 3 deletions pkg/apis/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
pipelinev1beta1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
resourcev1alpha1 "github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1"
"github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/cloudevent"
"github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/cluster"
"github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/git"
"github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/image"
"github.com/tektoncd/pipeline/pkg/apis/resource/v1alpha1/pullrequest"
Expand All @@ -39,8 +38,6 @@ func FromType(name string, r *resourcev1alpha1.PipelineResource, images pipeline
return git.NewResource(name, images.GitImage, r)
case resourcev1alpha1.PipelineResourceTypeImage:
return image.NewResource(name, r)
case resourcev1alpha1.PipelineResourceTypeCluster:
return cluster.NewResource(name, images.KubeconfigWriterImage, images.ShellImage, r)
case resourcev1alpha1.PipelineResourceTypeStorage:
return storage.NewResource(name, images, r)
case resourcev1alpha1.PipelineResourceTypePullRequest:
Expand Down
Loading

0 comments on commit 3e96dcd

Please sign in to comment.