-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom task that runs a Pipeline as a TaskRun 🍙
This commit adds a custom task that allows user to run simple sequential Pipelines as one TaskRun - which means the Pipeline can refer to multiple Tasks but run on only one pod. It only supports a subset of Pipeline functionality (more detail on what and why in the README) but is enough that folks can do a lot of what they would have previously used PipelineResources for, e.g. doing a git clone and then doing something with the data, in the same pod, and emit results such as the exact commit sha used. Next steps will be to expand the functionality supported, get feedback, and if the feedback is good, promote this to a top level Pipeline API feature. Experimental project proposal: tektoncd/community#447
- Loading branch information
1 parent
bed8bb7
commit 4133db4
Showing
38 changed files
with
6,048 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
Copyright 2021 The Tekton Authors | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
"github.com/tektoncd/experimental/pipeline-to-taskrun/pkg/reconciler/pipelinetotaskrun" | ||
//"github.com/tektoncd/experimental/pipeline-in-a-pod/pkg/reconciler/pipelinetotaskrun" | ||
"knative.dev/pkg/injection/sharedmain" | ||
) | ||
|
||
func main() { | ||
sharedmain.Main(pipelinetotaskrun.ControllerName, pipelinetotaskrun.NewController) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Copyright 2021 The Tekton Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: tekton-pipeline-to-taskrun | ||
labels: | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright 2021 The Tekton Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: pipeline-to-taskrun-controller | ||
namespace: tekton-pipeline-to-taskrun | ||
labels: | ||
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Copyright 2021 The Tekton Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: pipeline-to-taskrun-controller-cluster-access | ||
labels: | ||
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun | ||
rules: | ||
# Controller needs cluster access to all Run CRs. | ||
- apiGroups: ["tekton.dev"] | ||
resources: ["runs", "taskruns"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
- apiGroups: ["tekton.dev"] | ||
resources: ["pipelines", "tasks"] | ||
verbs: ["get", "list"] | ||
- apiGroups: ["tekton.dev"] | ||
resources: ["runs/finalizers"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
- apiGroups: ["tekton.dev"] | ||
resources: ["runs/status", "pipelineruns/status"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
|
||
# Controller needs cluster access to leases for leader election. | ||
- apiGroups: ["coordination.k8s.io"] | ||
resources: ["leases"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
|
||
# Controller needs permission to emit events associated with Run CRs. | ||
- apiGroups: [""] | ||
resources: ["events"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Copyright 2021 The Tekton Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: pipeline-to-taskrun-controller | ||
namespace: tekton-pipeline-to-taskrun | ||
labels: | ||
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun | ||
rules: | ||
- apiGroups: [""] | ||
resources: ["configmaps"] | ||
verbs: ["list", "watch"] | ||
|
||
# The controller needs access to these configmaps for logging information and runtime configuration. | ||
- apiGroups: [""] | ||
resources: ["configmaps"] | ||
verbs: ["get"] | ||
resourceNames: ["config-logging", "config-observability", "config-leader-election"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Copyright 2021 The Tekton Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: RoleBinding | ||
metadata: | ||
name: pipeline-to-taskrun-controller | ||
namespace: tekton-pipeline-to-taskrun | ||
labels: | ||
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun | ||
subjects: | ||
- kind: ServiceAccount | ||
name: pipeline-to-taskrun-controller | ||
namespace: tekton-pipeline-to-taskrun | ||
roleRef: | ||
kind: Role | ||
name: pipeline-to-taskrun-controller | ||
apiGroup: rbac.authorization.k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright 2021 The Tekton Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: pipeline-to-taskrun-controller-cluster-access | ||
labels: | ||
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun | ||
subjects: | ||
- kind: ServiceAccount | ||
name: pipeline-to-taskrun-controller | ||
namespace: tekton-pipeline-to-taskrun | ||
roleRef: | ||
kind: ClusterRole | ||
name: pipeline-to-taskrun-controller-cluster-access | ||
apiGroup: rbac.authorization.k8s.io |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Copyright 2021 The Tekton Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: pipeline-to-taskrun-controller | ||
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/version: devel | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun | ||
# tekton.dev/release value replaced with inputs.params.versionTag in pipeline/tekton/publish.yaml | ||
pipeline.tekton.dev/release: "devel" | ||
# labels below are related to istio and should not be used for resource lookup | ||
app: pipeline-to-taskrun-controller | ||
version: "devel" | ||
name: pipeline-to-taskrun-controller | ||
namespace: tekton-pipeline-to-taskrun | ||
spec: | ||
ports: | ||
- name: http-metrics | ||
port: 9090 | ||
protocol: TCP | ||
targetPort: 9090 | ||
selector: | ||
app.kubernetes.io/name: pipeline-to-taskrun-controller | ||
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright 2021 The Tekton Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: pipeline-to-taskrun-controller | ||
namespace: tekton-pipeline-to-taskrun | ||
labels: | ||
app.kubernetes.io/name: pipeline-to-taskrun-controller | ||
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/version: devel | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: pipeline-to-taskrun-controller | ||
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun | ||
template: | ||
metadata: | ||
annotations: | ||
cluster-autoscaler.kubernetes.io/safe-to-evict: "false" | ||
labels: | ||
app.kubernetes.io/name: pipeline-to-taskrun-controller | ||
app.kubernetes.io/component: pipeline-to-taskrun-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/version: devel | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun | ||
app: pipeline-to-taskrun-controller | ||
spec: | ||
serviceAccountName: pipeline-to-taskrun-controller | ||
containers: | ||
- name: pipeline-to-taskrun-controller | ||
image: ko://github.com/tektoncd/experimental/pipeline-to-taskrun/cmd/controller | ||
volumeMounts: | ||
- name: config-logging | ||
mountPath: /etc/config-logging | ||
env: | ||
- name: SYSTEM_NAMESPACE | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: metadata.namespace | ||
# If you are changing these names, you will also need to update | ||
# the controller's Role in 200-role.yaml to include the new | ||
# values in the "configmaps" "get" rule. | ||
- name: CONFIG_LOGGING_NAME | ||
value: config-logging | ||
volumes: | ||
- name: config-logging | ||
configMap: | ||
name: config-logging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Copyright 2021 The Tekton Authors | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License | ||
|
||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: config-logging | ||
namespace: tekton-pipeline-to-taskrun | ||
labels: | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipeline-to-taskrun | ||
data: | ||
# Common configuration for all knative codebase | ||
zap-logger-config: | | ||
{ | ||
"level": "info", | ||
"development": false, | ||
"sampling": { | ||
"initial": 100, | ||
"thereafter": 100 | ||
}, | ||
"outputPaths": ["stdout"], | ||
"errorOutputPaths": ["stderr"], | ||
"encoding": "json", | ||
"encoderConfig": { | ||
"timeKey": "ts", | ||
"levelKey": "level", | ||
"nameKey": "logger", | ||
"callerKey": "caller", | ||
"messageKey": "msg", | ||
"stacktraceKey": "stacktrace", | ||
"lineEnding": "", | ||
"levelEncoder": "", | ||
"timeEncoder": "", | ||
"durationEncoder": "", | ||
"callerEncoder": "" | ||
} | ||
} | ||
# Log level overrides | ||
loglevel.controller: "info" | ||
loglevel.webhook: "info" |
Oops, something went wrong.