From 2e94e0928ed09e10290b173e15eae8722c1a15e3 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 | 4 +- config/config-leader-election-events.yaml | 52 ++++++++++++++++++++ config/config-leader-election-webhook.yaml | 52 ++++++++++++++++++++ config/events.yaml | 2 +- config/resolvers/config-leader-election.yaml | 2 +- config/resolvers/resolvers-deployment.yaml | 2 +- config/webhook.yaml | 2 +- 7 files changed, 110 insertions(+), 6 deletions(-) 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..a6bef19f298 100644 --- a/config/200-role.yaml +++ b/config/200-role.yaml @@ -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-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/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 f9aeca84f77..08d2f80cb09 100644 --- a/config/resolvers/resolvers-deployment.yaml +++ b/config/resolvers/resolvers-deployment.yaml @@ -89,7 +89,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 # Override this env var to set a private hub api endpoint 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