-
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.
Run events controller as separate binary
This is the first step towards moving the whole cloudevents logic to a dedicated controller. The `Run` controller is already separated from the other controllers, but it's compiled and deployed in the shared binary. In this change we move that controller to a dedicated binary, with its own deployment, service account, roles and bindings. This new binary shares the config maps from the pipeline binary, so that existing configuration options and docs continue to apply with no change. Because of injection, all the informers are setup for this binary, which means that the service account requires read access to the various tekton resources. This is fine however considering that eventually this controller will handle events for all tekton pipeline resources. The publish task is amended to expect the new events image by default as well. Partially-fixes: #2944 Signed-off-by: Andrea Frittoli <andrea.frittoli@uk.ibm.com>
- Loading branch information
Showing
8 changed files
with
297 additions
and
1 deletion.
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 @@ | ||
../../../LICENSE |
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 2023 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 ( | ||
"log" | ||
"net/http" | ||
"os" | ||
|
||
"github.com/tektoncd/pipeline/pkg/reconciler/customrun" | ||
"knative.dev/pkg/injection/sharedmain" | ||
) | ||
|
||
const eventsControllerName = "events-controller" | ||
|
||
func main() { | ||
// sets up liveness and readiness probes. | ||
mux := http.NewServeMux() | ||
|
||
mux.HandleFunc("/", handler) | ||
mux.HandleFunc("/health", handler) | ||
mux.HandleFunc("/readiness", handler) | ||
|
||
port := os.Getenv("PROBES_PORT") | ||
if port == "" { | ||
port = "8080" | ||
} | ||
|
||
go func() { | ||
// start the web server on port and accept requests | ||
log.Printf("Readiness and health check server listening on port %s", port) | ||
log.Fatal(http.ListenAndServe(":"+port, mux)) // #nosec G114 -- see https://github.com/securego/gosec#available-rules | ||
}() | ||
|
||
// start the events controller | ||
sharedmain.Main(eventsControllerName, customrun.NewController()) | ||
} | ||
|
||
func handler(w http.ResponseWriter, r *http.Request) { | ||
w.WriteHeader(http.StatusOK) | ||
} |
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
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
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
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
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,164 @@ | ||
# Copyright 2023 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. | ||
|
||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: tekton-events-controller | ||
namespace: tekton-pipelines | ||
labels: | ||
app.kubernetes.io/name: events | ||
app.kubernetes.io/component: events | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/version: "devel" | ||
app.kubernetes.io/part-of: tekton-pipelines | ||
# 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 | ||
version: "devel" | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: events | ||
app.kubernetes.io/component: events | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipelines | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: events | ||
app.kubernetes.io/component: events | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/version: "devel" | ||
app.kubernetes.io/part-of: tekton-pipelines | ||
# 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: tekton-pipelines-controller | ||
version: "devel" | ||
spec: | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: kubernetes.io/os | ||
operator: NotIn | ||
values: | ||
- windows | ||
serviceAccountName: tekton-events-controller | ||
containers: | ||
- name: tekton-events-controller | ||
image: ko://github.com/tektoncd/pipeline/cmd/events | ||
args: [] | ||
volumeMounts: | ||
- name: config-logging | ||
mountPath: /etc/config-logging | ||
- name: config-registry-cert | ||
mountPath: /etc/config-registry-cert | ||
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_DEFAULTS_NAME | ||
value: config-defaults | ||
- name: CONFIG_LOGGING_NAME | ||
value: config-logging | ||
- name: CONFIG_OBSERVABILITY_NAME | ||
value: config-observability | ||
- name: CONFIG_LEADERELECTION_NAME | ||
value: config-leader-election | ||
- name: SSL_CERT_FILE | ||
value: /etc/config-registry-cert/cert | ||
- name: SSL_CERT_DIR | ||
value: /etc/ssl/certs | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
capabilities: | ||
drop: | ||
- "ALL" | ||
# User 65532 is the nonroot user ID | ||
runAsUser: 65532 | ||
runAsGroup: 65532 | ||
runAsNonRoot: true | ||
seccompProfile: | ||
type: RuntimeDefault | ||
ports: | ||
- name: metrics | ||
containerPort: 9090 | ||
- name: profiling | ||
containerPort: 8008 | ||
- name: probes | ||
containerPort: 8080 | ||
livenessProbe: | ||
httpGet: | ||
path: /health | ||
port: probes | ||
scheme: HTTP | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
timeoutSeconds: 5 | ||
readinessProbe: | ||
httpGet: | ||
path: /readiness | ||
port: probes | ||
scheme: HTTP | ||
initialDelaySeconds: 5 | ||
periodSeconds: 10 | ||
timeoutSeconds: 5 | ||
volumes: | ||
- name: config-logging | ||
configMap: | ||
name: config-logging | ||
- name: config-registry-cert | ||
configMap: | ||
name: config-registry-cert | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: events | ||
app.kubernetes.io/component: events | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/version: "devel" | ||
app.kubernetes.io/part-of: tekton-pipelines | ||
# 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: tekton-pipelines-controller | ||
version: "devel" | ||
name: tekton-pipelines-controller | ||
namespace: tekton-pipelines | ||
spec: | ||
ports: | ||
- name: http-metrics | ||
port: 9090 | ||
protocol: TCP | ||
targetPort: 9090 | ||
- name: http-profiling | ||
port: 8008 | ||
targetPort: 8008 | ||
- name: probes | ||
port: 8080 | ||
selector: | ||
app.kubernetes.io/name: events | ||
app.kubernetes.io/component: events | ||
app.kubernetes.io/instance: default | ||
app.kubernetes.io/part-of: tekton-pipelines |
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