-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate the testing Wait Task to reconcile on v1beta1.CustomRun
As Custom Task Beta version is released, this PR creates a new Wait Task to reconcile on `v1beta1.CustomRun`, with the new condition changes applied.
- Loading branch information
1 parent
4ae320b
commit 0b8349b
Showing
8 changed files
with
3,787 additions
and
0 deletions.
There are no files selected for viewing
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,10 @@ | ||
# Beta Wait Custom Task for Tekton | ||
|
||
This folder is largely copied from [experimental/wait-task](https://github.com/tektoncd/experimental/tree/main/wait-task) | ||
for the testing purpose, with resources used for building and releasing the | ||
wait custom task removed. | ||
|
||
It provides a `Beta` version of [Tekton Custom | ||
Task](https://tekton.dev/docs/pipelines/customruns/) that, when run, simply waits a | ||
given amount of time before succeeding, specified by an input parameter named | ||
`duration`. It also supports `timeout` and `retries`. |
55 changes: 55 additions & 0 deletions
55
test/custom-task-ctrls/wait-task-beta/cmd/controller/main.go
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,55 @@ | ||
/* | ||
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/pipeline/test/wait-task-beta/cmd/controller" | ||
|
||
import ( | ||
"context" | ||
|
||
customruninformer "github.com/tektoncd/pipeline/pkg/client/injection/informers/pipeline/v1beta1/customrun" | ||
customrunreconciler "github.com/tektoncd/pipeline/pkg/client/injection/reconciler/pipeline/v1beta1/customrun" | ||
tkncontroller "github.com/tektoncd/pipeline/pkg/controller" | ||
"github.com/tektoncd/pipeline/test/wait-task-beta/pkg/reconciler" | ||
"k8s.io/client-go/tools/cache" | ||
"k8s.io/utils/clock" | ||
"knative.dev/pkg/configmap" | ||
"knative.dev/pkg/controller" | ||
"knative.dev/pkg/injection/sharedmain" | ||
) | ||
|
||
const controllerName = "wait-task-controller" | ||
|
||
func main() { | ||
sharedmain.Main(controllerName, newController) | ||
} | ||
|
||
func newController(ctx context.Context, cmw configmap.Watcher) *controller.Impl { | ||
c := &reconciler.Reconciler{ | ||
Clock: clock.RealClock{}, | ||
} | ||
impl := customrunreconciler.NewImpl(ctx, c, func(impl *controller.Impl) controller.Options { | ||
return controller.Options{ | ||
AgentName: controllerName, | ||
} | ||
}) | ||
|
||
customruninformer.Get(ctx).Informer().AddEventHandler(cache.FilteringResourceEventHandler{ | ||
FilterFunc: tkncontroller.FilterRunRef("wait.testing.tekton.dev/v1beta1", "Wait"), | ||
Handler: controller.HandleAll(impl.Enqueue), | ||
}) | ||
|
||
return impl | ||
} |
239 changes: 239 additions & 0 deletions
239
test/custom-task-ctrls/wait-task-beta/config/controller.yaml
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,239 @@ | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: wait-task-beta | ||
labels: | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: wait-task-beta | ||
|
||
--- | ||
|
||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: wait-task-controller | ||
namespace: wait-task-beta | ||
labels: | ||
app.kubernetes.io/component: wait-task-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: wait-task | ||
|
||
--- | ||
|
||
kind: ClusterRole | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: wait-task-controller-cluster-access | ||
labels: | ||
app.kubernetes.io/component: wait-task-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: wait-task | ||
rules: | ||
# Controller needs cluster access to all Run CRs. | ||
- apiGroups: ["tekton.dev"] | ||
resources: ["customruns"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
- apiGroups: ["tekton.dev"] | ||
resources: ["customruns/finalizers"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
- apiGroups: ["tekton.dev"] | ||
resources: ["customruns/status"] | ||
verbs: ["get", "list", "create", "update", "delete", "patch", "watch"] | ||
|
||
# Controller needs permission to configure master-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"] | ||
|
||
--- | ||
|
||
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
name: wait-task-controller | ||
namespace: wait-task-beta | ||
labels: | ||
app.kubernetes.io/component: wait-task-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: wait-task | ||
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"] | ||
|
||
--- | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: wait-task-controller | ||
namespace: wait-task-beta | ||
labels: | ||
app.kubernetes.io/component: wait-task-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: wait-task | ||
subjects: | ||
- kind: ServiceAccount | ||
name: wait-task-controller | ||
namespace: wait-task-beta | ||
roleRef: | ||
kind: Role | ||
name: wait-task-controller | ||
apiGroup: rbac.authorization.k8s.io | ||
|
||
--- | ||
|
||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: wait-task-controller-cluster-access | ||
labels: | ||
app.kubernetes.io/component: wait-task-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: wait-task | ||
subjects: | ||
- kind: ServiceAccount | ||
name: wait-task-controller | ||
namespace: wait-task-beta | ||
roleRef: | ||
kind: ClusterRole | ||
name: wait-task-controller-cluster-access | ||
apiGroup: rbac.authorization.k8s.io | ||
|
||
--- | ||
|
||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: config-logging | ||
namespace: wait-task-beta | ||
labels: | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: wait-task | ||
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": "", | ||
"levelKey": "level", | ||
"nameKey": "logger", | ||
"callerKey": "caller", | ||
"messageKey": "msg", | ||
"stacktraceKey": "stacktrace", | ||
"lineEnding": "", | ||
"levelEncoder": "", | ||
"timeEncoder": "", | ||
"durationEncoder": "", | ||
"callerEncoder": "" | ||
} | ||
} | ||
# Log level overrides | ||
loglevel.controller: "info" | ||
loglevel.webhook: "info" | ||
|
||
--- | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: wait-task-controller | ||
namespace: wait-task-beta | ||
labels: | ||
app.kubernetes.io/name: wait-task-controller | ||
app.kubernetes.io/component: wait-task-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/version: devel | ||
app.kubernetes.io/part-of: wait-task | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: wait-task-controller | ||
app.kubernetes.io/component: wait-task-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: wait-task | ||
template: | ||
metadata: | ||
annotations: | ||
cluster-autoscaler.kubernetes.io/safe-to-evict: "false" | ||
labels: | ||
app.kubernetes.io/name: wait-task-controller | ||
app.kubernetes.io/component: wait-task-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/version: devel | ||
app.kubernetes.io/part-of: wait-task | ||
app: wait-task-controller | ||
spec: | ||
serviceAccountName: wait-task-controller | ||
containers: | ||
- name: wait-task-controller | ||
image: ko://github.com/tektoncd/pipeline/test/wait-task-beta/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 | ||
- name: METRICS_DOMAIN | ||
value: wait.testing.tekton.dev/wait-task | ||
volumes: | ||
- name: config-logging | ||
configMap: | ||
name: config-logging | ||
|
||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: wait-task-controller | ||
app.kubernetes.io/component: wait-task-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/version: devel | ||
app.kubernetes.io/part-of: wait-task | ||
# 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: wait-task-controller | ||
version: "devel" | ||
name: wait-task-controller | ||
namespace: wait-task-beta | ||
spec: | ||
ports: | ||
- name: http-metrics | ||
port: 9090 | ||
protocol: TCP | ||
targetPort: 9090 | ||
selector: | ||
app.kubernetes.io/name: wait-task-controller | ||
app.kubernetes.io/component: wait-task-controller | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: wait-task |
13 changes: 13 additions & 0 deletions
13
test/custom-task-ctrls/wait-task-beta/example_customrun.yaml
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,13 @@ | ||
piVersion: tekton.dev/v1beta1 | ||
kind: CustomRun | ||
metadata: | ||
generateName: wait-customrun- | ||
spec: | ||
retries: 2 | ||
timeout: 10s | ||
customRef: | ||
apiVersion: wait.testing.tekton.dev/v1beta1 | ||
kind: Wait | ||
params: | ||
- name: duration | ||
value: 3s |
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,14 @@ | ||
module github.com/tektoncd/pipeline/test/wait-task-beta | ||
|
||
go 1.15 | ||
|
||
require ( | ||
github.com/emicklei/go-restful v2.15.0+incompatible // indirect | ||
github.com/google/go-cmp v0.5.9 | ||
github.com/tektoncd/pipeline v0.42.0 | ||
k8s.io/api v0.25.4 | ||
k8s.io/apimachinery v0.25.4 | ||
k8s.io/client-go v0.25.4 | ||
k8s.io/utils v0.0.0-20221012122500-cfd413dd9e85 | ||
knative.dev/pkg v0.0.0-20221011175852-714b7630a836 | ||
) |
Oops, something went wrong.