From 1e0cea2f0f9f659fd28c78dd2be42a40c8563c03 Mon Sep 17 00:00:00 2001 From: Khurram Baig Date: Wed, 2 Aug 2023 12:56:11 +0530 Subject: [PATCH] Different config map for Leader Election per deployment Change configmap for leader election. This is so that we can apply changes per deployment. Also changed resolvers leader election name so that we can avoid conflict with controllers config if we install in same namespace. --- config/200-role.yaml | 6 +-- ...=> config-leader-election-controller.yaml} | 2 +- config/config-leader-election-events.yaml | 52 +++++++++++++++++++ config/config-leader-election-webhook.yaml | 52 +++++++++++++++++++ config/controller.yaml | 2 +- config/events.yaml | 2 +- config/resolvers/config-leader-election.yaml | 2 +- config/resolvers/resolvers-deployment.yaml | 2 +- config/webhook.yaml | 2 +- docs/enabling-ha.md | 2 +- 10 files changed, 114 insertions(+), 10 deletions(-) rename config/{config-leader-election.yaml => config-leader-election-controller.yaml} (98%) create mode 100644 config/config-leader-election-events.yaml create mode 100644 config/config-leader-election-webhook.yaml diff --git a/config/200-role.yaml b/config/200-role.yaml index 1ccb7a3ed12..dcd14410597 100644 --- a/config/200-role.yaml +++ b/config/200-role.yaml @@ -29,7 +29,7 @@ rules: - apiGroups: [""] resources: ["configmaps"] verbs: ["get"] - resourceNames: ["config-logging", "config-observability", "feature-flags", "config-leader-election", "config-registry-cert"] + resourceNames: ["config-logging", "config-observability", "feature-flags", "config-leader-election-controller", "config-registry-cert"] --- kind: Role apiVersion: rbac.authorization.k8s.io/v1 @@ -48,7 +48,7 @@ rules: - apiGroups: [""] resources: ["configmaps"] verbs: ["get"] - resourceNames: ["config-logging", "config-observability", "config-leader-election", "feature-flags"] + resourceNames: ["config-logging", "config-observability", "config-leader-election-webhook", "feature-flags"] - apiGroups: [""] resources: ["secrets"] verbs: ["list", "watch"] @@ -77,7 +77,7 @@ rules: - apiGroups: [""] resources: ["configmaps"] verbs: ["get"] - resourceNames: ["config-logging", "config-observability", "feature-flags", "config-leader-election", "config-registry-cert"] + resourceNames: ["config-logging", "config-observability", "feature-flags", "config-leader-election-events", "config-registry-cert"] --- kind: Role apiVersion: rbac.authorization.k8s.io/v1 diff --git a/config/config-leader-election.yaml b/config/config-leader-election-controller.yaml similarity index 98% rename from config/config-leader-election.yaml rename to config/config-leader-election-controller.yaml index 73f300c9c2f..8af224b7d19 100644 --- a/config/config-leader-election.yaml +++ b/config/config-leader-election-controller.yaml @@ -15,7 +15,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: config-leader-election + name: config-leader-election-controller namespace: tekton-pipelines labels: app.kubernetes.io/instance: default diff --git a/config/config-leader-election-events.yaml b/config/config-leader-election-events.yaml new file mode 100644 index 00000000000..55be4ea300c --- /dev/null +++ b/config/config-leader-election-events.yaml @@ -0,0 +1,52 @@ +# Copyright 2023 Tekton Authors LLC +# +# 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-leader-election-events + namespace: tekton-pipelines + labels: + app.kubernetes.io/instance: default + app.kubernetes.io/part-of: tekton-pipelines +data: + _example: | + ################################ + # # + # EXAMPLE CONFIGURATION # + # # + ################################ + # This block is not actually functional configuration, + # but serves to illustrate the available configuration + # options and document them in a way that is accessible + # to users that `kubectl edit` this config map. + # + # These sample configuration options may be copied out of + # this example block and unindented to be in the data block + # to actually change the configuration. + # lease-duration is how long non-leaders will wait to try to acquire the + # lock; 15 seconds is the value used by core kubernetes controllers. + lease-duration: "60s" + # renew-deadline is how long a leader will try to renew the lease before + # giving up; 10 seconds is the value used by core kubernetes controllers. + renew-deadline: "40s" + # retry-period is how long the leader election client waits between tries of + # actions; 2 seconds is the value used by core kubernetes controllers. + retry-period: "10s" + # buckets is the number of buckets used to partition key space of each + # Reconciler. If this number is M and the replica number of the controller + # is N, the N replicas will compete for the M buckets. The owner of a + # bucket will take care of the reconciling for the keys partitioned into + # that bucket. + buckets: "1" diff --git a/config/config-leader-election-webhook.yaml b/config/config-leader-election-webhook.yaml new file mode 100644 index 00000000000..8883a600b6a --- /dev/null +++ b/config/config-leader-election-webhook.yaml @@ -0,0 +1,52 @@ +# Copyright 2023 Tekton Authors LLC +# +# 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-leader-election-webhook + namespace: tekton-pipelines + labels: + app.kubernetes.io/instance: default + app.kubernetes.io/part-of: tekton-pipelines +data: + _example: | + ################################ + # # + # EXAMPLE CONFIGURATION # + # # + ################################ + # This block is not actually functional configuration, + # but serves to illustrate the available configuration + # options and document them in a way that is accessible + # to users that `kubectl edit` this config map. + # + # These sample configuration options may be copied out of + # this example block and unindented to be in the data block + # to actually change the configuration. + # lease-duration is how long non-leaders will wait to try to acquire the + # lock; 15 seconds is the value used by core kubernetes controllers. + lease-duration: "60s" + # renew-deadline is how long a leader will try to renew the lease before + # giving up; 10 seconds is the value used by core kubernetes controllers. + renew-deadline: "40s" + # retry-period is how long the leader election client waits between tries of + # actions; 2 seconds is the value used by core kubernetes controllers. + retry-period: "10s" + # buckets is the number of buckets used to partition key space of each + # Reconciler. If this number is M and the replica number of the controller + # is N, the N replicas will compete for the M buckets. The owner of a + # bucket will take care of the reconciling for the keys partitioned into + # that bucket. + buckets: "1" diff --git a/config/controller.yaml b/config/controller.yaml index d4a18b134f3..e90cc9c398f 100644 --- a/config/controller.yaml +++ b/config/controller.yaml @@ -101,7 +101,7 @@ spec: - name: CONFIG_FEATURE_FLAGS_NAME value: feature-flags - name: CONFIG_LEADERELECTION_NAME - value: config-leader-election + value: config-leader-election-controller - name: CONFIG_SPIRE value: config-spire - name: SSL_CERT_FILE diff --git a/config/events.yaml b/config/events.yaml index 39e595a2eae..088c0e28c15 100644 --- a/config/events.yaml +++ b/config/events.yaml @@ -83,7 +83,7 @@ spec: - name: CONFIG_OBSERVABILITY_NAME value: config-observability - name: CONFIG_LEADERELECTION_NAME - value: config-leader-election + value: config-leader-election-events - name: SSL_CERT_FILE value: /etc/config-registry-cert/cert - name: SSL_CERT_DIR diff --git a/config/resolvers/config-leader-election.yaml b/config/resolvers/config-leader-election.yaml index 300c42f080f..40dda69cab1 100644 --- a/config/resolvers/config-leader-election.yaml +++ b/config/resolvers/config-leader-election.yaml @@ -15,7 +15,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: config-leader-election + name: config-leader-election-resolvers namespace: tekton-pipelines-resolvers labels: app.kubernetes.io/component: resolvers diff --git a/config/resolvers/resolvers-deployment.yaml b/config/resolvers/resolvers-deployment.yaml index ae67cc6c7e4..87d1e7c8213 100644 --- a/config/resolvers/resolvers-deployment.yaml +++ b/config/resolvers/resolvers-deployment.yaml @@ -94,7 +94,7 @@ spec: - name: CONFIG_FEATURE_FLAGS_NAME value: feature-flags - name: CONFIG_LEADERELECTION_NAME - value: config-leader-election + value: config-leader-election-resolvers - name: METRICS_DOMAIN value: tekton.dev/resolution - name: PROBES_PORT diff --git a/config/webhook.yaml b/config/webhook.yaml index 19ee8fd43a1..41922fa1c1b 100644 --- a/config/webhook.yaml +++ b/config/webhook.yaml @@ -98,7 +98,7 @@ spec: - name: CONFIG_OBSERVABILITY_NAME value: config-observability - name: CONFIG_LEADERELECTION_NAME - value: config-leader-election + value: config-leader-election-webhook - name: CONFIG_FEATURE_FLAGS_NAME value: feature-flags # If you change PROBES_PORT, you will also need to change the diff --git a/docs/enabling-ha.md b/docs/enabling-ha.md index 521f0e957e0..74ae0042df3 100644 --- a/docs/enabling-ha.md +++ b/docs/enabling-ha.md @@ -38,7 +38,7 @@ kubectl -n tekton-pipelines scale deployment tekton-pipelines-controller --repli ### Configuring Leader Election -Leader election can be configured in [config-leader-election.yaml](./../config/config-leader-election.yaml). The ConfigMap defines the following parameters: +Leader election can be configured in [config-leader-election.yaml](./../config/config-leader-election-controller.yaml). The ConfigMap defines the following parameters: | Parameter | Default | | -------------------- | -------- |