From 4fdc89b2280c6e28ece2243c4d4130f993a4e2f5 Mon Sep 17 00:00:00 2001 From: xingran Date: Wed, 23 Oct 2024 13:59:29 +0800 Subject: [PATCH] chore: upgrade pulsar addon to v1.0 API and add scripts ut (#1111) --- README.md | 2 +- addons-cluster/pulsar/templates/cluster.yaml | 2 +- addons/pulsar/Chart.yaml | 9 +- .../config/broker-config-constraint.cue | 1498 ----------------- .../pulsar/config/proxy-config-constraint.cue | 362 ---- .../pulsar/config/zookeeper-server-config.tpl | 12 - addons/pulsar/config/zookeeper-servers.tpl | 20 - .../bookies_member_leave_spec.sh | 88 + .../scripts-ut-spec/check_bookies_spec.sh | 64 + .../scripts-ut-spec/init_bookies_spec.sh | 125 ++ .../scripts-ut-spec/init_broker_spec.sh | 210 +++ .../pulsar/scripts-ut-spec/init_proxy_spec.sh | 57 + .../scripts-ut-spec/start_bookies_spec.sh | 120 ++ .../scripts-ut-spec/start_broker_spec.sh | 90 + addons/pulsar/scripts-ut-spec/utils.sh | 32 + addons/pulsar/scripts/bookies-member-leave.sh | 49 + addons/pulsar/scripts/check-bookies.sh | 56 +- addons/pulsar/scripts/init-bookies.sh | 82 +- addons/pulsar/scripts/init-broker-sysctl.sh | 28 +- addons/pulsar/scripts/init-broker.sh | 130 +- addons/pulsar/scripts/init-proxy.sh | 40 +- addons/pulsar/scripts/prestop-bookies.sh | 6 - .../pulsar/scripts/start-bookies-recovery.sh | 14 +- addons/pulsar/scripts/start-bookies.sh | 125 +- addons/pulsar/scripts/start-broker.sh | 117 +- addons/pulsar/scripts/start-proxy.sh | 14 +- addons/pulsar/scripts/start-zookeeper.sh | 12 +- addons/pulsar/templates/_helpers.tpl | 322 ++++ .../pulsar/templates/clusterdefinition.yaml | 21 +- ...very.yaml => cmpd-bookies-recovery-2.yaml} | 30 +- .../templates/cmpd-bookies-recovery-3.yaml | 110 ++ ...bookkeeper.yaml => cmpd-bookkeeper-2.yaml} | 87 +- .../pulsar/templates/cmpd-bookkeeper-3.yaml | 164 ++ .../{cmpd-broker.yaml => cmpd-broker-2.yaml} | 105 +- addons/pulsar/templates/cmpd-broker-3.yaml | 260 +++ .../{cmpd-proxy.yaml => cmpd-proxy-2.yaml} | 46 +- addons/pulsar/templates/cmpd-proxy-3.yaml | 159 ++ ...d-zookeeper.yaml => cmpd-zookeeper-2.yaml} | 34 +- addons/pulsar/templates/cmpd-zookeeper-3.yaml | 108 ++ addons/pulsar/templates/cmpv-bkrecovery.yaml | 5 +- addons/pulsar/templates/cmpv-bookkeeper.yaml | 3 +- addons/pulsar/templates/cmpv-broker.yaml | 2 +- addons/pulsar/templates/cmpv-proxy.yaml | 2 +- addons/pulsar/templates/cmpv-zookeeper.yaml | 2 +- ...figmap.yaml => bookies-env-configmap.yaml} | 2 +- ...ml => bookies-recovery-env-configmap.yaml} | 2 +- ...nfigmap.yaml => broker-env-configmap.yaml} | 2 +- ...onfigmap.yaml => proxy-env-configmap.yaml} | 2 +- .../config/pulsar-tools-configmap.yaml | 2 +- .../config/pulsar2-config-configmap.yaml | 6 +- .../config/pulsar3-config-configmap.yaml | 6 +- ...gmap.yaml => zookeeper-env-configmap.yaml} | 2 +- .../pulsar/templates/configconstraints.yaml | 29 +- addons/pulsar/templates/scripts.yaml | 6 +- addons/pulsar/values.yaml | 35 +- examples/pulsar/cluster-cmpd.yaml | 2 +- 56 files changed, 2723 insertions(+), 2197 deletions(-) delete mode 100644 addons/pulsar/config/broker-config-constraint.cue delete mode 100644 addons/pulsar/config/proxy-config-constraint.cue delete mode 100644 addons/pulsar/config/zookeeper-server-config.tpl delete mode 100644 addons/pulsar/config/zookeeper-servers.tpl create mode 100644 addons/pulsar/scripts-ut-spec/bookies_member_leave_spec.sh create mode 100644 addons/pulsar/scripts-ut-spec/check_bookies_spec.sh create mode 100644 addons/pulsar/scripts-ut-spec/init_bookies_spec.sh create mode 100644 addons/pulsar/scripts-ut-spec/init_broker_spec.sh create mode 100644 addons/pulsar/scripts-ut-spec/init_proxy_spec.sh create mode 100644 addons/pulsar/scripts-ut-spec/start_bookies_spec.sh create mode 100644 addons/pulsar/scripts-ut-spec/start_broker_spec.sh create mode 100644 addons/pulsar/scripts-ut-spec/utils.sh create mode 100755 addons/pulsar/scripts/bookies-member-leave.sh delete mode 100755 addons/pulsar/scripts/prestop-bookies.sh rename addons/pulsar/templates/{cmpd-bkrecovery.yaml => cmpd-bookies-recovery-2.yaml} (74%) create mode 100644 addons/pulsar/templates/cmpd-bookies-recovery-3.yaml rename addons/pulsar/templates/{cmpd-bookkeeper.yaml => cmpd-bookkeeper-2.yaml} (62%) create mode 100644 addons/pulsar/templates/cmpd-bookkeeper-3.yaml rename addons/pulsar/templates/{cmpd-broker.yaml => cmpd-broker-2.yaml} (61%) create mode 100644 addons/pulsar/templates/cmpd-broker-3.yaml rename addons/pulsar/templates/{cmpd-proxy.yaml => cmpd-proxy-2.yaml} (76%) create mode 100644 addons/pulsar/templates/cmpd-proxy-3.yaml rename addons/pulsar/templates/{cmpd-zookeeper.yaml => cmpd-zookeeper-2.yaml} (75%) create mode 100644 addons/pulsar/templates/cmpd-zookeeper-3.yaml rename addons/pulsar/templates/config/{bookies-configmap.yaml => bookies-env-configmap.yaml} (76%) rename addons/pulsar/templates/config/{bookies-recovery-configmap.yaml => bookies-recovery-env-configmap.yaml} (75%) rename addons/pulsar/templates/config/{broker-configmap.yaml => broker-env-configmap.yaml} (76%) rename addons/pulsar/templates/config/{proxy-configmap.yaml => proxy-env-configmap.yaml} (77%) rename addons/pulsar/templates/config/{zookeeper-configmap.yaml => zookeeper-env-configmap.yaml} (76%) diff --git a/README.md b/README.md index 5048691c0..cda755dab 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ KubeBlocks add-ons. | orioledb | orioledb-14.7.2-beta1 | OrioleDB is a new storage engine for PostgreSQL, bringing a modern approach to database capacity, capabilities and performance to the world's most-loved database platform. | 1aal | | polardbx | polardbx-v2.3 | PolarDB-X is a cloud native distributed SQL Database designed for high concurrency, massive storage, complex querying scenarios. | Vettal Wu | | postgresql | postgresql-12.14.0
postgresql-12.14.1
postgresql-12.15.0
postgresql-14.7.2
postgresql-14.8.0
postgresql-15.7.0
postgresql-16.4.0 | A PostgreSQL (with Patroni HA) cluster definition Helm chart for Kubernetes | ldming | -| pulsar | pulsar-bkrecovery-2.11.2
pulsar-bkrecovery-3.0.2
pulsar-bookkeeper-2.11.2
pulsar-bookkeeper-3.0.2
pulsar-broker-2.11.2
pulsar-broker-3.0.2
pulsar-proxy-2.11.2
pulsar-proxy-3.0.2
pulsar-zookeeper-2.11.2
pulsar-zookeeper-3.0.2 | Apache Pulsar is an open-source, distributed messaging and streaming platform built for the cloud. | caiq1nyu | +| pulsar | pulsar-bookies-recovery-2.11.2
pulsar-bookies-recovery-3.0.2
pulsar-bookkeeper-2.11.2
pulsar-bookkeeper-3.0.2
pulsar-broker-2.11.2
pulsar-broker-3.0.2
pulsar-proxy-2.11.2
pulsar-proxy-3.0.2
pulsar-zookeeper-2.11.2
pulsar-zookeeper-3.0.2 | Apache Pulsar is an open-source, distributed messaging and streaming platform built for the cloud. | caiq1nyu | | qdrant | qdrant-1.10.0
qdrant-1.5.0
qdrant-1.7.3
qdrant-1.8.1
qdrant-1.8.4 | High-performance, massive-scale Vector Database for the next generation of AI. | iziang | | rabbitmq | rabbitmq-3.10.25
rabbitmq-3.11.28
rabbitmq-3.12.14
rabbitmq-3.13.2
rabbitmq-3.8.14
rabbitmq-3.9.29 | RabbitMQ is a reliable and mature messaging and streaming broker. | xuriwuyun | | redis | redis-7.0.6
redis-7.2.4
redis-cluster-7.0.6
redis-cluster-7.2.4
redis-sentinel-7.0.6
redis-sentinel-7.2.4
redis-twemproxy-0.5.0 | Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps. | Y-Rookie | diff --git a/addons-cluster/pulsar/templates/cluster.yaml b/addons-cluster/pulsar/templates/cluster.yaml index a743194c5..a45900c77 100644 --- a/addons-cluster/pulsar/templates/cluster.yaml +++ b/addons-cluster/pulsar/templates/cluster.yaml @@ -99,7 +99,7 @@ spec: {{- if or (eq .Values.mode "pulsar-enhanced-cluster") ( and (not $topologyEnable) .Values.bookiesRecovery.enabled) }} - name: bookies-recovery {{- if not $topologyEnable }} - componentDef: pulsar-bkrecovery + componentDef: pulsar-bookies-recovery {{- end }} {{ include "pulsar-zookeeper-ref" . | nindent 6 }} replicas: {{ .Values.bookiesRecovery.replicaCount | default 3 }} diff --git a/addons/pulsar/Chart.yaml b/addons/pulsar/Chart.yaml index e885fc031..7c919426e 100644 --- a/addons/pulsar/Chart.yaml +++ b/addons/pulsar/Chart.yaml @@ -12,6 +12,13 @@ version: 1.0.0-alpha.0 # The current default value is the highest version of the Pulsar supported in KubeBlocks. appVersion: 3.0.2 +# Add a dependency to the kubeblocks definition library chart +dependencies: + - name: kblib + version: 0.1.0 + repository: file://../kblib + alias: extra + home: https://pulsar.apache.org/ icon: https://pulsar.apache.org/img/logo-black.svg keywords: @@ -30,6 +37,6 @@ maintainers: url: https://github.com/apecloud/kubeblocks/ annotations: - addon.kubeblocks.io/kubeblocks-version: ">=0.9.0" + addon.kubeblocks.io/kubeblocks-version: ">=1.0.0" addon.kubeblocks.io/model: "streaming" addon.kubeblocks.io/provider: "community" diff --git a/addons/pulsar/config/broker-config-constraint.cue b/addons/pulsar/config/broker-config-constraint.cue deleted file mode 100644 index 478dc939d..000000000 --- a/addons/pulsar/config/broker-config-constraint.cue +++ /dev/null @@ -1,1498 +0,0 @@ -// Copyright (C) 2022-2023 ApeCloud Co., Ltd -// -// This file is part of KubeBlocks project -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -// @deprecated -// This version comes from the pulsar master branch, because this configuration template was used in the old version of pulsar addon, -// but the master branch code keeps changing. This file is kept here for archiving reasons, but it is no longer used in the new version addon. - -// AUTO generate: ./bin/cue-tools https://raw.githubusercontent.com/apache/pulsar/master/pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java "ServiceConfiguration" "PulsarBrokersParameter" > broker-config-constraint.cue -#PulsarBrokersParameter: { - // The Zookeeper quorum connection string (as a comma-separated list). Deprecated in favour of metadataStoreUrl - // @deprecated - zookeeperServers: string - - // The metadata store URL. \n Examples: \n * zk:my-zk-1:2181,my-zk-2:2181,my-zk-3:2181\n * my-zk-1:2181,my-zk-2:2181,my-zk-3:2181 (will default to ZooKeeper when the schema is not specified)\n * zk:my-zk-1:2181,my-zk-2:2181,my-zk-3:2181/my-chroot-path (to add a ZK chroot path)\n - metadataStoreUrl: string - - // Global Zookeeper quorum connection string (as a comma-separated list). Deprecated in favor of using `configurationStoreServers` - // @deprecated - globalZookeeperServers: string - - // Configuration store connection string (as a comma-separated list). Deprecated in favor of `configurationMetadataStoreUrl` - // @deprecated - configurationStoreServers: string - - // The metadata store URL for the configuration data. If empty, we fall back to use metadataStoreUrl - configurationMetadataStoreUrl: string - - // The port for serving binary protobuf requests. If set, defines a server binding for bindAddress:brokerServicePort. The Default value is 6650. - brokerServicePort: int - - // The port for serving TLS-secured binary protobuf requests. If set, defines a server binding for bindAddress:brokerServicePortTls. - brokerServicePortTls: int - - // The port for serving http requests - webServicePort: int - - // The port for serving https requests - webServicePortTls: int - - // Specify the TLS provider for the web service: SunJSSE, Conscrypt and etc. - webServiceTlsProvider: string - - // Specify the tls protocols the proxy's web service will use to negotiate during TLS Handshake.\n\nExample:- [TLSv1.3, TLSv1.2] - webServiceTlsProtocols: string - - // Specify the tls cipher the proxy's web service will use to negotiate during TLS Handshake.\n\nExample:- [TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256] - webServiceTlsCiphers: string - - // Hostname or IP address the service binds on - bindAddress: string - - // Hostname or IP address the service advertises to the outside world. If not set, the value of `InetAddress.getLocalHost().getCanonicalHostName()` is used. - advertisedAddress: string - - // Used to specify multiple advertised listeners for the broker. The value must format as :pulsar://:,multiple listeners should separate with commas.Do not use this configuration with advertisedAddress and brokerServicePort.The Default value is absent means use advertisedAddress and brokerServicePort. - advertisedListeners: string - - // Used to specify the internal listener name for the broker.The listener name must contain in the advertisedListeners.The Default value is absent, the broker uses the first listener as the internal listener. - internalListenerName: string - - // Used to specify additional bind addresses for the broker. The value must format as :://:, multiple bind addresses should be separated with commas. Associates each bind address with an advertised listener and protocol handler. Note that the brokerServicePort, brokerServicePortTls, webServicePort, and webServicePortTls properties define additional bindings. - bindAddresses: string - - // Enable or disable the proxy protocol. If true, the real IP addresses of consumers and producers can be obtained when getting topic statistics data. - haProxyProtocolEnabled: bool - - // Number of threads to use for Netty Acceptor. Default is set to `1` - numAcceptorThreads: int - - // Number of threads to use for Netty IO. Default is set to `2 * Runtime.getRuntime().availableProcessors()` - numIOThreads: int - - // Number of threads to use for orderedExecutor. The ordered executor is used to operate with zookeeper, such as init zookeeper client, get namespace policies from zookeeper etc. It also used to split bundle. Default is 8 - numOrderedExecutorThreads: int - - // Number of threads to use for HTTP requests processing Default is set to `2 * Runtime.getRuntime().availableProcessors()` - numHttpServerThreads: int - - // Number of threads to use for pulsar broker service. The executor in thread pool will do basic broker operation like load/unload bundle, update managedLedgerConfig, update topic/subscription/replicator message dispatch rate, do leader election etc. Default is set to 20 - numExecutorThreadPoolSize: int - - // Number of thread pool size to use for pulsar zookeeper callback service.The cache executor thread pool is used for restarting global zookeeper session. Default is 10 - numCacheExecutorThreadPoolSize: int - - // Option to enable busy-wait settings. Default is false. WARNING: This option will enable spin-waiting on executors and IO threads in order to reduce latency during context switches. The spinning will consume 100% CPU even when the broker is not doing any work. It is recommended to reduce the number of IO threads and BK client threads to only have few CPU cores busy. - enableBusyWait: bool - - // Max concurrent web requests - maxConcurrentHttpRequests: int - - // Capacity for thread pool queue in the HTTP server Default is set to 8192. - httpServerThreadPoolQueueSize: int - - // Capacity for accept queue in the HTTP server Default is set to 8192. - httpServerAcceptQueueSize: int - - // Maximum number of inbound http connections. (0 to disable limiting) - maxHttpServerConnections: int - - // Whether to enable the delayed delivery for messages. - delayedDeliveryEnabled: bool - - // Class name of the factory that implements the delayed deliver tracker. If value is "org.apache.pulsar.broker.delayed.BucketDelayedDeliveryTrackerFactory", \ will create bucket based delayed message index tracker. - delayedDeliveryTrackerFactoryClassName: string - - // Control the tick time for when retrying on delayed delivery, affecting the accuracy of the delivery time compared to the scheduled time. Default is 1 second. Note that this time is used to configure the HashedWheelTimer's tick time. - delayedDeliveryTickTimeMillis: int - - // Whether the deliverAt time is strictly followed. When false (default), messages may be sent to consumers before the deliverAt time by as much as the tickTimeMillis. This can reduce the overhead on the broker of maintaining the delayed index for a potentially very short time period. When true, messages will not be sent to consumer until the deliverAt time has passed, and they may be as late as the deliverAt time plus the tickTimeMillis for the topic plus the delayedDeliveryTickTimeMillis. - isDelayedDeliveryDeliverAtTimeStrict: bool - - // The delayed message index bucket min index count. When the index count of the current bucket is more than \ this value and all message indexes of current ledger have already been added to the tracker \ we will seal the bucket. - delayedDeliveryMinIndexCountPerBucket: int - - // The delayed message index time step(in seconds) in per bucket snapshot segment, \ after reaching the max time step limitation, the snapshot segment will be cut off. - delayedDeliveryMaxTimeStepPerBucketSnapshotSegmentSeconds: int - - // The max number of delayed message index in per bucket snapshot segment, -1 means no limitation, \ after reaching the max number limitation, the snapshot segment will be cut off. - delayedDeliveryMaxIndexesPerBucketSnapshotSegment: int - - // The max number of delayed message index bucket, \ after reaching the max buckets limitation, the adjacent buckets will be merged.\ (disable with value -1) - delayedDeliveryMaxNumBuckets: int - - // Size of the lookahead window to use when detecting if all the messages in the topic have a fixed delay for InMemoryDelayedDeliveryTracker (the default DelayedDeliverTracker). Default is 50,000. Setting the lookahead window to 0 will disable the logic to handle fixed delays in messages in a different way. - delayedDeliveryFixedDelayDetectionLookahead: int - - // Whether to enable the acknowledge of batch local index - acknowledgmentAtBatchIndexLevelEnabled: bool - - // Enable the WebSocket API service in broker - webSocketServiceEnabled: bool - - // Flag indicates whether to run broker in standalone mode - isRunningStandalone: bool - - // Name of the cluster to which this broker belongs to - clusterName: string - - // The maximum number of tenants that each pulsar cluster can create.This configuration is not precise control, in a concurrent scenario, the threshold will be exceeded. - maxTenants: int - - // Enable cluster's failure-domain which can distribute brokers into logical region - failureDomainsEnabled: bool - - // Metadata store session timeout in milliseconds. - metadataStoreSessionTimeoutMillis: int - - // Metadata store operation timeout in seconds. - metadataStoreOperationTimeoutSeconds: int - - // Metadata store cache expiry time in seconds. - metadataStoreCacheExpirySeconds: int - - // Is metadata store read-only operations. - metadataStoreAllowReadOnlyOperations: bool - - // ZooKeeper session timeout in milliseconds. @deprecated - Use metadataStoreSessionTimeoutMillis instead. - // @deprecated - zooKeeperSessionTimeoutMillis: int - - // ZooKeeper operation timeout in seconds. @deprecated - Use metadataStoreOperationTimeoutSeconds instead. - // @deprecated - zooKeeperOperationTimeoutSeconds: int - - // ZooKeeper cache expiry time in seconds. @deprecated - Use metadataStoreCacheExpirySeconds instead. - // @deprecated - zooKeeperCacheExpirySeconds: int - - // Is zookeeper allow read-only operations. - // @deprecated - zooKeeperAllowReadOnlyOperations: bool - - // Time to wait for broker graceful shutdown. After this time elapses, the process will be killed - brokerShutdownTimeoutMs: int - - // Flag to skip broker shutdown when broker handles Out of memory error - skipBrokerShutdownOnOOM: bool - - // Amount of seconds to timeout when loading a topic. In situations with many geo-replicated clusters, this may need raised. - topicLoadTimeoutSeconds: int - - // Whether we should enable metadata operations batching - metadataStoreBatchingEnabled: bool - - // Maximum delay to impose on batching grouping - metadataStoreBatchingMaxDelayMillis: int - - // Maximum number of operations to include in a singular batch - metadataStoreBatchingMaxOperations: int - - // Maximum size of a batch - metadataStoreBatchingMaxSizeKb: int - - // Configuration file path for local metadata store. It's supported by RocksdbMetadataStore for now. - metadataStoreConfigPath: string - - // Event topic to sync metadata between separate pulsar clusters on different cloud platforms. - metadataSyncEventTopic: string - - // Event topic to sync configuration-metadata between separate pulsar clusters on different cloud platforms. - configurationMetadataSyncEventTopic: string - - // Factory class-name to create topic with custom workflow - topicFactoryClassName: string - - // Enable backlog quota check. Enforces actions on topic when the quota is reached - backlogQuotaCheckEnabled: bool - - // Whether to enable precise time based backlog quota check. Enabling precise time based backlog quota check will cause broker to read first entry in backlog of the slowest cursor on a ledger which will mostly result in reading entry from BookKeeper's disk which can have negative impact on overall performance. Disabling precise time based backlog quota check will just use the timestamp indicating when a ledger was closed, which is of coarser granularity. - preciseTimeBasedBacklogQuotaCheck: bool - - // How often to check for topics that have reached the quota. It only takes effects when `backlogQuotaCheckEnabled` is true - backlogQuotaCheckIntervalInSeconds: int - - // @deprecated - Use backlogQuotaDefaultLimitByte instead. - backlogQuotaDefaultLimitGB: float - - // Default per-topic backlog quota limit by size, less than 0 means no limitation. default is -1. Increase it if you want to allow larger msg backlog - backlogQuotaDefaultLimitBytes: int - - // Default per-topic backlog quota limit by time in second, less than 0 means no limitation. default is -1. Increase it if you want to allow larger msg backlog - backlogQuotaDefaultLimitSecond: int - - // Default backlog quota retention policy. Default is producer_request_hold\n\n'producer_request_hold' Policy which holds producer's send request until theresource becomes available (or holding times out)\n'producer_exception' Policy which throws javax.jms.ResourceAllocationException to the producer\n'consumer_backlog_eviction' Policy which evicts the oldest message from the slowest consumer's backlog - backlogQuotaDefaultRetentionPolicy: string - - // Default ttl for namespaces if ttl is not already configured at namespace policies. (disable default-ttl with value 0) - ttlDurationDefaultInSeconds: int - - // Enable the deletion of inactive topics.\nIf only enable this option, will not clean the metadata of partitioned topic. - brokerDeleteInactiveTopicsEnabled: bool - - // Metadata of inactive partitioned topic will not be automatically cleaned up by default.\nNote: If `allowAutoTopicCreation` and this option are enabled at the same time,\nit may appear that a partitioned topic has just been deleted but is automatically created as a non-partitioned topic. - brokerDeleteInactivePartitionedTopicMetadataEnabled: bool - - // How often to check for inactive topics - brokerDeleteInactiveTopicsFrequencySeconds: int - - // Set the inactive topic delete mode. Default is delete_when_no_subscriptions\n'delete_when_no_subscriptions' mode only delete the topic which has no subscriptions and no active producers\n'delete_when_subscriptions_caught_up' mode only delete the topic that all subscriptions has no backlogs(caught up) and no active producers/consumers - brokerDeleteInactiveTopicsMode: string - - // Max duration of topic inactivity in seconds, default is not present\nIf not present, 'brokerDeleteInactiveTopicsFrequencySeconds' will be used\nTopics that are inactive for longer than this value will be deleted - brokerDeleteInactiveTopicsMaxInactiveDurationSeconds: int - - // Allow forced deletion of tenants. Default is false. - forceDeleteTenantAllowed: bool - - // Allow forced deletion of namespaces. Default is false. - forceDeleteNamespaceAllowed: bool - - // Max pending publish requests per connection to avoid keeping large number of pending requests in memory. Default: 1000 - maxPendingPublishRequestsPerConnection: int - - // How frequently to proactively check and purge expired messages - messageExpiryCheckIntervalInMinutes: int - - // How long to delay rewinding cursor and dispatching messages when active consumer is changed - activeConsumerFailoverDelayTimeMillis: int - - // Maximum time to spend while scanning a subscription to calculate the accurate backlog - subscriptionBacklogScanMaxTimeMs: int - - // Maximum number of entries to process while scanning a subscription to calculate the accurate backlog - subscriptionBacklogScanMaxEntries: int - - // How long to delete inactive subscriptions from last consuming. When it is 0, inactive subscriptions are not deleted automatically - subscriptionExpirationTimeMinutes: int - - // Enable subscription message redelivery tracker to send redelivery count to consumer (default is enabled) - subscriptionRedeliveryTrackerEnabled: bool - - // How frequently to proactively check and purge expired subscription - subscriptionExpiryCheckIntervalInMinutes: int - - // Enable subscription types (default is all type enabled) - subscriptionTypesEnabled: string - - // Enable Key_Shared subscription (default is enabled).\n@deprecated - use subscriptionTypesEnabled instead. - subscriptionKeySharedEnable: bool - - // On KeyShared subscriptions, with default AUTO_SPLIT mode, use splitting ranges or consistent hashing to reassign keys to new consumers (default is consistent hashing) - subscriptionKeySharedUseConsistentHashing: bool - - // On KeyShared subscriptions, number of points in the consistent-hashing ring. The higher the number, the more equal the assignment of keys to consumers - subscriptionKeySharedConsistentHashingReplicaPoints: int - - // Set the default behavior for message deduplication in the broker.\n\nThis can be overridden per-namespace. If enabled, broker will reject messages that were already stored in the topic - brokerDeduplicationEnabled: bool - - // Maximum number of producer information that it's going to be persisted for deduplication purposes - brokerDeduplicationMaxNumberOfProducers: int - - // How often is the thread pool scheduled to check whether a snapshot needs to be taken.(disable with value 0) - brokerDeduplicationSnapshotFrequencyInSeconds: int - - // If this time interval is exceeded, a snapshot will be taken.It will run simultaneously with `brokerDeduplicationEntriesInterval` - brokerDeduplicationSnapshotIntervalSeconds: int - - // Number of entries after which a dedup info snapshot is taken.\n\nA bigger interval will lead to less snapshots being taken though it would increase the topic recovery time, when the entries published after the snapshot need to be replayed - brokerDeduplicationEntriesInterval: int - - // Time of inactivity after which the broker will discard the deduplication information relative to a disconnected producer. Default is 6 hours. - brokerDeduplicationProducerInactivityTimeoutMinutes: int - - // When a namespace is created without specifying the number of bundle, this value will be used as the default - defaultNumberOfNamespaceBundles: int - - // The maximum number of namespaces that each tenant can create.This configuration is not precise control, in a concurrent scenario, the threshold will be exceeded - maxNamespacesPerTenant: int - - // Max number of topics allowed to be created in the namespace. When the topics reach the max topics of the namespace, the broker should reject the new topic request(include topic auto-created by the producer or consumer) until the number of connected consumers decrease. Using a value of 0, is disabling maxTopicsPerNamespace-limit check. - maxTopicsPerNamespace: int - - // The maximum number of connections in the broker. If it exceeds, new connections are rejected. - brokerMaxConnections: int - - // The maximum number of connections per IP. If it exceeds, new connections are rejected. - brokerMaxConnectionsPerIp: int - - // Allow schema to be auto updated at broker level. User can override this by 'is_allow_auto_update_schema' of namespace policy. This is enabled by default. - isAllowAutoUpdateSchemaEnabled: bool - - // Whether to enable the automatic shrink of pendingAcks map, the default is false, which means it is not enabled. When there are a large number of share or key share consumers in the cluster, it can be enabled to reduce the memory consumption caused by pendingAcks. - autoShrinkForConsumerPendingAcksMap: bool - - // Enable check for minimum allowed client library version - clientLibraryVersionCheckEnabled: bool - - // Path for the file used to determine the rotation status for the broker when responding to service discovery health checks - statusFilePath: string - - // Max number of unacknowledged messages allowed to receive messages by a consumer on a shared subscription.\n\n Broker will stop sending messages to consumer once, this limit reaches until consumer starts acknowledging messages back and unack count reaches to `maxUnackedMessagesPerConsumer/2`. Using a value of 0, it is disabling unackedMessage-limit check and consumer can receive messages without any restriction - maxUnackedMessagesPerConsumer: int - - // Max number of unacknowledged messages allowed per shared subscription. \n\n Broker will stop dispatching messages to all consumers of the subscription once this limit reaches until consumer starts acknowledging messages back and unack count reaches to `limit/2`. Using a value of 0, is disabling unackedMessage-limit check and dispatcher can dispatch messages without any restriction - maxUnackedMessagesPerSubscription: int - - // Max number of unacknowledged messages allowed per broker. \n\n Once this limit reaches, broker will stop dispatching messages to all shared subscription which has higher number of unack messages until subscriptions start acknowledging messages back and unack count reaches to `limit/2`. Using a value of 0, is disabling unackedMessage-limit check and broker doesn't block dispatchers - maxUnackedMessagesPerBroker: int - - // Once broker reaches maxUnackedMessagesPerBroker limit, it blocks subscriptions which has higher unacked messages than this percentage limit and subscription will not receive any new messages until that subscription acks back `limit/2` messages - maxUnackedMessagesPerSubscriptionOnBrokerBlocked: float - - // Maximum size of Consumer metadata - maxConsumerMetadataSize: int - - // Broker periodically checks if subscription is stuck and unblock if flag is enabled. (Default is disabled) - unblockStuckSubscriptionEnabled: bool - - // Tick time to schedule task that checks topic publish rate limiting across all topics Reducing to lower value can give more accuracy while throttling publish but it uses more CPU to perform frequent check. (Disable publish throttling with value 0) - topicPublisherThrottlingTickTimeMillis: int - - // Enable precise rate limit for topic publish - preciseTopicPublishRateLimiterEnable: bool - - // Tick time to schedule task that checks broker publish rate limiting across all topics Reducing to lower value can give more accuracy while throttling publish but it uses more CPU to perform frequent check. (Disable publish throttling with value 0) - brokerPublisherThrottlingTickTimeMillis: int - - // Max Rate(in 1 seconds) of Message allowed to publish for a broker when broker publish rate limiting enabled. (Disable message rate limit with value 0) - brokerPublisherThrottlingMaxMessageRate: int - - // Max Rate(in 1 seconds) of Byte allowed to publish for a broker when broker publish rate limiting enabled. (Disable byte rate limit with value 0) - brokerPublisherThrottlingMaxByteRate: int - - // Default messages per second dispatch throttling-limit for whole broker. Using a value of 0, is disabling default message-byte dispatch-throttling - dispatchThrottlingRateInMsg: int - - // Default bytes per second dispatch throttling-limit for whole broker. Using a value of 0, is disabling default message-byte dispatch-throttling - dispatchThrottlingRateInByte: int - - // Max Rate(in 1 seconds) of Message allowed to publish for a topic when topic publish rate limiting enabled. (Disable byte rate limit with value 0) - maxPublishRatePerTopicInMessages: int - - // Max Rate(in 1 seconds) of Byte allowed to publish for a topic when topic publish rate limiting enabled. (Disable byte rate limit with value 0) - maxPublishRatePerTopicInBytes: int - - // Too many subscribe requests from a consumer can cause broker rewinding consumer cursors and loading data from bookies, hence causing high network bandwidth usage When the positive value is set, broker will throttle the subscribe requests for one consumer. Otherwise, the throttling will be disabled. The default value of this setting is 0 - throttling is disabled. - subscribeThrottlingRatePerConsumer: int - - // Rate period for {subscribeThrottlingRatePerConsumer}. Default is 30s. - subscribeRatePeriodPerConsumerInSecond: int - - // Default number of message dispatching throttling-limit for every topic. \n\nUsing a value of 0, is disabling default message dispatch-throttling - dispatchThrottlingRatePerTopicInMsg: int - - // Default number of message-bytes dispatching throttling-limit for every topic. \n\nUsing a value of 0, is disabling default message-byte dispatch-throttling - dispatchThrottlingRatePerTopicInByte: int - - // Apply dispatch rate limiting on batch message instead individual messages with in batch message. (Default is disabled) - dispatchThrottlingOnBatchMessageEnabled: bool - - // Default number of message dispatching throttling-limit for a subscription. \n\nUsing a value of 0, is disabling default message dispatch-throttling. - dispatchThrottlingRatePerSubscriptionInMsg: int - - // Default number of message-bytes dispatching throttling-limit for a subscription. \n\nUsing a value of 0, is disabling default message-byte dispatch-throttling. - dispatchThrottlingRatePerSubscriptionInByte: int - - // Default number of message dispatching throttling-limit for every replicator in replication. \n\nUsing a value of 0, is disabling replication message dispatch-throttling - dispatchThrottlingRatePerReplicatorInMsg: int - - // Default number of message-bytes dispatching throttling-limit for every replicator in replication. \n\nUsing a value of 0, is disabling replication message-byte dispatch-throttling - dispatchThrottlingRatePerReplicatorInByte: int - - // Dispatch rate-limiting relative to publish rate. (Enabling flag will make broker to dynamically update dispatch-rate relatively to publish-rate: throttle-dispatch-rate = (publish-rate + configured dispatch-rate) - dispatchThrottlingRateRelativeToPublishRate: bool - - // Default dispatch-throttling is disabled for consumers which already caught-up with published messages and don't have backlog. This enables dispatch-throttling for non-backlog consumers as well. - dispatchThrottlingOnNonBacklogConsumerEnabled: bool - - // Default policy for publishing usage reports to system topic is disabled.This enables publishing of usage reports - resourceUsageTransportClassName: string - - // Default interval to publish usage reports if resourceUsagePublishToTopic is enabled. - resourceUsageTransportPublishIntervalInSecs: int - - // Enables evaluating subscription pattern on broker side. - enableBrokerSideSubscriptionPatternEvaluation: bool - - // Max length of subscription pattern - subscriptionPatternMaxLength: int - - // Max number of entries to read from bookkeeper. By default it is 100 entries. - dispatcherMaxReadBatchSize: int - - // Dispatch messages and execute broker side filters in a per-subscription thread - dispatcherDispatchMessagesInSubscriptionThread: bool - - // Whether the broker should count filtered entries in dispatch rate limit calculations. When disabled, only messages sent to a consumer count towards a dispatch rate limit at the broker, topic, and subscription level. When enabled, messages filtered out due to entry filter logic are counted towards each relevant rate limit. - dispatchThrottlingForFilteredEntriesEnabled: bool - - // Max size in bytes of entries to read from bookkeeper. By default it is 5MB. - dispatcherMaxReadSizeBytes: int - - // Min number of entries to read from bookkeeper. By default it is 1 entries.When there is an error occurred on reading entries from bookkeeper, the broker will backoff the batch size to this minimum number. - dispatcherMinReadBatchSize: int - - // The read failure backoff initial time in milliseconds. By default it is 15s. - dispatcherReadFailureBackoffInitialTimeInMs: int - - // The read failure backoff max time in milliseconds. By default it is 60s. - dispatcherReadFailureBackoffMaxTimeInMs: int - - // The read failure backoff mandatory stop time in milliseconds. By default it is 0s. - dispatcherReadFailureBackoffMandatoryStopTimeInMs: int - - // Time in milliseconds to delay the new delivery of a message when an EntryFilter returns RESCHEDULE. - dispatcherEntryFilterRescheduledMessageDelay: int - - // Max number of entries to dispatch for a shared subscription. By default it is 20 entries. - dispatcherMaxRoundRobinBatchSize: int - - // Precise dispatcher flow control according to history message number of each entry - preciseDispatcherFlowControl: bool - - // Class name of pluggable entry filter that decides whether the entry needs to be filtered.You can use this class to decide which entries can be sent to consumers.Multiple names need to be separated by commas. - entryFilterNames: string - - // The directory for all the entry filter implementations. - entryFiltersDirectory: string - - // Whether allow topic level entry filters policies overrides broker configuration. - allowOverrideEntryFilters: bool - - // Max number of concurrent lookup request broker allows to throttle heavy incoming lookup traffic - maxConcurrentLookupRequest: int - - // Max number of concurrent topic loading request broker allows to control number of zk-operations - maxConcurrentTopicLoadRequest: int - - // Max concurrent non-persistent message can be processed per connection - maxConcurrentNonPersistentMessagePerConnection: int - - // Number of worker threads to serve non-persistent topic.\n@deprecated - use topicOrderedExecutorThreadNum instead. - // @deprecated - numWorkerThreadsForNonPersistentTopic: int - - // Number of worker threads to serve topic ordered executor - topicOrderedExecutorThreadNum: int - - // Enable broker to load persistent topics - enablePersistentTopics: bool - - // Enable broker to load non-persistent topics - enableNonPersistentTopics: bool - - // Enable to run bookie along with broker - enableRunBookieTogether: bool - - // Enable to run bookie autorecovery along with broker - enableRunBookieAutoRecoveryTogether: bool - - // Max number of producers allowed to connect to topic. \n\nOnce this limit reaches, Broker will reject new producers until the number of connected producers decrease. Using a value of 0, is disabling maxProducersPerTopic-limit check. - maxProducersPerTopic: int - - // Max number of producers with the same IP address allowed to connect to topic. \n\nOnce this limit reaches, Broker will reject new producers until the number of connected producers with the same IP address decrease. Using a value of 0, is disabling maxSameAddressProducersPerTopic-limit check. - maxSameAddressProducersPerTopic: int - - // Enforce producer to publish encrypted messages.(default disable). - encryptionRequireOnProducer: bool - - // Max number of consumers allowed to connect to topic. \n\nOnce this limit reaches, Broker will reject new consumers until the number of connected consumers decrease. Using a value of 0, is disabling maxConsumersPerTopic-limit check. - maxConsumersPerTopic: int - - // Max number of consumers with the same IP address allowed to connect to topic. \n\nOnce this limit reaches, Broker will reject new consumers until the number of connected consumers with the same IP address decrease. Using a value of 0, is disabling maxSameAddressConsumersPerTopic-limit check. - maxSameAddressConsumersPerTopic: int - - // Max number of subscriptions allowed to subscribe to topic. \n\nOnce this limit reaches, broker will reject new subscription until the number of subscribed subscriptions decrease.\n Using a value of 0, is disabling maxSubscriptionsPerTopic limit check. - maxSubscriptionsPerTopic: int - - // Max number of consumers allowed to connect to subscription. \n\nOnce this limit reaches, Broker will reject new consumers until the number of connected consumers decrease. Using a value of 0, is disabling maxConsumersPerSubscription-limit check. - maxConsumersPerSubscription: int - - // Max size of messages. - maxMessageSize: int - - // Enable tracking of replicated subscriptions state across clusters. - enableReplicatedSubscriptions: bool - - // Frequency of snapshots for replicated subscriptions tracking. - replicatedSubscriptionsSnapshotFrequencyMillis: int - - // Timeout for building a consistent snapshot for tracking replicated subscriptions state. - replicatedSubscriptionsSnapshotTimeoutSeconds: int - - // Max number of snapshot to be cached per subscription. - replicatedSubscriptionsSnapshotMaxCachedPerSubscription: int - - // Max memory size for broker handling messages sending from producers.\n\n If the processing message size exceed this value, broker will stop read data from the connection. The processing messages means messages are sends to broker but broker have not send response to client, usually waiting to write to bookies.\n\n It's shared across all the topics running in the same broker.\n\n Use -1 to disable the memory limitation. Default is 1/2 of direct memory.\n\n - maxMessagePublishBufferSizeInMB: int - - // Interval between checks to see if message publish buffer size is exceed the max message publish buffer size - messagePublishBufferCheckIntervalInMillis: int - - // Whether to recover cursors lazily when trying to recover a managed ledger backing a persistent topic. It can improve write availability of topics.\nThe caveat is now when recovered ledger is ready to write we're not sure if all old consumers last mark delete position can be recovered or not. - lazyCursorRecovery: bool - - // Check between intervals to see if consumed ledgers need to be trimmed - retentionCheckIntervalInSeconds: int - - // The number of partitions per partitioned topic.\nIf try to create or update partitioned topics by exceeded number of partitions, then fail. - maxNumPartitionsPerPartitionedTopic: int - - // The directory to locate broker interceptors - brokerInterceptorsDirectory: string - - // List of broker interceptor to load, which is a list of broker interceptor names - brokerInterceptors: string - - // Enable or disable the broker interceptor, which is only used for testing for now - disableBrokerInterceptors: bool - - // List of interceptors for payload processing. - brokerEntryPayloadProcessors: string - - // There are two policies to apply when broker metadata session expires: session expired happens, \"shutdown\" or \"reconnect\". \n\n With \"shutdown\", the broker will be restarted.\n\n With \"reconnect\", the broker will keep serving the topics, while attempting to recreate a new session. - zookeeperSessionExpiredPolicy: string - - // If a topic remains fenced for this number of seconds, it will be closed forcefully.\n If it is set to 0 or a negative number, the fenced topic will not be closed. - topicFencingTimeoutSeconds: int - - // The directory to locate messaging protocol handlers - protocolHandlerDirectory: string - - // Use a separate ThreadPool for each Protocol Handler - useSeparateThreadPoolForProtocolHandlers: bool - - // List of messaging protocols to load, which is a list of protocol names - messagingProtocols: string - - // Enable or disable system topic. - systemTopicEnabled: bool - - // # Enable strict topic name check. Which includes two parts as follows:\n# 1. Mark `-partition-` as a keyword.\n# E.g.\n Create a non-partitioned topic.\n No corresponding partitioned topic\n - persistent://public/default/local-name (passed)\n - persistent://public/default/local-name-partition-z (rejected by keyword)\n - persistent://public/default/local-name-partition-0 (rejected by keyword)\n Has corresponding partitioned topic, partitions=2 and topic partition name is persistent://public/default/local-name\n - persistent://public/default/local-name-partition-0 (passed, Because it is the partition topic's sub-partition)\n - persistent://public/default/local-name-partition-z (rejected by keyword)\n - persistent://public/default/local-name-partition-4 (rejected, Because it exceeds the number of maximum partitions)\n Create a partitioned topic(topic metadata)\n - persistent://public/default/local-name (passed)\n - persistent://public/default/local-name-partition-z (rejected by keyword)\n - persistent://public/default/local-name-partition-0 (rejected by keyword)\n# 2. Allowed alphanumeric (a-zA-Z_0-9) and these special chars -=:. for topic name.\n# NOTE: This flag will be removed in some major releases in the future.\n - strictTopicNameEnabled: bool - - // The schema compatibility strategy to use for system topics - systemTopicSchemaCompatibilityStrategy: string - - // Enable or disable topic level policies, topic level policies depends on the system topic, please enable the system topic first. - topicLevelPoliciesEnabled: bool - - // List of interceptors for entry metadata. - brokerEntryMetadataInterceptors: string - - // Enable or disable exposing broker entry metadata to client. - exposingBrokerEntryMetadataToClientEnabled: bool - - // Enable namespaceIsolation policy update take effect ontime or not, if set to ture, then the related namespaces will be unloaded after reset policy to make it take effect. - enableNamespaceIsolationUpdateOnTime: bool - - // Enable or disable strict bookie affinity. - strictBookieAffinityEnabled: bool - - // Enable TLS - tlsEnabled: bool - - // Tls cert refresh duration in seconds (set 0 to check on every new connection) - tlsCertRefreshCheckDurationSec: int - - // Path for the TLS certificate file - tlsCertificateFilePath: string - - // Path for the TLS private key file - tlsKeyFilePath: string - - // Path for the trusted TLS certificate file - tlsTrustCertsFilePath: string - - // Accept untrusted TLS certificate from client - tlsAllowInsecureConnection: bool - - // Whether the hostname is validated when the broker creates a TLS connection with other brokers - tlsHostnameVerificationEnabled: bool - - // Specify the tls protocols the broker will use to negotiate during TLS Handshake.\n\nExample:- [TLSv1.3, TLSv1.2] - tlsProtocols: string - - // Specify the tls cipher the broker will use to negotiate during TLS Handshake.\n\nExample:- [TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256] - tlsCiphers: string - - // Specify whether Client certificates are required for TLS Reject.\nthe Connection if the Client Certificate is not trusted - tlsRequireTrustedClientCertOnConnect: bool - - // Enable authentication - authenticationEnabled: bool - - // Authentication provider name list, which is a list of class names - authenticationProviders: string - - // Interval of time for checking for expired authentication credentials - authenticationRefreshCheckSeconds: int - - // Enforce authorization - authorizationEnabled: bool - - // Authorization provider fully qualified class-name - authorizationProvider: string - - // Role names that are treated as `super-user`, meaning they will be able to do all admin operations and publish/consume from all topics - superUserRoles: string - - // Role names that are treated as `proxy roles`. \n\nIf the broker sees a request with role as proxyRoles - it will demand to see the original client role or certificate. - proxyRoles: string - - // If this flag is set then the broker authenticates the original Auth data else it just accepts the originalPrincipal and authorizes it (if required) - authenticateOriginalAuthData: bool - - // Allow wildcard matching in authorization\n\n(wildcard matching only applicable if wildcard-char: * presents at first or last position eg: *.pulsar.service, pulsar.service.*) - authorizationAllowWildcardsMatching: bool - - // When this parameter is not empty, unauthenticated users perform as anonymousUserRole - anonymousUserRole: string - - // If >0, it will reject all HTTP requests with bodies larged than the configured limit - httpMaxRequestSize: int - - // The maximum size in bytes of the request header. Larger headers will allow for more and/or larger cookies plus larger form content encoded in a URL. However, larger headers consume more memory and can make a server more vulnerable to denial of service attacks. - httpMaxRequestHeaderSize: int - - // If true, the broker will reject all HTTP requests using the TRACE and TRACK verbs.\n This setting may be necessary if the broker is deployed into an environment that uses http port\n scanning and flags web servers allowing the TRACE method as insecure. - disableHttpDebugMethods: bool - - // Enable the enforcement of limits on the incoming HTTP requests - httpRequestsLimitEnabled: bool - - // Max HTTP requests per seconds allowed. The excess of requests will be rejected with HTTP code 429 (Too many requests) - httpRequestsMaxPerSecond: float - - // Admin API fail on unknown request parameter in request-body. see PIP-179. Default false. - httpRequestsFailOnUnknownPropertiesEnabled: bool - - // This is a regexp, which limits the range of possible ids which can connect to the Broker using SASL.\n Default value is: \".*pulsar.*\", so only clients whose id contains 'pulsar' are allowed to connect. - saslJaasClientAllowedIds: string - - // Service Principal, for login context name. Default value is \"PulsarBroker\". - saslJaasServerSectionName: string - - // Path to file containing the secret to be used to SaslRoleTokenSigner\nThe secret can be specified like:\nsaslJaasServerRoleTokenSignerSecretPath=file:///my/saslRoleTokenSignerSecret.key. - saslJaasServerRoleTokenSignerSecretPath: string - - // kerberos kinit command. - kinitCommand: string - - // how often the broker expires the inflight SASL context. - inflightSaslContextExpiryMs: int - - // Maximum number of inflight sasl context. - maxInflightSaslContext: int - - // Metadata service uri that bookkeeper is used for loading corresponding metadata driver and resolving its metadata service location - bookkeeperMetadataServiceUri: string - - // Authentication plugin to use when connecting to bookies - bookkeeperClientAuthenticationPlugin: string - - // BookKeeper auth plugin implementation specifics parameters name and values - bookkeeperClientAuthenticationParametersName: string - - // Parameters for bookkeeper auth plugin - bookkeeperClientAuthenticationParameters: string - - // Timeout for BK add / read operations - bookkeeperClientTimeoutInSeconds: int - - // Speculative reads are initiated if a read request doesn't complete within a certain time Using a value of 0, is disabling the speculative reads - bookkeeperClientSpeculativeReadTimeoutInMillis: int - - // Number of channels per bookie - bookkeeperNumberOfChannelsPerBookie: int - - // Use older Bookkeeper wire protocol with bookie - bookkeeperUseV2WireProtocol: bool - - // Enable bookies health check. \n\n Bookies that have more than the configured number of failure within the interval will be quarantined for some time. During this period, new ledgers won't be created on these bookies - bookkeeperClientHealthCheckEnabled: bool - - // Bookies health check interval in seconds - bookkeeperClientHealthCheckIntervalSeconds: int - - // Bookies health check error threshold per check interval - bookkeeperClientHealthCheckErrorThresholdPerInterval: int - - // Bookie health check quarantined time in seconds - bookkeeperClientHealthCheckQuarantineTimeInSeconds: int - - // bookie quarantine ratio to avoid all clients quarantine the high pressure bookie servers at the same time - bookkeeperClientQuarantineRatio: float - - // Enable rack-aware bookie selection policy. \n\nBK will chose bookies from different racks when forming a new bookie ensemble - bookkeeperClientRackawarePolicyEnabled: bool - - // Enable region-aware bookie selection policy. \n\nBK will chose bookies from different regions and racks when forming a new bookie ensemble - bookkeeperClientRegionawarePolicyEnabled: bool - - // Minimum number of racks per write quorum. \n\nBK rack-aware bookie selection policy will try to get bookies from at least 'bookkeeperClientMinNumRacksPerWriteQuorum' racks for a write quorum. - bookkeeperClientMinNumRacksPerWriteQuorum: int - - // Enforces rack-aware bookie selection policy to pick bookies from 'bookkeeperClientMinNumRacksPerWriteQuorum' racks for a writeQuorum. \n\nIf BK can't find bookie then it would throw BKNotEnoughBookiesException instead of picking random one. - bookkeeperClientEnforceMinNumRacksPerWriteQuorum: bool - - // Enable/disable reordering read sequence on reading entries - bookkeeperClientReorderReadSequenceEnabled: bool - - // Enable bookie isolation by specifying a list of bookie groups to choose from. \n\nAny bookie outside the specified groups will not be used by the broker - bookkeeperClientIsolationGroups: string - - // Enable bookie secondary-isolation group if bookkeeperClientIsolationGroups doesn't have enough bookie available. - bookkeeperClientSecondaryIsolationGroups: string - - // Set the interval to periodically check bookie info - bookkeeperClientGetBookieInfoIntervalSeconds: int - - // Set the interval to retry a failed bookie info lookup - bookkeeperClientGetBookieInfoRetryIntervalSeconds: int - - // Enable/disable having read operations for a ledger to be sticky to a single bookie.\nIf this flag is enabled, the client will use one single bookie (by preference) to read all entries for a ledger. - bookkeeperEnableStickyReads: bool - - // Set the client security provider factory class name. Default: org.apache.bookkeeper.tls.TLSContextFactory - bookkeeperTLSProviderFactoryClass: string - - // Enable tls authentication with bookie - bookkeeperTLSClientAuthentication: bool - - // Supported type: PEM, JKS, PKCS12. Default value: PEM - bookkeeperTLSKeyFileType: string - - // Supported type: PEM, JKS, PKCS12. Default value: PEM - bookkeeperTLSTrustCertTypes: string - - // Path to file containing keystore password, if the client keystore is password protected. - bookkeeperTLSKeyStorePasswordPath: string - - // Path to file containing truststore password, if the client truststore is password protected. - bookkeeperTLSTrustStorePasswordPath: string - - // Path for the TLS private key file - bookkeeperTLSKeyFilePath: string - - // Path for the TLS certificate file - bookkeeperTLSCertificateFilePath: string - - // Path for the trusted TLS certificate file - bookkeeperTLSTrustCertsFilePath: string - - // Tls cert refresh duration at bookKeeper-client in seconds (0 to disable check) - bookkeeperTlsCertFilesRefreshDurationSeconds: int - - // Enable/disable disk weight based placement. Default is false - bookkeeperDiskWeightBasedPlacementEnabled: bool - - // Set the interval to check the need for sending an explicit LAC - bookkeeperExplicitLacIntervalInMills: int - - // whether expose managed ledger client stats to prometheus - bookkeeperClientExposeStatsToPrometheus: bool - - // whether limit per_channel_bookie_client metrics of bookkeeper client stats - bookkeeperClientLimitStatsLogging: bool - - // Throttle value for bookkeeper client - bookkeeperClientThrottleValue: int - - // Number of BookKeeper client worker threads. Default is Runtime.getRuntime().availableProcessors() - bookkeeperClientNumWorkerThreads: int - - // Number of BookKeeper client IO threads. Default is Runtime.getRuntime().availableProcessors() * 2 - bookkeeperClientNumIoThreads: int - - // Use separated IO threads for BookKeeper client. Default is false, which will use Pulsar IO threads - bookkeeperClientSeparatedIoThreadsEnabled: bool - - // Ensemble (E) size, Number of bookies to use for storing entries in a ledger.\nPlease notice that sticky reads enabled by bookkeeperEnableStickyReads=true aren’t used unless ensemble size (E) equals write quorum (Qw) size. - managedLedgerDefaultEnsembleSize: int - - // Write quorum (Qw) size, Replication factor for storing entries (messages) in a ledger. - managedLedgerDefaultWriteQuorum: int - - // Ack quorum (Qa) size, Number of guaranteed copies (acks to wait for before a write is considered completed) - managedLedgerDefaultAckQuorum: int - - // How frequently to flush the cursor positions that were accumulated due to rate limiting. (seconds). Default is 60 seconds - managedLedgerCursorPositionFlushSeconds: int - - // How frequently to refresh the stats. (seconds). Default is 60 seconds - managedLedgerStatsPeriodSeconds: int - - // Default type of checksum to use when writing to BookKeeper. \n\nDefault is `CRC32C`. Other possible options are `CRC32`, `MAC` or `DUMMY` (no checksum). - managedLedgerDigestType: string - - // Default password to use when writing to BookKeeper. \n\nDefault is ``. - managedLedgerPassword: string - - // Max number of bookies to use when creating a ledger - managedLedgerMaxEnsembleSize: int - - // Max number of copies to store for each message - managedLedgerMaxWriteQuorum: int - - // Max number of guaranteed copies (acks to wait before write is complete) - managedLedgerMaxAckQuorum: int - - // Amount of memory to use for caching data payload in managed ledger. \n\nThis memory is allocated from JVM direct memory and it's shared across all the topics running in the same broker. By default, uses 1/5th of available direct memory - managedLedgerCacheSizeMB: int - - // Whether we should make a copy of the entry payloads when inserting in cache - managedLedgerCacheCopyEntries: bool - - // Maximum buffer size for bytes read from storage. This is the memory retained by data read from storage (or cache) until it has been delivered to the Consumer Netty channel. Use O to disable - managedLedgerMaxReadsInFlightSizeInMB: int - - // Threshold to which bring down the cache level when eviction is triggered - managedLedgerCacheEvictionWatermark: float - - // Configure the cache eviction frequency for the managed ledger cache. - managedLedgerCacheEvictionFrequency: float - - // Configure the cache eviction interval in milliseconds for the managed ledger cache, default is 10ms - managedLedgerCacheEvictionIntervalMs: int - - // All entries that have stayed in cache for more than the configured time, will be evicted - managedLedgerCacheEvictionTimeThresholdMillis: int - - // Configure the threshold (in number of entries) from where a cursor should be considered 'backlogged' and thus should be set as inactive. - managedLedgerCursorBackloggedThreshold: int - - // Rate limit the amount of writes per second generated by consumer acking the messages - managedLedgerDefaultMarkDeleteRateLimit: float - - // Allow automated creation of topics if set to true (default value). - allowAutoTopicCreation: bool - - // The type of topic that is allowed to be automatically created.(partitioned/non-partitioned) - allowAutoTopicCreationType: string - - // Allow automated creation of subscriptions if set to true (default value). - allowAutoSubscriptionCreation: bool - - // The number of partitioned topics that is allowed to be automatically created if allowAutoTopicCreationType is partitioned. - defaultNumPartitions: int - - // The class of the managed ledger storage - managedLedgerStorageClassName: string - - // Number of threads to be used for managed ledger scheduled tasks - managedLedgerNumSchedulerThreads: int - - // Max number of entries to append to a ledger before triggering a rollover.\n\nA ledger rollover is triggered after the min rollover time has passed and one of the following conditions is true: the max rollover time has been reached, the max entries have been written to the ledger, or the max ledger size has been written to the ledger - managedLedgerMaxEntriesPerLedger: int - - // Minimum time between ledger rollover for a topic - managedLedgerMinLedgerRolloverTimeMinutes: int - - // Maximum time before forcing a ledger rollover for a topic - managedLedgerMaxLedgerRolloverTimeMinutes: int - - // Maximum ledger size before triggering a rollover for a topic (MB) - managedLedgerMaxSizePerLedgerMbytes: int - - // Delay between a ledger being successfully offloaded to long term storage, and the ledger being deleted from bookkeeper - managedLedgerOffloadDeletionLagMs: int - - // The number of bytes before triggering automatic offload to long term storage - managedLedgerOffloadAutoTriggerSizeThresholdBytes: int - - // The threshold to triggering automatic offload to long term storage - managedLedgerOffloadThresholdInSeconds: int - - // Max number of entries to append to a cursor ledger - managedLedgerCursorMaxEntriesPerLedger: int - - // Max time before triggering a rollover on a cursor ledger - managedLedgerCursorRolloverTimeInSeconds: int - - // Max number of `acknowledgment holes` that are going to be persistently stored.\n\nWhen acknowledging out of order, a consumer will leave holes that are supposed to be quickly filled by acking all the messages. The information of which messages are acknowledged is persisted by compressing in `ranges` of messages that were acknowledged. After the max number of ranges is reached, the information will only be tracked in memory and messages will be redelivered in case of crashes. - managedLedgerMaxUnackedRangesToPersist: int - - // If enabled, the maximum \"acknowledgment holes\" will not be limited and \"acknowledgment holes\" are stored in multiple entries. - persistentUnackedRangesWithMultipleEntriesEnabled: bool - - // Max number of `acknowledgment holes` that can be stored in Zookeeper.\n\nIf number of unack message range is higher than this limit then broker will persist unacked ranges into bookkeeper to avoid additional data overhead into zookeeper.\n@deprecated - use managedLedgerMaxUnackedRangesToPersistInMetadataStore. - // @deprecated - managedLedgerMaxUnackedRangesToPersistInZooKeeper: int - - // Max number of `acknowledgment holes` that can be stored in MetadataStore.\n\nIf number of unack message range is higher than this limit then broker will persist unacked ranges into bookkeeper to avoid additional data overhead into MetadataStore. - managedLedgerMaxUnackedRangesToPersistInMetadataStore: int - - // Use Open Range-Set to cache unacked messages (it is memory efficient but it can take more cpu) - managedLedgerUnackedRangesOpenCacheSetEnabled: bool - - // Skip reading non-recoverable/unreadable data-ledger under managed-ledger's list.\n\n It helps when data-ledgers gets corrupted at bookkeeper and managed-cursor is stuck at that ledger. - autoSkipNonRecoverableData: bool - - // operation timeout while updating managed-ledger metadata. - managedLedgerMetadataOperationsTimeoutSeconds: int - - // Read entries timeout when broker tries to read messages from bookkeeper (0 to disable it) - managedLedgerReadEntryTimeoutSeconds: int - - // Add entry timeout when broker tries to publish message to bookkeeper.(0 to disable it) - managedLedgerAddEntryTimeoutSeconds: int - - // Managed ledger prometheus stats latency rollover seconds - managedLedgerPrometheusStatsLatencyRolloverSeconds: int - - // Whether trace managed ledger task execution time - managedLedgerTraceTaskExecution: bool - - // New entries check delay for the cursor under the managed ledger. \nIf no new messages in the topic, the cursor will try to check again after the delay time. \nFor consumption latency sensitive scenario, can set to a smaller value or set to 0.\nOf course, this may degrade consumption throughput. Default is 10ms. - managedLedgerNewEntriesCheckDelayInMillis: int - - // Read priority when ledgers exists in both bookkeeper and the second layer storage. - managedLedgerDataReadPriority: string - - // ManagedLedgerInfo compression type, option values (NONE, LZ4, ZLIB, ZSTD, SNAPPY). \nIf value is invalid or NONE, then save the ManagedLedgerInfo bytes data directly. - managedLedgerInfoCompressionType: string - - // ManagedLedgerInfo compression size threshold (bytes), only compress metadata when origin size more then this value.\n0 means compression will always apply.\n - managedLedgerInfoCompressionThresholdInBytes: int - - // ManagedCursorInfo compression type, option values (NONE, LZ4, ZLIB, ZSTD, SNAPPY). \nIf value is NONE, then save the ManagedCursorInfo bytes data directly. - managedCursorInfoCompressionType: string - - // ManagedCursorInfo compression size threshold (bytes), only compress metadata when origin size more then this value.\n0 means compression will always apply.\n - managedCursorInfoCompressionThresholdInBytes: int - - // Minimum cursors that must be in backlog state to cache and reuse the read entries.(Default =0 to disable backlog reach cache) - managedLedgerMinimumBacklogCursorsForCaching: int - - // Minimum backlog entries for any cursor before start caching reads - managedLedgerMinimumBacklogEntriesForCaching: int - - // Maximum backlog entry difference to prevent caching entries that can't be reused - managedLedgerMaxBacklogBetweenCursorsForCaching: int - - // Enable load balancer - loadBalancerEnabled: bool - - // load placement strategy[weightedRandomSelection/leastLoadedServer] (only used by SimpleLoadManagerImpl) - // @deprecated - loadBalancerPlacementStrategy: string - - // load balance load shedding strategy (It requires broker restart if value is changed using dynamic config). Default is ThresholdShedder since 2.10.0 - loadBalancerLoadSheddingStrategy: string - - // When [current usage < average usage - threshold], the broker with the highest load will be triggered to unload - lowerBoundarySheddingEnabled: bool - - // load balance placement strategy - loadBalancerLoadPlacementStrategy: string - - // Percentage of change to trigger load report update - loadBalancerReportUpdateThresholdPercentage: int - - // maximum interval to update load report - loadBalancerReportUpdateMinIntervalMillis: int - - // Min delay of load report to collect, in milli-seconds - loadBalancerReportUpdateMaxIntervalMinutes: int - - // Frequency of report to collect, in minutes - loadBalancerHostUsageCheckIntervalMinutes: int - - // Enable/disable automatic bundle unloading for load-shedding - loadBalancerSheddingEnabled: bool - - // Load shedding interval. \n\nBroker periodically checks whether some traffic should be offload from some over-loaded broker to other under-loaded brokers - loadBalancerSheddingIntervalMinutes: int - - // enable/disable distribute bundles evenly - loadBalancerDistributeBundlesEvenlyEnabled: bool - - // Prevent the same topics to be shed and moved to other broker more than once within this timeframe - loadBalancerSheddingGracePeriodMinutes: int - - // Usage threshold to determine a broker as under-loaded (only used by SimpleLoadManagerImpl) - // @deprecated - loadBalancerBrokerUnderloadedThresholdPercentage: int - - // Usage threshold to allocate max number of topics to broker - loadBalancerBrokerMaxTopics: int - - // Usage threshold to determine a broker as over-loaded - loadBalancerBrokerOverloadedThresholdPercentage: int - - // Usage threshold to determine a broker whether to start threshold shedder - loadBalancerBrokerThresholdShedderPercentage: int - - // Average resource usage difference threshold to determine a broker whether to be a best candidate in LeastResourceUsageWithWeight.(eg: broker1 with 10% resource usage with weight and broker2 with 30% and broker3 with 80% will have 40% average resource usage. The placement strategy can select broker1 and broker2 as best candidates.) - loadBalancerAverageResourceUsageDifferenceThresholdPercentage: int - - // In FlowOrQpsEquallyDivideBundleSplitAlgorithm, if msgRate >= loadBalancerNamespaceBundleMaxMsgRate * (100 + flowOrQpsDifferenceThresholdPercentage)/100.0 or throughput >= loadBalancerNamespaceBundleMaxBandwidthMbytes * (100 + flowOrQpsDifferenceThresholdPercentage)/100.0, execute split bundle - flowOrQpsDifferenceThresholdPercentage: int - - // In the UniformLoadShedder strategy, the minimum message that triggers unload. - minUnloadMessage: int - - // In the UniformLoadShedder strategy, the minimum throughput that triggers unload. - minUnloadMessageThroughput: int - - // In the UniformLoadShedder strategy, the maximum unload ratio. - maxUnloadPercentage: float - - // Message-rate percentage threshold between highest and least loaded brokers for uniform load shedding. (eg: broker1 with 50K msgRate and broker2 with 30K msgRate will have 66% msgRate difference and load balancer can unload bundles from broker-1 to broker-2) - loadBalancerMsgRateDifferenceShedderThreshold: float - - // Message-throughput threshold between highest and least loaded brokers for uniform load shedding. (eg: broker1 with 450MB msgRate and broker2 with 100MB msgRate will have 4.5 times msgThroughout difference and load balancer can unload bundles from broker-1 to broker-2) - loadBalancerMsgThroughputMultiplierDifferenceShedderThreshold: float - - // For each uniform balanced unload, the maximum number of bundles that can be unloaded. The default value is -1, which means no limit - maxUnloadBundleNumPerShedding: int - - // Resource history Usage Percentage When adding new resource usage info - loadBalancerHistoryResourcePercentage: float - - // BandwithIn Resource Usage Weight - loadBalancerBandwithInResourceWeight: float - - // BandwithOut Resource Usage Weight - loadBalancerBandwithOutResourceWeight: float - - // CPU Resource Usage Weight - loadBalancerCPUResourceWeight: float - - // Memory Resource Usage Weight. Deprecated: Memory is no longer used as a load balancing item. - // @deprecated - loadBalancerMemoryResourceWeight: float - - // Direct Memory Resource Usage Weight - loadBalancerDirectMemoryResourceWeight: float - - // Bundle unload minimum throughput threshold (MB) - loadBalancerBundleUnloadMinThroughputThreshold: float - - // Interval to flush dynamic resource quota to ZooKeeper - loadBalancerResourceQuotaUpdateIntervalMinutes: int - - // Usage threshold to determine a broker is having just right level of load (only used by SimpleLoadManagerImpl) - // @deprecated - loadBalancerBrokerComfortLoadLevelPercentage: int - - // enable/disable automatic namespace bundle split - loadBalancerAutoBundleSplitEnabled: bool - - // enable/disable automatic unloading of split bundles - loadBalancerAutoUnloadSplitBundlesEnabled: bool - - // maximum topics in a bundle, otherwise bundle split will be triggered - loadBalancerNamespaceBundleMaxTopics: int - - // maximum sessions (producers + consumers) in a bundle, otherwise bundle split will be triggered(disable threshold check with value -1) - loadBalancerNamespaceBundleMaxSessions: int - - // maximum msgRate (in + out) in a bundle, otherwise bundle split will be triggered - loadBalancerNamespaceBundleMaxMsgRate: int - - // maximum bandwidth (in + out) in a bundle, otherwise bundle split will be triggered - loadBalancerNamespaceBundleMaxBandwidthMbytes: int - - // maximum number of bundles in a namespace - loadBalancerNamespaceMaximumBundles: int - - // Name of load manager to use - loadManagerClassName: string - - // Name of topic bundle assignment strategy to use - topicBundleAssignmentStrategy: string - - // Supported algorithms name for namespace bundle split - supportedNamespaceBundleSplitAlgorithms: string - - // Default algorithm name for namespace bundle split - defaultNamespaceBundleSplitAlgorithm: string - - // Option to override the auto-detected network interfaces max speed - loadBalancerOverrideBrokerNicSpeedGbps: float - - // Time to wait for the unloading of a namespace bundle - namespaceBundleUnloadingTimeoutMs: int - - // Option to enable the debug mode for the load balancer logics. The debug mode prints more logs to provide more information such as load balance states and decisions. (only used in load balancer extension logics) - loadBalancerDebugModeEnabled: bool - - // The target standard deviation of the resource usage across brokers (100% resource usage is 1.0 load). The shedder logic tries to distribute bundle load across brokers to meet this target std. The smaller value will incur load balancing more frequently. (only used in load balancer extension TransferSheddeer) - loadBalancerBrokerLoadTargetStd: float - - // Threshold to the consecutive count of fulfilled shedding(unload) conditions. If the unload scheduler consecutively finds bundles that meet unload conditions many times bigger than this threshold, the scheduler will shed the bundles. The bigger value will incur less bundle unloading/transfers. (only used in load balancer extension TransferSheddeer) - loadBalancerSheddingConditionHitCountThreshold: int - - // Option to enable the bundle transfer mode when distributing bundle loads. On: transfer bundles from overloaded brokers to underloaded -- pre-assigns the destination broker upon unloading). Off: unload bundles from overloaded brokers -- post-assigns the destination broker upon lookups). (only used in load balancer extension TransferSheddeer) - loadBalancerTransferEnabled: bool - - // Maximum number of brokers to unload bundle load for each unloading cycle. The bigger value will incur more unloading/transfers for each unloading cycle. (only used in load balancer extension TransferSheddeer) - loadBalancerMaxNumberOfBrokerSheddingPerCycle: int - - // Delay (in seconds) to the next unloading cycle after unloading. The logic tries to give enough time for brokers to recompute load after unloading. The bigger value will delay the next unloading cycle longer. (only used in load balancer extension TransferSheddeer) - loadBalanceSheddingDelayInSeconds: int - - // Broker load data time to live (TTL in seconds). The logic tries to avoid (possibly unavailable) brokers with out-dated load data, and those brokers will be ignored in the load computation. When tuning this value, please consider loadBalancerReportUpdateMaxIntervalMinutes. The current default is loadBalancerReportUpdateMaxIntervalMinutes * 2. (only used in load balancer extension TransferSheddeer) - loadBalancerBrokerLoadDataTTLInSeconds: int - - // Max number of bundles in bundle load report from each broker. The load balancer distributes bundles across brokers, based on topK bundle load data and other broker load data.The bigger value will increase the overhead of reporting many bundles in load data. (only used in load balancer extension logics) - loadBalancerMaxNumberOfBundlesInBundleLoadReport: int - - // Service units'(bundles) split interval. Broker periodically checks whether some service units(e.g. bundles) should split if they become hot-spots. (only used in load balancer extension logics) - loadBalancerSplitIntervalMinutes: int - - // Max number of bundles to split to per cycle. (only used in load balancer extension logics) - loadBalancerMaxNumberOfBundlesToSplitPerCycle: int - - // Threshold to the consecutive count of fulfilled split conditions. If the split scheduler consecutively finds bundles that meet split conditions many times bigger than this threshold, the scheduler will trigger splits on the bundles (if the number of bundles is less than loadBalancerNamespaceMaximumBundles). (only used in load balancer extension logics) - loadBalancerNamespaceBundleSplitConditionHitCountThreshold: int - - // After this delay, the service-unit state channel tombstones any service units (e.g., bundles) in semi-terminal states. For example, after splits, parent bundles will be `deleted`, and then after this delay, the parent bundles' state will be `tombstoned` in the service-unit state channel. Pulsar does not immediately remove such semi-terminal states to avoid unnecessary system confusion, as the bundles in the `tombstoned` state might temporarily look available to reassign. Rarely, one could lower this delay in order to aggressively clean the service-unit state channel when there are a large number of bundles. minimum value = 30 secs(only used in load balancer extension logics) - loadBalancerServiceUnitStateTombstoneDelayTimeInSeconds: int - - // Option to automatically unload namespace bundles with affinity(isolation) or anti-affinity group policies.Such bundles are not ideal targets to auto-unload as destination brokers are limited.(only used in load balancer extension logics) - loadBalancerSheddingBundlesWithPoliciesEnabled: bool - - // Enable replication metrics - replicationMetricsEnabled: bool - - // Max number of connections to open for each broker in a remote cluster.\n\nMore connections host-to-host lead to better throughput over high-latency links - replicationConnectionsPerBroker: int - - // replicator prefix used for replicator producer name and cursor name - replicatorPrefix: string - - // Replicator producer queue size. When dynamically modified, it only takes effect for the newly added replicators - replicationProducerQueueSize: int - - // Duration to check replication policy to avoid replicator inconsistency due to missing ZooKeeper watch (disable with value 0) - replicationPolicyCheckDurationSeconds: int - - // @deprecated - Use brokerClientTlsEnabled instead. - // @deprecated - replicationTlsEnabled: bool - - // Default message retention time. 0 means retention is disabled. -1 means data is not removed by time quota - defaultRetentionTimeInMinutes: int - - // Default retention size. 0 means retention is disabled. -1 means data is not removed by size quota - defaultRetentionSizeInMB: int - - // How often to check pulsar connection is still alive - keepAliveIntervalSeconds: int - - // Timeout for connection liveness check used to check liveness of possible consumer or producer duplicates. Helps prevent ProducerFencedException with exclusive producer, ConsumerAssignException with range conflict for Key Shared with sticky hash ranges or ConsumerBusyException in the case of an exclusive consumer. Set to 0 to disable connection liveness check. - connectionLivenessCheckTimeoutMillis: int - - // How often broker checks for inactive topics to be deleted (topics with no subscriptions and no one connected) Deprecated in favor of using `brokerDeleteInactiveTopicsFrequencySeconds`\n@deprecated - unused. - // @deprecated - brokerServicePurgeInactiveFrequencyInSeconds: int - - // A comma-separated list of namespaces to bootstrap - bootstrapNamespaces: string - - // If true, (and ModularLoadManagerImpl is being used), the load manager will attempt to use only brokers running the latest software version (to minimize impact to bundles) - preferLaterVersions: bool - - // Interval between checks to see if topics with compaction policies need to be compacted - brokerServiceCompactionMonitorIntervalInSeconds: int - - // The estimated backlog size is greater than this threshold, compression will be triggered.\nUsing a value of 0, is disabling compression check. - brokerServiceCompactionThresholdInBytes: int - - // Timeout for the compaction phase one loop, If the execution time of the compaction phase one loop exceeds this time, the compaction will not proceed. - brokerServiceCompactionPhaseOneLoopTimeInSeconds: int - - // Interval between checks to see if cluster is migrated and marks topic migrated if cluster is marked migrated. Disable with value 0. (Default disabled). - clusterMigrationCheckDurationSeconds: int - - // Enforce schema validation on following cases:\n\n - if a producer without a schema attempts to produce to a topic with schema, the producer will be\n failed to connect. PLEASE be carefully on using this, since non-java clients don't support schema.\n if you enable this setting, it will cause non-java clients failed to produce. - isSchemaValidationEnforced: bool - - // The schema storage implementation used by this broker - schemaRegistryStorageClassName: string - - // The list compatibility checkers to be used in schema registry - schemaRegistryCompatibilityCheckers: string - - // The schema compatibility strategy in broker level - schemaCompatibilityStrategy: string - - // Number of IO threads in Pulsar Client used in WebSocket proxy - webSocketNumIoThreads: int - - // Number of threads used by Websocket service - webSocketNumServiceThreads: int - - // Number of connections per Broker in Pulsar Client used in WebSocket proxy - webSocketConnectionsPerBroker: int - - // Time in milliseconds that idle WebSocket session times out - webSocketSessionIdleTimeoutMillis: int - - // Interval of time to sending the ping to keep alive in WebSocket proxy. This value greater than 0 means enabled - webSocketPingDurationSeconds: int - - // The maximum size of a text message during parsing in WebSocket proxy. - webSocketMaxTextFrameSize: int - - // Whether the '/metrics' endpoint requires authentication. Defaults to false.'authenticationEnabled' must also be set for this to take effect. - authenticateMetricsEndpoint: bool - - // If true, export topic level metrics otherwise namespace level - exposeTopicLevelMetricsInPrometheus: bool - - // If true, export buffered metrics - metricsBufferResponse: bool - - // If true, export consumer level metrics otherwise namespace level - exposeConsumerLevelMetricsInPrometheus: bool - - // If true, export producer level metrics otherwise namespace level - exposeProducerLevelMetricsInPrometheus: bool - - // If true, export managed ledger metrics (aggregated by namespace) - exposeManagedLedgerMetricsInPrometheus: bool - - // If true, export managed cursor metrics - exposeManagedCursorMetricsInPrometheus: bool - - // Classname of Pluggable JVM GC metrics logger that can log GC specific metrics - jvmGCMetricsLoggerClassName: string - - // Enable expose the precise backlog stats.\n Set false to use published counter and consumed counter to calculate,\n this would be more efficient but may be inaccurate. Default is false. - exposePreciseBacklogInPrometheus: bool - - // Time in milliseconds that metrics endpoint would time out. Default is 30s.\n Increase it if there are a lot of topics to expose topic-level metrics.\n Set it to 0 to disable timeout. - metricsServletTimeoutMs: int - - // Enable expose the backlog size for each subscription when generating stats.\n Locking is used for fetching the status so default to false. - exposeSubscriptionBacklogSizeInPrometheus: bool - - // Enable splitting topic and partition label in Prometheus.\n If enabled, a topic name will split into 2 parts, one is topic name without partition index,\n another one is partition index, e.g. (topic=xxx, partition=0).\n If the topic is a non-partitioned topic, -1 will be used for the partition index.\n If disabled, one label to represent the topic and partition, e.g. (topic=xxx-partition-0)\n Default is false. - splitTopicAndPartitionLabelInPrometheus: bool - - // Enable expose the broker bundles metrics. - exposeBundlesMetricsInPrometheus: bool - - // Flag indicates enabling or disabling function worker on brokers - functionsWorkerEnabled: bool - - // The nar package for the function worker service - functionsWorkerServiceNarPackage: string - - // Flag indicates enabling or disabling function worker using unified PackageManagement service. - functionsWorkerEnablePackageManagement: bool - - // If true, export publisher stats when returning topics stats from the admin rest api - exposePublisherStats: bool - - // Stats update frequency in seconds - statsUpdateFrequencyInSecs: int - - // Stats update initial delay in seconds - statsUpdateInitialDelayInSecs: int - - // If true, aggregate publisher stats of PartitionedTopicStats by producerName - aggregatePublisherStatsByProducerName: bool - - // The directory to locate offloaders - offloadersDirectory: string - - // Driver to use to offload old data to long term storage - managedLedgerOffloadDriver: string - - // Maximum number of thread pool threads for ledger offloading - managedLedgerOffloadMaxThreads: int - - // The directory where nar Extraction of offloaders happens - narExtractionDirectory: string - - // Maximum prefetch rounds for ledger reading for offloading - managedLedgerOffloadPrefetchRounds: int - - // Time to rollover ledger for inactive topic (duration without any publish on that topic). Disable rollover with value 0 (Default value 0) - managedLedgerInactiveLedgerRolloverTimeSeconds: int - - // Evicting cache data by the slowest markDeletedPosition or readPosition. The default is to evict through readPosition. - cacheEvictionByMarkDeletedPosition: bool - - // Enable transaction coordinator in broker - transactionCoordinatorEnabled: bool - - // Class name for transaction metadata store provider - transactionMetadataStoreProviderClassName: string - - // Class name for transaction buffer provider - transactionBufferProviderClassName: string - - // Class name for transaction pending ack store provider - transactionPendingAckStoreProviderClassName: string - - // Number of threads to use for pulsar transaction replay PendingAckStore or TransactionBuffer.Default is 5 - numTransactionReplayThreadPoolSize: int - - // Transaction buffer take snapshot transaction countIf transaction buffer enables snapshot segment, transaction buffer updates snapshot metadataafter the number of transaction operations reaches this value. - transactionBufferSnapshotMaxTransactionCount: int - - // The interval time for transaction buffer to take snapshots.If transaction buffer enables snapshot segment, it is the interval time for transaction buffer to update snapshot metadata. - transactionBufferSnapshotMinTimeInMillis: int - - // Transaction buffer stores the transaction ID of aborted transactions and takes snapshots.This configuration determines the size of the snapshot segment. The default value is 256 KB (262144 bytes). - transactionBufferSnapshotSegmentSize: int - - // Whether to enable segmented transaction buffer snapshot to handle a large number of aborted transactions. - transactionBufferSegmentedSnapshotEnabled: bool - - // The max concurrent requests for transaction buffer client. - transactionBufferClientMaxConcurrentRequests: int - - // The transaction buffer client's operation timeout in milliseconds. - transactionBufferClientOperationTimeoutInMills: int - - // The max active transactions per transaction coordinator, default value 0 indicates no limit. - maxActiveTransactionsPerCoordinator: int - - // MLPendingAckStore maintain a ConcurrentSkipListMap pendingAckLogIndex`,it store the position in pendingAckStore as value and save a position used to determinewhether the previous data can be cleaned up as a key.transactionPendingAckLogIndexMinLag is used to configure the minimum lag between indexes - transactionPendingAckLogIndexMinLag: int - - // Provide a mechanism allowing the Transaction Log Store to aggregate multiple records into a batched record and persist into a single BK entry. This will make Pulsar transactions work more efficiently, aka batched log. see: https://github.com/apache/pulsar/issues/15370. Default false - transactionLogBatchedWriteEnabled: bool - - // If enabled the feature that transaction log batch, this attribute means maximum log records count in a batch, default 512. - transactionLogBatchedWriteMaxRecords: int - - // If enabled the feature that transaction log batch, this attribute means bytes size in a batch, default 4m. - transactionLogBatchedWriteMaxSize: int - - // If enabled the feature that transaction log batch, this attribute means maximum wait time(in millis) for the first record in a batch, default 1 millisecond. - transactionLogBatchedWriteMaxDelayInMillis: int - - // Provide a mechanism allowing the transaction pending ack Log Store to aggregate multiple records into a batched record and persist into a single BK entry. This will make Pulsar transactions work more efficiently, aka batched log. see: https://github.com/apache/pulsar/issues/15370. Default false. - transactionPendingAckBatchedWriteEnabled: bool - - // If enabled the feature that transaction log batch, this attribute means maximum log records count in a batch, default 512. - transactionPendingAckBatchedWriteMaxRecords: int - - // If enabled the feature that transaction pending ack log batch, this attribute means bytes size in a batch, default 4m. - transactionPendingAckBatchedWriteMaxSize: int - - // If enabled the feature that transaction pending ack log batch, this attribute means maximum wait time(in millis) for the first record in a batch, default 1 millisecond. - transactionPendingAckBatchedWriteMaxDelayInMillis: int - - // The class name of the factory that implements the topic compaction service. - compactionServiceFactoryClassName: string - - // Enable TLS with KeyStore type configuration in broker - tlsEnabledWithKeyStore: bool - - // Specify the TLS provider for the broker service: \nWhen using TLS authentication with CACert, the valid value is either OPENSSL or JDK.\nWhen using TLS authentication with KeyStore, available values can be SunJSSE, Conscrypt and etc. - tlsProvider: string - - // TLS KeyStore type configuration in broker: JKS, PKCS12 - tlsKeyStoreType: string - - // TLS KeyStore path in broker - tlsKeyStore: string - - // TLS KeyStore password for broker - tlsKeyStorePassword: string - - // TLS TrustStore type configuration in broker: JKS, PKCS12 - tlsTrustStoreType: string - - // TLS TrustStore path in broker - tlsTrustStore: string - - // TLS TrustStore password for broker, null means empty password. - tlsTrustStorePassword: string - - // Authentication settings of the broker itself. \n\nUsed when the broker connects to other brokers, either in same or other clusters. Default uses plugin which disables authentication - brokerClientAuthenticationPlugin: string - - // Authentication parameters of the authentication plugin the broker is using to connect to other brokers - brokerClientAuthenticationParameters: string - - // Enable TLS when talking with other brokers in the same cluster (admin operation) or different clusters (replication) - brokerClientTlsEnabled: bool - - // Whether internal client use KeyStore type to authenticate with other Pulsar brokers - brokerClientTlsEnabledWithKeyStore: bool - - // The TLS Provider used by internal client to authenticate with other Pulsar brokers - brokerClientSslProvider: string - - // TLS trusted certificate file for internal client, used by the internal client to authenticate with Pulsar brokers - brokerClientTrustCertsFilePath: string - - // TLS private key file for internal client, used by the internal client to authenticate with Pulsar brokers - brokerClientKeyFilePath: string - - // TLS certificate file for internal client, used by the internal client to authenticate with Pulsar brokers - brokerClientCertificateFilePath: string - - // TLS TrustStore type configuration for internal client: JKS, PKCS12 used by the internal client to authenticate with Pulsar brokers - brokerClientTlsTrustStoreType: string - - // TLS TrustStore path for internal client, used by the internal client to authenticate with Pulsar brokers - brokerClientTlsTrustStore: string - - // TLS TrustStore password for internal client, used by the internal client to authenticate with Pulsar brokers - brokerClientTlsTrustStorePassword: string - - // TLS KeyStore type configuration for internal client: JKS, PKCS12, used by the internal client to authenticate with Pulsar brokers - brokerClientTlsKeyStoreType: string - - // TLS KeyStore path for internal client, used by the internal client to authenticate with Pulsar brokers - brokerClientTlsKeyStore: string - - // TLS KeyStore password for internal client, used by the internal client to authenticate with Pulsar brokers - brokerClientTlsKeyStorePassword: string - - // Specify the tls cipher the internal client will use to negotiate during TLS Handshake (a comma-separated list of ciphers).\n\nExamples:- [TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256].\n used by the internal client to authenticate with Pulsar brokers - brokerClientTlsCiphers: string - - // Specify the tls protocols the broker will use to negotiate during TLS handshake (a comma-separated list of protocol names).\n\nExamples:- [TLSv1.3, TLSv1.2] \n used by the internal client to authenticate with Pulsar brokers - brokerClientTlsProtocols: string - - // Enable the packages management service or not - enablePackagesManagement: bool - - // The packages management service storage service provider - packagesManagementStorageProvider: string - - // When the packages storage provider is bookkeeper, you can use this configuration to\ncontrol the number of replicas for storing the package - packagesReplicas: int - - // The bookkeeper ledger root path - packagesManagementLedgerRootPath: string - - // The directory to locate broker additional servlet - additionalServletDirectory: string - - // List of broker additional servlet to load, which is a list of broker additional servlet names - additionalServlets: string - - ... -} - -configuration: #PulsarBrokersParameter & { -} diff --git a/addons/pulsar/config/proxy-config-constraint.cue b/addons/pulsar/config/proxy-config-constraint.cue deleted file mode 100644 index 15904a1dc..000000000 --- a/addons/pulsar/config/proxy-config-constraint.cue +++ /dev/null @@ -1,362 +0,0 @@ -// Copyright (C) 2022-2023 ApeCloud Co., Ltd -// -// This file is part of KubeBlocks project -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#PulsarProxyParameter: { - // The ZooKeeper quorum connection string (as a comma-separated list) - // @deprecated - zookeeperServers: string - - // The metadata store URL. \n Examples: \n * zk:my-zk-1:2181,my-zk-2:2181,my-zk-3:2181\n * my-zk-1:2181,my-zk-2:2181,my-zk-3:2181 (will default to ZooKeeper when the schema is not specified)\n * zk:my-zk-1:2181,my-zk-2:2181,my-zk-3:2181/my-chroot-path (to add a ZK chroot path)\n - metadataStoreUrl: string - - // Configuration store connection string (as a comma-separated list). Deprecated in favor of `configurationMetadataStoreUrl` - // @deprecated - configurationStoreServers: string - - // Global ZooKeeper quorum connection string (as a comma-separated list) - // @deprecated - globalZookeeperServers: string - - // The metadata store URL for the configuration data. If empty, we fall back to use metadataStoreUrl - configurationMetadataStoreUrl: string - - // Metadata store session timeout in milliseconds. - metadataStoreSessionTimeoutMillis: int - - // Metadata store cache expiry time in seconds. - metadataStoreCacheExpirySeconds: int - - // Is metadata store read-only operations. - metadataStoreAllowReadOnlyOperations: bool - - // Max size of messages. - maxMessageSize: int - - // ZooKeeper session timeout in milliseconds. @deprecated - Use metadataStoreSessionTimeoutMillis instead. - // @deprecated - zookeeperSessionTimeoutMs: int - - // ZooKeeper cache expiry time in seconds. @deprecated - Use metadataStoreCacheExpirySeconds instead. - // @deprecated - zooKeeperCacheExpirySeconds: int - - // Is zooKeeper allow read-only operations. - // @deprecated - zooKeeperAllowReadOnlyOperations: bool - - // The service url points to the broker cluster. URL must have the pulsar:// prefix. - brokerServiceURL: string - - // The tls service url points to the broker cluster. URL must have the pulsar+ssl:// prefix. - brokerServiceURLTLS: string - - // The web service url points to the broker cluster - brokerWebServiceURL: string - - // The tls web service url points to the broker cluster - brokerWebServiceURLTLS: string - - // The web service url points to the function worker cluster. Only configure it when you setup function workers in a separate cluster - functionWorkerWebServiceURL: string - - // The tls web service url points to the function worker cluster. Only configure it when you setup function workers in a separate cluster - functionWorkerWebServiceURLTLS: string - - // When enabled, checks that the target broker is active before connecting. zookeeperServers and configurationStoreServers must be configured in proxy configuration for retrieving the active brokers. - checkActiveBrokers: bool - - // Broker proxy connect timeout.\nThe timeout value for Broker proxy connect timeout is in millisecond. Set to 0 to disable. - brokerProxyConnectTimeoutMs: int - - // Broker proxy read timeout.\nThe timeout value for Broker proxy read timeout is in millisecond. Set to 0 to disable. - brokerProxyReadTimeoutMs: int - - // Allowed broker target host names. Supports multiple comma separated entries and a wildcard. - brokerProxyAllowedHostNames: string - - // Allowed broker target ip addresses or ip networks / netmasks. Supports multiple comma separated entries. - brokerProxyAllowedIPAddresses: string - - // Allowed broker target ports - brokerProxyAllowedTargetPorts: string - - // Hostname or IP address the service binds on - bindAddress: string - - // Hostname or IP address the service advertises to the outside world. If not set, the value of `InetAddress.getLocalHost().getCanonicalHostName()` is used. - advertisedAddress: string - - // Enable or disable the proxy protocol. - haProxyProtocolEnabled: bool - - // Enables zero-copy transport of data across network interfaces using the spice. Zero copy mode cannot be used when TLS is enabled or when proxyLogLevel is > 0. - proxyZeroCopyModeEnabled: bool - - // The port for serving binary protobuf request - servicePort: int - - // The port for serving tls secured binary protobuf request - servicePortTls: int - - // The port for serving http requests - webServicePort: int - - // The port for serving https requests - webServicePortTls: int - - // Specify the TLS provider for the web service, available values can be SunJSSE, Conscrypt and etc. - webServiceTlsProvider: string - - // Specify the tls protocols the proxy's web service will use to negotiate during TLS Handshake.\n\nExample:- [TLSv1.3, TLSv1.2] - webServiceTlsProtocols: string - - // Specify the tls cipher the proxy's web service will use to negotiate during TLS Handshake.\n\nExample:- [TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256] - webServiceTlsCiphers: string - - // The directory where nar Extraction happens - narExtractionDirectory: string - - // Proxy log level, default is 0. 0: Do not log any tcp channel info 1: Parse and log any tcp channel info and command info without message body 2: Parse and log channel info, command info and message body - proxyLogLevel: int - - // Path for the file used to determine the rotation status for the proxy instance when responding to service discovery health checks - statusFilePath: string - - // A list of role names (a comma-separated list of strings) that are treated as `super-user`, meaning they will be able to do all admin operations and publish & consume from all topics - superUserRoles: string - - // Whether authentication is enabled for the Pulsar proxy - authenticationEnabled: bool - - // Authentication provider name list (a comma-separated list of class names - authenticationProviders: string - - // Whether authorization is enforced by the Pulsar proxy - authorizationEnabled: bool - - // Authorization provider as a fully qualified class name - authorizationProvider: string - - // Whether client authorization credentials are forwarded to the broker for re-authorization.Authentication must be enabled via configuring `authenticationEnabled` to be true for thisto take effect - forwardAuthorizationCredentials: bool - - // Interval of time for checking for expired authentication credentials. Disable by setting to 0. - authenticationRefreshCheckSeconds: int - - // Whether the '/metrics' endpoint requires authentication. Defaults to true.'authenticationEnabled' must also be set for this to take effect. - authenticateMetricsEndpoint: bool - - // This is a regexp, which limits the range of possible ids which can connect to the Broker using SASL.\n Default value is: \".*pulsar.*\", so only clients whose id contains 'pulsar' are allowed to connect. - saslJaasClientAllowedIds: string - - // Service Principal, for login context name. Default value is \"PulsarProxy\". - saslJaasServerSectionName: string - - // Path to file containing the secret to be used to SaslRoleTokenSigner\nThe secret can be specified like:\nsaslJaasServerRoleTokenSignerSecretPath=file:///my/saslRoleTokenSignerSecret.key. - saslJaasServerRoleTokenSignerSecretPath: string - - // kerberos kinit command. - kinitCommand: string - - // Max concurrent inbound connections. The proxy will reject requests beyond that - maxConcurrentInboundConnections: int - - // The maximum number of connections per IP. If it exceeds, new connections are rejected. - maxConcurrentInboundConnectionsPerIp: int - - // Max concurrent lookup requests. The proxy will reject requests beyond that - maxConcurrentLookupRequests: int - - // The authentication plugin used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientAuthenticationPlugin: string - - // The authentication parameters used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientAuthenticationParameters: string - - // The path to trusted certificates used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientTrustCertsFilePath: string - - // The path to TLS private key used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientKeyFilePath: string - - // The path to the TLS certificate used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientCertificateFilePath: string - - // Whether TLS is enabled when communicating with Pulsar brokers - tlsEnabledWithBroker: bool - - // When this parameter is not empty, unauthenticated users perform as anonymousUserRole - anonymousUserRole: string - - // Tls cert refresh duration in seconds (set 0 to check on every new connection) - tlsCertRefreshCheckDurationSec: int - - // Path for the TLS certificate file - tlsCertificateFilePath: string - - // Path for the TLS private key file - tlsKeyFilePath: string - - // Path for the trusted TLS certificate file.\n\nThis cert is used to verify that any certs presented by connecting clients are signed by a certificate authority. If this verification fails, then the certs are untrusted and the connections are dropped - tlsTrustCertsFilePath: string - - // Accept untrusted TLS certificate from client.\n\nIf true, a client with a cert which cannot be verified with the `tlsTrustCertsFilePath` cert will be allowed to connect to the server, though the cert will not be used for client authentication - tlsAllowInsecureConnection: bool - - // Whether the hostname is validated when the proxy creates a TLS connection with brokers - tlsHostnameVerificationEnabled: bool - - // Specify the tls protocols the broker will use to negotiate during TLS handshake (a comma-separated list of protocol names).\n\nExamples:- [TLSv1.3, TLSv1.2] - tlsProtocols: string - - // Specify the tls cipher the proxy will use to negotiate during TLS Handshake (a comma-separated list of ciphers).\n\nExamples:- [TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256] - tlsCiphers: string - - // Whether client certificates are required for TLS.\n\n Connections are rejected if the client certificate isn't trusted - tlsRequireTrustedClientCertOnConnect: bool - - // Enable TLS with KeyStore type configuration for proxy - tlsEnabledWithKeyStore: bool - - // Specify the TLS provider for the broker service: \nWhen using TLS authentication with CACert, the valid value is either OPENSSL or JDK.\nWhen using TLS authentication with KeyStore, available values can be SunJSSE, Conscrypt and etc. - tlsProvider: string - - // TLS KeyStore type configuration for proxy: JKS, PKCS12 - tlsKeyStoreType: string - - // TLS KeyStore path for proxy - tlsKeyStore: string - - // TLS KeyStore password for proxy - tlsKeyStorePassword: string - - // TLS TrustStore type configuration for proxy: JKS, PKCS12 - tlsTrustStoreType: string - - // TLS TrustStore path for proxy - tlsTrustStore: string - - // TLS TrustStore password for proxy, null means empty password. - tlsTrustStorePassword: string - - // Whether the Pulsar proxy use KeyStore type to authenticate with Pulsar brokers - brokerClientTlsEnabledWithKeyStore: bool - - // The TLS Provider used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientSslProvider: string - - // TLS KeyStore type configuration for proxy: JKS, PKCS12 used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientTlsKeyStoreType: string - - // TLS KeyStore path for internal client, used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientTlsKeyStore: string - - // TLS KeyStore password for proxy, used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientTlsKeyStorePassword: string - - // TLS TrustStore type configuration for proxy: JKS, PKCS12 used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientTlsTrustStoreType: string - - // TLS TrustStore path for proxy, used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientTlsTrustStore: string - - // TLS TrustStore password for proxy, used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientTlsTrustStorePassword: string - - // Specify the tls cipher the proxy will use to negotiate during TLS Handshake (a comma-separated list of ciphers).\n\nExamples:- [TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256].\n used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientTlsCiphers: string - - // Specify the tls protocols the broker will use to negotiate during TLS handshake (a comma-separated list of protocol names).\n\nExamples:- [TLSv1.3, TLSv1.2] \n used by the Pulsar proxy to authenticate with Pulsar brokers - brokerClientTlsProtocols: string - - // Http directs to redirect to non-pulsar services - httpReverseProxyConfigs: string - - // Http output buffer size.\n\nThe amount of data that will be buffered for http requests before it is flushed to the channel. A larger buffer size may result in higher http throughput though it may take longer for the client to see data. If using HTTP streaming via the reverse proxy, this should be set to the minimum value, 1, so that clients see the data as soon as possible. - httpOutputBufferSize: int - - // The maximum size in bytes of the request header. Larger headers will allow for more and/or larger cookies plus larger form content encoded in a URL. However, larger headers consume more memory and can make a server more vulnerable to denial of service attacks. - httpMaxRequestHeaderSize: int - - // Http input buffer max size.\n\nThe maximum amount of data that will be buffered for incoming http requests so that the request body can be replayed when the backend broker issues a redirect response. - httpInputMaxReplayBufferSize: int - - // Http proxy timeout.\n\nThe timeout value for HTTP proxy is in millisecond. - httpProxyTimeout: int - - // Number of threads to use for HTTP requests processing - httpNumThreads: int - - // Max concurrent web requests - maxConcurrentHttpRequests: int - - // Capacity for thread pool queue in the HTTP server Default is set to 8192. - httpServerThreadPoolQueueSize: int - - // Capacity for accept queue in the HTTP server Default is set to 8192. - httpServerAcceptQueueSize: int - - // Maximum number of inbound http connections. (0 to disable limiting) - maxHttpServerConnections: int - - // Number of threads used for Netty IO. Default is set to `2 * Runtime.getRuntime().availableProcessors()` - numIOThreads: int - - // Number of threads used for Netty Acceptor. Default is set to `1` - numAcceptorThreads: int - - // The directory to locate proxy additional servlet - proxyAdditionalServletDirectory: string - - // The directory to locate proxy additional servlet - additionalServletDirectory: string - - // List of proxy additional servlet to load, which is a list of proxy additional servlet names - proxyAdditionalServlets: string - - // List of proxy additional servlet to load, which is a list of proxy additional servlet names - additionalServlets: string - - // Enable the enforcement of limits on the incoming HTTP requests - httpRequestsLimitEnabled: bool - - // Max HTTP requests per seconds allowed. The excess of requests will be rejected with HTTP code 429 (Too many requests) - httpRequestsMaxPerSecond: float - - // The directory to locate proxy extensions - proxyExtensionsDirectory: string - - // List of messaging protocols to load, which is a list of extension names - proxyExtensions: string - - // Use a separate ThreadPool for each Proxy Extension - useSeparateThreadPoolForProxyExtensions: bool - - // Enable or disable the WebSocket servlet - webSocketServiceEnabled: bool - - // Interval of time to sending the ping to keep alive in WebSocket proxy. This value greater than 0 means enabled - webSocketPingDurationSeconds: int - - // Name of the cluster to which this broker belongs to - clusterName: string - - ... -} - -configuration: #PulsarProxyParameter & { -} diff --git a/addons/pulsar/config/zookeeper-server-config.tpl b/addons/pulsar/config/zookeeper-server-config.tpl deleted file mode 100644 index e77270f4c..000000000 --- a/addons/pulsar/config/zookeeper-server-config.tpl +++ /dev/null @@ -1,12 +0,0 @@ -{{- $clusterName := $.cluster.metadata.name }} -{{- $namespace := $.cluster.metadata.namespace }} -{{- $pulsar_zk_component := fromJson "{}" }} -{{- range $i, $e := $.cluster.spec.componentSpecs }} - {{- if eq $e.componentDefRef "zookeeper" }} - {{- $pulsar_zk_component = $e }} - {{- end }} -{{- end }} -{{- $replicas := $pulsar_zk_component.replicas | int }} -{{- range $i, $e := until $replicas }} - {{- printf "server.%d=%s-%s-%d.%s-%s-headless.%s.svc:2888:3888:participant;0.0.0.0:2181\n" (add1 $i) $clusterName $pulsar_zk_component.name $i $clusterName $pulsar_zk_component.name $namespace }} -{{- end }} \ No newline at end of file diff --git a/addons/pulsar/config/zookeeper-servers.tpl b/addons/pulsar/config/zookeeper-servers.tpl deleted file mode 100644 index 1a2afbb90..000000000 --- a/addons/pulsar/config/zookeeper-servers.tpl +++ /dev/null @@ -1,20 +0,0 @@ -{{- $clusterName := $.cluster.metadata.name }} -{{- $namespace := $.cluster.metadata.namespace }} -{{- $pulsar_zk_component := fromJson "{}" }} -{{- range $i, $e := $.cluster.spec.componentSpecs }} - {{- if eq $e.componentDefRef "zookeeper" }} - {{- $pulsar_zk_component = $e }} - {{- end }} -{{- end }} -{{- $zk_servers := "" }} -{{- $zk_server_i := "" }} -{{- $replicas := $pulsar_zk_component.replicas | int }} -{{- range $i, $e := until $replicas }} - {{- $zk_server_i = printf "%s-%s-%d\n" $clusterName $pulsar_zk_component.name $i }} - {{- if ne $zk_servers "" }} - {{- $zk_servers = printf "%s,%s" $zk_servers $zk_server_i }} - {{- else }} - {{- $zk_servers = printf "%s" $zk_server_i }} - {{- end }} -{{- end }} -{{- $zk_servers }} \ No newline at end of file diff --git a/addons/pulsar/scripts-ut-spec/bookies_member_leave_spec.sh b/addons/pulsar/scripts-ut-spec/bookies_member_leave_spec.sh new file mode 100644 index 000000000..da1841c84 --- /dev/null +++ b/addons/pulsar/scripts-ut-spec/bookies_member_leave_spec.sh @@ -0,0 +1,88 @@ +# shellcheck shell=bash +# shellcheck disable=SC2034 + +# validate_shell_type_and_version defined in shellspec/spec_helper.sh used to validate the expected shell type and version this script needs to run. +if ! validate_shell_type_and_version "bash" 4 &>/dev/null; then + echo "bookies_member_leave_spec.sh skip cases because dependency bash version 4 or higher is not installed." + exit 0 +fi + +Describe "Pulsar Bookies Member Leave Bash Script Tests" + # load the scripts to be tested and dependencies + Include ../scripts/bookies-member-leave.sh + + init() { + ut_mode="true" + } + BeforeAll "init" + + Describe "format_bookie()" + It "formats bookie with force and deleteCookie" + bin/bookkeeper() { + if [ "$1" = "shell" ] && [ "$2" = "bookieformat" ] && [ "$3" = "-nonInteractive" ] && [ "$4" = "-force" ] && [ "$5" = "-deleteCookie" ]; then + echo "Bookie formatted with force and deleteCookie" + return 0 + fi + return 1 + } + + When call format_bookie "true" "true" + The output should include "Formatting Bookie..." + The output should include "Bookie formatted with force and deleteCookie" + The status should be success + End + + It "formats bookie without force and deleteCookie" + bin/bookkeeper() { + if [ "$1" = "shell" ] && [ "$2" = "bookieformat" ] && [ "$3" = "-nonInteractive" ]; then + echo "Bookie formatted" + return 0 + fi + return 1 + } + + When call format_bookie "false" "false" + The output should include "Formatting Bookie..." + The output should include "Bookie formatted" + The status should be success + End + End + + Describe "should_format_bookie()" + It "returns true when pod index is greater than or equal to replicas" + When call should_format_bookie "pod-3" "2" + The status should be success + End + + It "returns false when pod index is less than replicas" + When call should_format_bookie "pod-1" "2" + The status should be failure + End + End + + Describe "bookies_member_leave()" + setup() { + export CURRENT_POD_NAME="pod-3" + export BOOKKEEPER_COMP_REPLICAS="2" + } + + It "formats bookie when condition is met" + setup + + format_bookie() { + echo "format_bookie called with $1 $2" + } + + When call bookies_member_leave + The output should include "format_bookie called with true true" + End + + It "skips formatting when condition is not met" + export CURRENT_POD_NAME="pod-1" + export BOOKKEEPER_COMP_REPLICAS="2" + + When call bookies_member_leave + The output should include "Skipping Bookie formatting" + End + End +End \ No newline at end of file diff --git a/addons/pulsar/scripts-ut-spec/check_bookies_spec.sh b/addons/pulsar/scripts-ut-spec/check_bookies_spec.sh new file mode 100644 index 000000000..251121f7f --- /dev/null +++ b/addons/pulsar/scripts-ut-spec/check_bookies_spec.sh @@ -0,0 +1,64 @@ +# shellcheck shell=bash +# shellcheck disable=SC2034 + +# validate_shell_type_and_version defined in shellspec/spec_helper.sh used to validate the expected shell type and version this script needs to run. +if ! validate_shell_type_and_version "bash" 4 &>/dev/null; then + echo "check_bookies_spec.sh skip cases because dependency bash version 4 or higher is not installed." + exit 0 +fi + +Describe "Pulsar Check Bookies Bash Script Tests" + # load the scripts to be tested and dependencies + Include ../scripts/check-bookies.sh + + init() { + ut_mode="true" + } + BeforeAll "init" + + Describe "apply_config_from_env()" + It "applies configuration from environment variables" + # mock command to apply configuration from environment variables + bin/apply-config-from-env.py() { + return 0 + } + + When call apply_config_from_env + The output should include "Applying configuration from environment variables:" + The output should include " - Command: bin/apply-config-from-env.py conf/bookkeeper.conf" + The status should be success + End + End + + Describe "wait_for_bookkeeper()" + It "waits for bookkeeper to start" + # mock command to check if bookkeeper instance id is available + bin/bookkeeper() { + if [ "$1" = "shell" ] && [ "$2" = "whatisinstanceid" ]; then + return 0 + fi + return 1 + } + + When run wait_for_bookkeeper + The output should include "Waiting for bookkeeper to start..." + The output should include "Bookkeeper started successfully" + The status should be success + End + End + + Describe "set_tcp_keepalive()" + It "sets TCP keepalive parameters" + sysctl() { + return 0 + } + + When run set_tcp_keepalive + The output should include "Setting TCP keepalive parameters:" + The output should include " - net.ipv4.tcp_keepalive_time=1" + The output should include " - net.ipv4.tcp_keepalive_intvl=11" + The output should include " - net.ipv4.tcp_keepalive_probes=3" + The status should be success + End + End +End \ No newline at end of file diff --git a/addons/pulsar/scripts-ut-spec/init_bookies_spec.sh b/addons/pulsar/scripts-ut-spec/init_bookies_spec.sh new file mode 100644 index 000000000..430e3c539 --- /dev/null +++ b/addons/pulsar/scripts-ut-spec/init_bookies_spec.sh @@ -0,0 +1,125 @@ +# shellcheck shell=bash +# shellcheck disable=SC2034 + +# validate_shell_type_and_version defined in shellspec/spec_helper.sh used to validate the expected shell type and version this script needs to run. +if ! validate_shell_type_and_version "bash" 4 &>/dev/null; then + echo "init_bookies_spec.sh skip cases because dependency bash version 4 or higher is not installed." + exit 0 +fi + +Describe "Pulsar Init Bookies Bash Script Tests" + # load the scripts to be tested and dependencies + Include ../scripts/init-bookies.sh + + init() { + ut_mode="true" + } + BeforeAll "init" + + Describe "wait_for_zookeeper()" + It "waits for Zookeeper to be ready" + nc() { + if [ "$1" = "-q" ] && [ "$2" = "1" ] && [ "$3" = "zookeeper.example.com" ] && [ "$4" = "2181" ]; then + echo "imok" + fi + } + + When call wait_for_zookeeper "zookeeper.example.com:2181" + The output should include "Waiting for Zookeeper at zookeeper.example.com:2181 to be ready..." + The output should include "Zookeeper is ready" + End + End + + Describe "merge_bookkeeper_config()" + It "merges Pulsar configuration files" + python3() { + echo "$1 $2 $3" + } + + When run merge_bookkeeper_config + The output should include "/kb-scripts/merge_pulsar_config.py" + The output should include "Merging Pulsar configuration files:" + The output should include " - Source: conf/bookkeeper.conf" + The output should include " - Destination: /opt/pulsar/conf/bookkeeper.conf" + The status should be success + End + End + + Describe "apply_config_from_env()" + It "applies configuration from environment variables" + bin/apply-config-from-env.py() { + return 0 + } + + When run apply_config_from_env + The output should include "Applying configuration from environment variables to conf/bookkeeper.conf" + The status should be success + End + End + + Describe "init_bookkeeper_cluster()" + It "initializes new BookKeeper cluster if not already initialized" + bin/bookkeeper() { + if [ "$1" = "shell" ] && [ "$2" = "whatisinstanceid" ]; then + return 1 + elif [ "$1" = "shell" ] && [ "$2" = "initnewcluster" ]; then + return 0 + fi + } + + When run init_bookkeeper_cluster + The output should include "Checking if BookKeeper cluster is already initialized..." + The output should include "Initializing new BookKeeper cluster" + The status should be success + End + + It "skips initialization if BookKeeper cluster is already initialized" + bin/bookkeeper() { + if [ "$1" = "shell" ] && [ "$2" = "whatisinstanceid" ]; then + return 0 + fi + } + + When run init_bookkeeper_cluster + The output should include "Checking if BookKeeper cluster is already initialized..." + The output should include "BookKeeper cluster is already initialized" + The status should be success + End + End + + Describe "init_bookies()" + It "initializes bookies" + export zkServers="zookeeper.example.com:2181" + + wait_for_zookeeper() { + echo "wait_for_zookeeper called" + } + + merge_bookkeeper_config() { + echo "merge_bookkeeper_config called" + } + + apply_config_from_env() { + echo "apply_config_from_env called" + } + + init_bookkeeper_cluster() { + echo "init_bookkeeper_cluster called" + } + + When run init_bookies + The output should include "wait_for_zookeeper called" + The output should include "merge_bookkeeper_config called" + The output should include "apply_config_from_env called" + The output should include "init_bookkeeper_cluster called" + End + + It "exits with status 1 when zkServers environment variable is not set" + unset zkServers + + When run init_bookies + The output should include "Error: zkServers environment variable is not set, Please set the zkServers environment variable and try again." + The status should be failure + End + End +End \ No newline at end of file diff --git a/addons/pulsar/scripts-ut-spec/init_broker_spec.sh b/addons/pulsar/scripts-ut-spec/init_broker_spec.sh new file mode 100644 index 000000000..4e01a7f55 --- /dev/null +++ b/addons/pulsar/scripts-ut-spec/init_broker_spec.sh @@ -0,0 +1,210 @@ +# shellcheck shell=bash +# shellcheck disable=SC2034 + +# validate_shell_type_and_version defined in shellspec/spec_helper.sh used to validate the expected shell type and version this script needs to run. +if ! validate_shell_type_and_version "bash" 4 &>/dev/null; then + echo "init_broker_spec.sh skip cases because dependency bash version 4 or higher is not installed." + exit 0 +fi + +Describe "Pulsar Init Broker Bash Script Tests" + # load the scripts to be tested and dependencies + Include ../scripts/init-broker.sh + + init() { + ut_mode="true" + } + BeforeAll "init" + + Describe "check_env_variables()" + It "checks if required environment variables are set" + export zookeeperServers="localhost:2181" + export POD_NAME="broker-0" + export clusterName="my-cluster" + export webServiceUrl="http://localhost:8080" + export brokerServiceUrl="pulsar://localhost:6650" + + When run check_env_variables + The status should be success + End + + It "exits with status 1 when a required environment variable is not set" + unset zookeeperServers + + When run check_env_variables + The output should include "Error: zookeeperServers environment variable is not set, Please set the zookeeperServers environment variable and try again." + The status should be failure + End + End + + Describe "wait_for_zookeeper()" + It "waits for Zookeeper to be ready" + python3() { + if [ "$1" = "/kb-scripts/zookeeper.py" ] && [ "$2" = "get" ] && [ "$3" = "/" ]; then + return 0 + fi + return 1 + } + + When call wait_for_zookeeper "localhost:2181" + The output should include "Waiting for Zookeeper at localhost:2181 to be ready..." + The output should include "Zookeeper is ready" + End + End + + Describe "check_cluster_initialized()" + It "returns 0 when cluster is already initialized" + python3() { + if [ "$1" = "/kb-scripts/zookeeper.py" ] && [ "$2" = "get" ] && [ "$3" = "/admin/clusters/my-cluster" ]; then + return 0 + fi + return 1 + } + + When call check_cluster_initialized "localhost:2181" "my-cluster" + The output should include "Cluster my-cluster is already initialized" + The status should be success + End + + It "returns 1 when cluster is not initialized" + python3() { + if [ "$1" = "/kb-scripts/zookeeper.py" ] && [ "$2" = "get" ] && [ "$3" = "/admin/clusters/my-cluster" ]; then + return 1 + fi + return 0 + } + + When call check_cluster_initialized "localhost:2181" "my-cluster" + The output should include "Cluster my-cluster is not initialized" + The status should be failure + End + End + + Describe "wait_for_cluster_metadata()" + It "waits for cluster metadata initialization" + python3() { + if [ "$1" = "/kb-scripts/zookeeper.py" ] && [ "$2" = "get" ] && [ "$3" = "/admin/clusters/my-cluster" ]; then + return 0 + fi + } + + When call wait_for_cluster_metadata "localhost:2181" "my-cluster" + The output should include "Waiting for cluster metadata initialization..." + The output should include "Cluster metadata initialized" + End + End + + Describe "initialize_cluster_metadata()" + It "initializes cluster metadata" + bin/pulsar() { + if [ "$1" = "initialize-cluster-metadata" ]; then + return 0 + fi + } + + When call initialize_cluster_metadata "my-cluster" "localhost:2181" "http://localhost:8080" "pulsar://localhost:6650" + The output should include "Initializing cluster metadata for cluster: my-cluster" + End + End + + Describe "init_broker()" + It "initializes broker for the first pod" + export zookeeperServers="localhost:2181" + export POD_NAME="broker-0" + export clusterName="my-cluster" + export webServiceUrl="http://localhost:8080" + export brokerServiceUrl="pulsar://localhost:6650" + + check_env_variables() { + return 0 + } + + wait_for_zookeeper() { + return 0 + } + + check_cluster_initialized() { + return 1 + } + + initialize_cluster_metadata() { + return 0 + } + + quit_script() { + return 0 + } + + When run init_broker + The status should be success + End + + It "skips initialization for non-first pods" + export zookeeperServers="localhost:2181" + export POD_NAME="broker-1" + export clusterName="my-cluster" + export webServiceUrl="http://localhost:8080" + export brokerServiceUrl="pulsar://localhost:6650" + + check_env_variables() { + return 0 + } + + wait_for_zookeeper() { + return 0 + } + + wait_for_cluster_metadata() { + return 0 + } + + quit_script() { + return 0 + } + + python3() { + return 0 + } + + bin/pulsar() { + return 0 + } + + When run init_broker + The status should be success + The output should include "Cluster already initialized" + End + + It "skips initialization if cluster is already initialized" + export zookeeperServers="localhost:2181" + export POD_NAME="broker-0" + export clusterName="my-cluster" + export webServiceUrl="http://localhost:8080" + export brokerServiceUrl="pulsar://localhost:6650" + + check_env_variables() { + return 0 + } + + wait_for_zookeeper() { + return 0 + } + + check_cluster_initialized() { + return 0 + } + + bin/pulsar() { + return 0 + } + + quit_script() { + return 0 + } + + When run init_broker + The stdout should include "Initializing cluster metadata for cluster: my-cluster" + The status should be success + End + End +End \ No newline at end of file diff --git a/addons/pulsar/scripts-ut-spec/init_proxy_spec.sh b/addons/pulsar/scripts-ut-spec/init_proxy_spec.sh new file mode 100644 index 000000000..ee72de025 --- /dev/null +++ b/addons/pulsar/scripts-ut-spec/init_proxy_spec.sh @@ -0,0 +1,57 @@ +# shellcheck shell=bash +# shellcheck disable=SC2034 + +# validate_shell_type_and_version defined in shellspec/spec_helper.sh used to validate the expected shell type and version this script needs to run. +if ! validate_shell_type_and_version "bash" 4 &>/dev/null; then + echo "init_proxy_spec.sh skip cases because dependency bash version 4 or higher is not installed." + exit 0 +fi + +Describe "Pulsar Init Proxy Bash Script Tests" + # load the scripts to be tested and dependencies + Include ../scripts/init-proxy.sh + + init() { + ut_mode="true" + } + BeforeAll "init" + + Describe "wait_for_zookeeper()" + It "waits for Zookeeper to be ready" + nc() { + if [ "$1" = "-q" ] && [ "$2" = "1" ] && [ "$3" = "zookeeper.example.com" ] && [ "$4" = "2181" ]; then + echo "imok" + fi + } + + When call wait_for_zookeeper "zookeeper.example.com:2181" + The output should include "Waiting for Zookeeper at zookeeper.example.com:2181 to be ready..." + The output should include "Zookeeper is ready" + End + End + + Describe "main()" + It "waits for Zookeeper when metadataStoreUrl is provided" + export metadataStoreUrl="zookeeper.example.com:2181" + + wait_for_zookeeper() { + echo "wait_for_zookeeper called with $1" + } + + When run main + The output should include "wait_for_zookeeper called with zookeeper.example.com:2181" + End + + It "skips Zookeeper readiness check when metadataStoreUrl is not provided" + unset metadataStoreUrl + + wait_for_zookeeper() { + echo "wait_for_zookeeper called" + } + + When run main + The output should not include "wait_for_zookeeper called" + The output should include "Zookeeper URL not provided, skipping Zookeeper readiness check" + End + End +End \ No newline at end of file diff --git a/addons/pulsar/scripts-ut-spec/start_bookies_spec.sh b/addons/pulsar/scripts-ut-spec/start_bookies_spec.sh new file mode 100644 index 000000000..bddbb831c --- /dev/null +++ b/addons/pulsar/scripts-ut-spec/start_bookies_spec.sh @@ -0,0 +1,120 @@ +# shellcheck shell=bash +# shellcheck disable=SC2034 + +# validate_shell_type_and_version defined in shellspec/spec_helper.sh used to validate the expected shell type and version this script needs to run. +if ! validate_shell_type_and_version "bash" 4 &>/dev/null; then + echo "start_bookies_spec.sh skip cases because dependency bash version 4 or higher is not installed." + exit 0 +fi + +source ./utils.sh + +# The unit test needs to rely on the common library functions defined in kblib. +# Therefore, we first dynamically generate the required common library files from the kblib library chart. +common_library_file="./common.sh" +generate_common_library $common_library_file + +Describe "Pulsar Start Bookies Bash Script Tests" + # load the scripts to be tested and dependencies + Include ../scripts/start-bookies.sh + Include $common_library_file + + init() { + ut_mode="true" + } + BeforeAll "init" + + cleanup() { + rm -f $common_library_file; + } + AfterAll 'cleanup' + + Describe "merge_configs()" + It "merges configuration files" + python3() { + echo "$1 $2 $3" + } + + bin/apply-config-from-env.py() { + return 0 + } + + When run merge_configs + The output should include "/kb-scripts/merge_pulsar_config.py" + The output should include "conf/bookkeeper.conf" + The output should include "/opt/pulsar/conf/bookkeeper.conf" + The status should be success + End + End + + Describe "get_directory()" + It "retrieves directory value from the configuration file" + grep() { + echo "zkLedgersRootPath=/ledgers" + } + + When call get_directory "journalDirectories" + The output should equal "/ledgers" + End + End + + Describe "create_directories()" + It "creates necessary directories" + mkdir() { + echo "Creating directories" + } + + When run create_directories "/var/pulsar/journal" "/var/pulsar/ledgers" + The output should include "Creating directories" + The status should be success + End + End + + Describe "check_empty_directories()" + It "checks if both directories are empty" + ls() { + return 1 # Simulates empty directory + } + + When call check_empty_directories "/var/pulsar/journal" "/var/pulsar/ledgers" + The status should be success + End + End + + Describe "handle_empty_directories()" + It "handles the case when both directories are empty" + get_target_pod_fqdn_from_pod_fqdn_vars() { + echo "pod.example.com" + } + + zkURL="zookeeper.example.com" + + When run handle_empty_directories + The stderr should include "Error: BOOKKEEPER_POD_FQDN_LIST or CURRENT_POD_NAME or zkServers is empty. Exiting." + The stdout should include "journalRes and ledgerRes directory is empty, check whether the remote cookies is empty either" + The status should be failure + End + + It "removes redundant bookieID if necessary" + BOOKKEEPER_POD_FQDN_LIST="pod1,pod2" + CURRENT_POD_NAME="pod1" + zkServers="pod1.svc.cluster.local" + + get_target_pod_fqdn_from_pod_fqdn_vars() { + echo "pod1.example.com" + } + + python3() { + return 0 # Simulates successful command + } + + grep() { + echo "zkLedgersRootPath=/ledgers" + } + + When run handle_empty_directories + The output should include "Warning: exist redundant bookieID" + The status should be success + End + End +End \ No newline at end of file diff --git a/addons/pulsar/scripts-ut-spec/start_broker_spec.sh b/addons/pulsar/scripts-ut-spec/start_broker_spec.sh new file mode 100644 index 000000000..0ccee7273 --- /dev/null +++ b/addons/pulsar/scripts-ut-spec/start_broker_spec.sh @@ -0,0 +1,90 @@ +# shellcheck shell=bash +# shellcheck disable=SC2034 + +# validate_shell_type_and_version defined in shellspec/spec_helper.sh used to validate the expected shell type and version this script needs to run. +if ! validate_shell_type_and_version "bash" 4 &>/dev/null; then + echo "start_broker_spec.sh skip cases because dependency bash version 4 or higher is not installed." + exit 0 +fi + +Describe "Pulsar Start Broker Bash Script Tests" + # load the scripts to be tested and dependencies + Include ../scripts/start-broker.sh + + init() { + ut_mode="true" + } + BeforeAll "init" + + Describe "extract_ordinal_from_object_name()" + It "extracts the ordinal from object name" + When call extract_ordinal_from_object_name "pod-1" + The output should equal "1" + End + End + + Describe "parse_advertised_svc_if_exist()" + It "parses advertised service if it exists" + POD_NAME="pod-1" + ADVERTISED_PORT_PULSAR="pod-svc-0:8080,pod-svc-1:8081" + + When run parse_advertised_svc_if_exist "$ADVERTISED_PORT_PULSAR" + The output should include "Found matching svcName and port for podName 'pod-1'" + The status should be success + End + + It "ignores if no advertised ports are provided" + When run parse_advertised_svc_if_exist "" + The output should include "Ignoring." + The status should be success + End + + It "exits with an error if no matching service is found" + POD_NAME="pod-1" + ADVERTISED_PORT_PULSAR="pod-svc-2:8080,pod-svc-3:8081" + + When run parse_advertised_svc_if_exist "$ADVERTISED_PORT_PULSAR" + The output should include "Error: No matching svcName and port found for podName 'pod-1'" + The status should be failure + End + End + + Describe "initialize_nodeport_config()" + It "initializes NodePort configuration" + POD_NAME="pod-1" + ADVERTISED_PORT_PULSAR="pod-svc-1:8080" + ADVERTISED_PORT_KAFKA="pod-svc-1:9092" + POD_HOST_IP="192.168.1.1" + + When run initialize_nodeport_config + The output should include "set PULSAR_PREFIX_advertisedListeners=cluster:pulsar://192.168.1.1:8080" + The output should include "set PULSAR_PREFIX_kafkaAdvertisedListeners=CLIENT://192.168.1.1:9092" + The status should be success + End + + It "handles missing service ports gracefully" + POD_NAME="pod-1" + ADVERTISED_PORT_PULSAR="pod-svc-2:8080" + ADVERTISED_PORT_KAFKA="pod-svc-3:9092" + + When run initialize_nodeport_config + The output should include "Error: No matching svcName and port found for podName 'pod-1'" + The status should be failure + End + End + + Describe "merge_configuration_files()" + It "merges configuration files successfully" + /kb-scripts/merge_pulsar_config.py() { + return 0 # Simulate successful merge + } + + bin/apply-config-from-env.py() { + return 0 # Simulate successful application + } + + When run merge_configuration_files + The status should be success + End + End +End \ No newline at end of file diff --git a/addons/pulsar/scripts-ut-spec/utils.sh b/addons/pulsar/scripts-ut-spec/utils.sh new file mode 100644 index 000000000..5b2506969 --- /dev/null +++ b/addons/pulsar/scripts-ut-spec/utils.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# utils functions for shellspec unit tests + +convert_tpl_to_bash() { + local input_file="$1" + local output_file="$2" + + sed -e '/^{{\/\*$/,/^\*\/}}$/d' \ + -e '/^{{-.*}}/d' \ + -e 's/{{- define ".*" }}//' \ + -e 's/{{- end }}//' \ + "$input_file" >> "$output_file" +} + +generate_common_library() { + local library_file="$1" + + libcommons_tpl_file="../../kblib/templates/_libcommons.tpl" + libpods_tpl_file="../../kblib/templates/_libpods.tpl" + libstrings_tpl_file="../../kblib/templates/_libstrings.tpl" + libenvs_tpl_file="../../kblib/templates/_libenvs.tpl" + libcompvars_tpl_file="../../kblib/templates/_libcompvars.tpl" + libututils_tpl_file="../../kblib/templates/_libututils.tpl" + + convert_tpl_to_bash $libcommons_tpl_file "$library_file" + convert_tpl_to_bash $libpods_tpl_file "$library_file" + convert_tpl_to_bash $libstrings_tpl_file "$library_file" + convert_tpl_to_bash $libenvs_tpl_file "$library_file" + convert_tpl_to_bash $libcompvars_tpl_file "$library_file" + convert_tpl_to_bash $libututils_tpl_file "$library_file" +} \ No newline at end of file diff --git a/addons/pulsar/scripts/bookies-member-leave.sh b/addons/pulsar/scripts/bookies-member-leave.sh new file mode 100755 index 000000000..45a0ce24a --- /dev/null +++ b/addons/pulsar/scripts/bookies-member-leave.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +format_bookie() { + local force=$1 + local delete_cookie=$2 + + echo "Formatting Bookie..." + if [[ $force == "true" && $delete_cookie == "true" ]]; then + bin/bookkeeper shell bookieformat -nonInteractive -force -deleteCookie || true + else + bin/bookkeeper shell bookieformat -nonInteractive || true + fi + echo "Bookie formatted" +} + +# TODO: this logic should be refactored rather than judging by pod name index +should_format_bookie() { + local current_pod_name=$1 + local current_component_replicas=$2 + + local idx=${current_pod_name##*-} + if [[ $idx -ge $current_component_replicas && $current_component_replicas -ne 0 ]]; then + return 0 + else + return 1 + fi +} + +bookies_member_leave() { + # shellcheck disable=SC2153 + local current_pod_name=${CURRENT_POD_NAME} + local current_component_replicas=${BOOKKEEPER_COMP_REPLICAS} + + if should_format_bookie "$current_pod_name" "$current_component_replicas"; then + format_bookie "true" "true" + else + echo "Skipping Bookie formatting" + fi +} + +# This is magic for shellspec ut framework. +# Sometime, functions are defined in a single shell script. +# You will want to test it. but you do not want to run the script. +# When included from shellspec, __SOURCED__ variable defined and script +# end here. The script path is assigned to the __SOURCED__ variable. +${__SOURCED__:+false} : || return 0 + +# main +bookies_member_leave \ No newline at end of file diff --git a/addons/pulsar/scripts/check-bookies.sh b/addons/pulsar/scripts/check-bookies.sh index 3f4c83187..24e388188 100755 --- a/addons/pulsar/scripts/check-bookies.sh +++ b/addons/pulsar/scripts/check-bookies.sh @@ -1,7 +1,51 @@ #!/bin/bash -set -x -bin/apply-config-from-env.py conf/bookkeeper.conf -until bin/bookkeeper shell whatisinstanceid; do - sleep 3; -done; -sysctl -w net.ipv4.tcp_keepalive_time=1 && sysctl -w net.ipv4.tcp_keepalive_intvl=11 && sysctl -w net.ipv4.tcp_keepalive_probes=3 \ No newline at end of file + +# shellcheck disable=SC2034 +ut_mode="false" +test || __() { + # when running in non-unit test mode, set the options "set -ex". + set -ex; +} + +apply_config_from_env() { + local cmd="bin/apply-config-from-env.py conf/bookkeeper.conf" + echo "Applying configuration from environment variables:" + echo " - Command: $cmd" + $cmd +} + +wait_for_bookkeeper() { + local cmd="bin/bookkeeper shell whatisinstanceid" + echo "Waiting for bookkeeper to start..." + until $cmd; do + sleep 3 + done + echo "Bookkeeper started successfully" +} + +set_tcp_keepalive() { + local keepalive_time=1 + local keepalive_intvl=11 + local keepalive_probes=3 + + echo "Setting TCP keepalive parameters:" + echo " - net.ipv4.tcp_keepalive_time=$keepalive_time" + echo " - net.ipv4.tcp_keepalive_intvl=$keepalive_intvl" + echo " - net.ipv4.tcp_keepalive_probes=$keepalive_probes" + + sysctl -w net.ipv4.tcp_keepalive_time=$keepalive_time + sysctl -w net.ipv4.tcp_keepalive_intvl=$keepalive_intvl + sysctl -w net.ipv4.tcp_keepalive_probes=$keepalive_probes +} + +# This is magic for shellspec ut framework. +# Sometime, functions are defined in a single shell script. +# You will want to test it. but you do not want to run the script. +# When included from shellspec, __SOURCED__ variable defined and script +# end here. The script path is assigned to the __SOURCED__ variable. +${__SOURCED__:+false} : || return 0 + +# main +apply_config_from_env +wait_for_bookkeeper +set_tcp_keepalive \ No newline at end of file diff --git a/addons/pulsar/scripts/init-bookies.sh b/addons/pulsar/scripts/init-bookies.sh index fa1a1321c..ee0d12ea8 100755 --- a/addons/pulsar/scripts/init-bookies.sh +++ b/addons/pulsar/scripts/init-bookies.sh @@ -1,15 +1,69 @@ #!/bin/bash -echo "waiting zookeeper:${zkServers} ready..." -zkDomain="${zkServers%%:*}" -until echo ruok | nc -q 1 ${zkDomain} 2181 | grep imok; do - sleep 1; -done; -echo "zk is ready, start to config bookkeeper..." -python3 /kb-scripts/merge_pulsar_config.py conf/bookkeeper.conf /opt/pulsar/conf/bookkeeper.conf; -bin/apply-config-from-env.py conf/bookkeeper.conf; -if bin/bookkeeper shell whatisinstanceid; then - echo "bookkeeper cluster already initialized"; -else - echo "bookkeeper init new cluster." - bin/bookkeeper shell initnewcluster; -fi \ No newline at end of file + +# shellcheck disable=SC2034 +ut_mode="false" +test || __() { + # when running in non-unit test mode, set the options "set -ex". + set -ex; +} + +wait_for_zookeeper() { + local zk_servers="$1" + local zk_domain="${zk_servers%%:*}" + local zk_port="2181" + + echo "Waiting for Zookeeper at ${zk_servers} to be ready..." + until echo ruok | nc -q 1 ${zk_domain} ${zk_port} | grep imok; do + sleep 1 + done + echo "Zookeeper is ready" +} + +merge_bookkeeper_config() { + local src_config="conf/bookkeeper.conf" + local dest_config="/opt/pulsar/conf/bookkeeper.conf" + + echo "Merging Pulsar configuration files:" + echo " - Source: $src_config" + echo " - Destination: $dest_config" + python3 /kb-scripts/merge_pulsar_config.py "$src_config" "$dest_config" +} + +apply_config_from_env() { + local config_file="conf/bookkeeper.conf" + + echo "Applying configuration from environment variables to $config_file" + bin/apply-config-from-env.py "$config_file" +} + +init_bookkeeper_cluster() { + echo "Checking if BookKeeper cluster is already initialized..." + if bin/bookkeeper shell whatisinstanceid; then + echo "BookKeeper cluster is already initialized" + else + echo "Initializing new BookKeeper cluster" + bin/bookkeeper shell initnewcluster + fi +} + +init_bookies() { + if [[ -z "$zkServers" ]]; then + echo "Error: zkServers environment variable is not set, Please set the zkServers environment variable and try again." + exit 1 + fi + + wait_for_zookeeper "$zkServers" + merge_bookkeeper_config + apply_config_from_env + init_bookkeeper_cluster +} + +# This is magic for shellspec ut framework. +# Sometime, functions are defined in a single shell script. +# You will want to test it. but you do not want to run the script. +# When included from shellspec, __SOURCED__ variable defined and script +# end here. The script path is assigned to the __SOURCED__ variable. +${__SOURCED__:+false} : || return 0 + +# main +init_bookies \ No newline at end of file diff --git a/addons/pulsar/scripts/init-broker-sysctl.sh b/addons/pulsar/scripts/init-broker-sysctl.sh index 448643aa3..8504e918a 100755 --- a/addons/pulsar/scripts/init-broker-sysctl.sh +++ b/addons/pulsar/scripts/init-broker-sysctl.sh @@ -1,2 +1,26 @@ -#!/bin/sh -sysctl -w net.ipv4.tcp_keepalive_time=1 && sysctl -w net.ipv4.tcp_keepalive_intvl=11 && sysctl -w net.ipv4.tcp_keepalive_probes=3 \ No newline at end of file +#!/bin/bash + +set_tcp_keepalive_params() { + local keepalive_time=${1:-1} + local keepalive_intvl=${2:-11} + local keepalive_probes=${3:-3} + + echo "Setting TCP keepalive parameters:" + echo " - net.ipv4.tcp_keepalive_time=$keepalive_time" + echo " - net.ipv4.tcp_keepalive_intvl=$keepalive_intvl" + echo " - net.ipv4.tcp_keepalive_probes=$keepalive_probes" + + sysctl -w net.ipv4.tcp_keepalive_time=$keepalive_time + sysctl -w net.ipv4.tcp_keepalive_intvl=$keepalive_intvl + sysctl -w net.ipv4.tcp_keepalive_probes=$keepalive_probes +} + +# This is magic for shellspec ut framework. +# Sometime, functions are defined in a single shell script. +# You will want to test it. but you do not want to run the script. +# When included from shellspec, __SOURCED__ variable defined and script +# end here. The script path is assigned to the __SOURCED__ variable. +${__SOURCED__:+false} : || return 0 + +# main +set_tcp_keepalive_params 1 11 3 \ No newline at end of file diff --git a/addons/pulsar/scripts/init-broker.sh b/addons/pulsar/scripts/init-broker.sh index f45ab69ec..cd6e624e8 100755 --- a/addons/pulsar/scripts/init-broker.sh +++ b/addons/pulsar/scripts/init-broker.sh @@ -1,29 +1,103 @@ -#!/bin/sh -set -x -echo "INFO: wait for zookeeper ready..." -zkDomain="${zookeeperServers%%:*}" -until zkURL=${zookeeperServers} python3 /kb-scripts/zookeeper.py get /; do - sleep 1; -done; -idx=${KB_POD_NAME##*-} -if [ $idx -ne 0 ]; then - # if not the first pod, do it - until zkURL=${zookeeperServers} python3 /kb-scripts/zookeeper.py get /admin/clusters/${clusterName}; do - echo "INFO: wait for init the meta cluster..." - sleep 1; +#!/bin/bash + +# shellcheck disable=SC2154 +# shellcheck disable=SC2034 +ut_mode="false" +test || __() { + # when running in non-unit test mode, set the options "set -ex". + set -ex; +} + +check_env_variables() { + local required_vars=("zookeeperServers" "POD_NAME" "clusterName" "webServiceUrl" "brokerServiceUrl") + for var in "${required_vars[@]}"; do + if [[ -z "${!var}" ]]; then + echo "Error: $var environment variable is not set, Please set the $var environment variable and try again." + exit 1 + fi + done +} + +wait_for_zookeeper() { + local zk_servers="$1" + local zk_domain="${zk_servers%%:*}" + + echo "Waiting for Zookeeper at ${zk_servers} to be ready..." + until zkURL=${zk_servers} python3 /kb-scripts/zookeeper.py get /; do + sleep 1 + done + echo "Zookeeper is ready" +} + +check_cluster_initialized() { + local zk_servers="$1" + local cluster_name="$2" + + if zkURL=${zk_servers} python3 /kb-scripts/zookeeper.py get /admin/clusters/${cluster_name}; then + echo "Cluster ${cluster_name} is already initialized" + return 0 + else + echo "Cluster ${cluster_name} is not initialized" + return 1 + fi +} + +wait_for_cluster_metadata() { + local zk_servers="$1" + local cluster_name="$2" + + echo "Waiting for cluster metadata initialization..." + until zkURL=${zk_servers} python3 /kb-scripts/zookeeper.py get /admin/clusters/${cluster_name}; do + echo "Waiting for cluster metadata initialization..." + sleep 1 done - echo "INFO: cluster already initialized" && exit 0 -fi -# if the pod is the first pod, do it -if zkURL=${zookeeperServers} python3 /kb-scripts/zookeeper.py get /admin/clusters/${clusterName}; then - echo "INFO: cluster already initialized" && exit 0 -fi -echo "INFO: init cluster metadata for cluster: ${clusterName}" -bin/pulsar initialize-cluster-metadata \ ---cluster ${clusterName} \ ---zookeeper ${zookeeperServers} \ ---configuration-store ${zookeeperServers} \ ---web-service-url ${webServiceUrl} \ ---broker-service-url ${brokerServiceUrl} - -(curl -sf -XPOST http://127.0.0.1:15020/quitquitquit || true) && exit 0 \ No newline at end of file + echo "Cluster metadata initialized" +} + +initialize_cluster_metadata() { + local cluster_name="$1" + local zk_servers="$2" + local web_service_url="$3" + local broker_service_url="$4" + + echo "Initializing cluster metadata for cluster: ${cluster_name}" + bin/pulsar initialize-cluster-metadata \ + --cluster ${cluster_name} \ + --zookeeper ${zk_servers} \ + --configuration-store ${zk_servers} \ + --web-service-url ${web_service_url} \ + --broker-service-url ${broker_service_url} +} + +init_broker() { + check_env_variables + wait_for_zookeeper "$zookeeperServers" + + # only initialize the cluster if this is the first broker pod + local idx=${POD_NAME##*-} + if [ $idx -ne 0 ]; then + wait_for_cluster_metadata "$zookeeperServers" "$clusterName" + echo "Cluster already initialized" && quit_script + fi + + if check_cluster_initialized "$zookeeperServers" "$clusterName"; then + echo "Cluster already initialized" && quit_script + fi + + initialize_cluster_metadata "$clusterName" "$zookeeperServers" "$webServiceUrl" "$brokerServiceUrl" + quit_script +} + +quit_script() { + (curl -sf -XPOST http://127.0.0.1:15020/quitquitquit || true) && exit 0 +} + +# This is magic for shellspec ut framework. +# Sometime, functions are defined in a single shell script. +# You will want to test it. but you do not want to run the script. +# When included from shellspec, __SOURCED__ variable defined and script +# end here. The script path is assigned to the __SOURCED__ variable. +${__SOURCED__:+false} : || return 0 + +# main +init_broker \ No newline at end of file diff --git a/addons/pulsar/scripts/init-proxy.sh b/addons/pulsar/scripts/init-proxy.sh index 8c0d456af..ee636f0be 100755 --- a/addons/pulsar/scripts/init-proxy.sh +++ b/addons/pulsar/scripts/init-proxy.sh @@ -1,9 +1,31 @@ -#!/bin/sh -if [ -n "${metadataStoreUrl}" ]; then - echo "waiting for zookeeper:{${metadataStoreUrl} to be ready..." - zkDomain="${metadataStoreUrl%%:*}" - until echo ruok | nc -q 1 ${zkDomain} 2181 | grep imok; do - sleep 1; - done; - echo "zk is ready..." -fi \ No newline at end of file +#!/bin/bash + +wait_for_zookeeper() { + local zk_url="$1" + local zk_domain="${zk_url%%:*}" + local zk_port="2181" + + echo "Waiting for Zookeeper at ${zk_url} to be ready..." + until echo ruok | nc -q 1 ${zk_domain} ${zk_port} | grep imok; do + sleep 1 + done + echo "Zookeeper is ready" +} + +main() { + if [ -n "${metadataStoreUrl}" ]; then + wait_for_zookeeper "${metadataStoreUrl}" + else + echo "Zookeeper URL not provided, skipping Zookeeper readiness check" + fi +} + +# This is magic for shellspec ut framework. +# Sometime, functions are defined in a single shell script. +# You will want to test it. but you do not want to run the script. +# When included from shellspec, __SOURCED__ variable defined and script +# end here. The script path is assigned to the __SOURCED__ variable. +${__SOURCED__:+false} : || return 0 + +# main +main \ No newline at end of file diff --git a/addons/pulsar/scripts/prestop-bookies.sh b/addons/pulsar/scripts/prestop-bookies.sh deleted file mode 100755 index 115b18bd9..000000000 --- a/addons/pulsar/scripts/prestop-bookies.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -current_component_replicas=`cat /etc/annotations/component-replicas` -idx=${KB_POD_NAME##*-} -if [[ $idx -ge $current_component_replicas && $current_component_replicas -ne 0 ]]; then - bin/bookkeeper shell bookieformat -nonInteractive -force -deleteCookie || true -fi \ No newline at end of file diff --git a/addons/pulsar/scripts/start-bookies-recovery.sh b/addons/pulsar/scripts/start-bookies-recovery.sh index f3f390e14..3d76ef9df 100755 --- a/addons/pulsar/scripts/start-bookies-recovery.sh +++ b/addons/pulsar/scripts/start-bookies-recovery.sh @@ -1,3 +1,11 @@ -#!/bin/sh -bin/apply-config-from-env.py conf/bookkeeper.conf -exec bin/bookkeeper autorecovery \ No newline at end of file +#!/bin/bash + +set -ex + +start_bookkeeper() { + bin/apply-config-from-env.py conf/bookkeeper.conf + exec bin/bookkeeper autorecovery +} + +# main +start_bookkeeper \ No newline at end of file diff --git a/addons/pulsar/scripts/start-bookies.sh b/addons/pulsar/scripts/start-bookies.sh index 99e28b968..705d4bf2e 100755 --- a/addons/pulsar/scripts/start-bookies.sh +++ b/addons/pulsar/scripts/start-bookies.sh @@ -1,26 +1,101 @@ #!/bin/bash -set -x - -python3 /kb-scripts/merge_pulsar_config.py conf/bookkeeper.conf /opt/pulsar/conf/bookkeeper.conf; -bin/apply-config-from-env.py conf/bookkeeper.conf; - -journalDirectories=$(grep 'journalDirectories' /pulsar/conf/bookkeeper.conf | grep -v '#' | cut -d '=' -f 2) -ledgerDirectories=$(grep 'ledgerDirectories' /pulsar/conf/bookkeeper.conf | grep -v '#' | cut -d '=' -f 2) -mkdir -p ${journalDirectories}/current && mkdir -p ${ledgerDirectories}/current -journalRes=`ls -A ${journalDirectories}/current` -ledgerRes=`ls -A ${ledgerDirectories}/current` - -if [[ -z $journalRes && -z $ledgerRes ]]; then - echo "journalRes and ledgerRes directory is empty, check whether the remote cookies is empty either" - host_ip_port="${KB_POD_FQDN}${cluster_domain}:3181" - zkLedgersRootPath=$(grep 'zkLedgersRootPath' /pulsar/conf/bookkeeper.conf | grep -v '#' | cut -d '=' -f 2) - zNode="${zkLedgersRootPath}/cookies/${host_ip_port}" - - # if current dir are empty but bookieId exists in zookeeper, delete it - if zkURL=${zkServers} python3 /kb-scripts/zookeeper.py get ${zNode}; then - echo "Warning: exist redundant bookieID ${zNode}" - zkURL=${zkServers} python3 /kb-scripts/zookeeper.py delete ${zNode}; - fi -fi - -OPTS="${OPTS} -Dlog4j2.formatMsgNoLookups=true" exec bin/pulsar bookie; \ No newline at end of file + +# shellcheck disable=SC2154 +# shellcheck disable=SC2034 +ut_mode="false" +test || __() { + # when running in non-unit test mode, set the options "set -ex". + set -ex; +} + +load_common_library() { + # the common.sh scripts is mounted to the same path which is defined in the cmpd.spec.scripts + common_library_file="/kb-scripts/common.sh" + # shellcheck disable=SC1090 + source "${common_library_file}" +} + +# Merge configuration files +merge_configs() { + python3 /kb-scripts/merge_pulsar_config.py conf/bookkeeper.conf /opt/pulsar/conf/bookkeeper.conf + bin/apply-config-from-env.py conf/bookkeeper.conf +} + +# Retrieve directory value from the configuration file +get_directory() { + local key="$1" + grep "${key}" /pulsar/conf/bookkeeper.conf | grep -v '#' | cut -d '=' -f 2 +} + +# Create necessary directories +create_directories() { + local journal_dir="$1" + local ledger_dir="$2" + mkdir -p "${journal_dir}/current" && mkdir -p "${ledger_dir}/current" +} + +# Check if both directories are empty +check_empty_directories() { + local journal_dir="$1" + local ledger_dir="$2" + [[ -z $(ls -A "${journal_dir}/current") && -z $(ls -A "${ledger_dir}/current") ]] +} + +# Handle the case when both directories are empty +handle_empty_directories() { + echo "journalRes and ledgerRes directory is empty, check whether the remote cookies is empty either" + # check env BOOKKEEPER_POD_FQDN_LIST and CURRENT_POD_NAME + if is_empty "$BOOKKEEPER_POD_FQDN_LIST" || is_empty "$CURRENT_POD_NAME" || is_empty "${zkServers}"; then + echo "Error: BOOKKEEPER_POD_FQDN_LIST or CURRENT_POD_NAME or zkServers is empty. Exiting." >&2 + return 1 + fi + + local host_ip_port + host_ip_port=$(get_target_pod_fqdn_from_pod_fqdn_vars "$BOOKKEEPER_POD_FQDN_LIST" "$CURRENT_POD_NAME") + if is_empty "$host_ip_port"; then + echo "Error: Failed to get current pod: $CURRENT_POD_NAME fqdn from bookkeeper pod fqdn list: $BOOKKEEPER_POD_FQDN_LIST. Exiting." >&2 + return 1 + fi + + local zkLedgersRootPath + zkLedgersRootPath=$(get_directory 'zkLedgersRootPath') + local zNode="${zkLedgersRootPath}/cookies/${host_ip_port}" + + if zkURL="${zkServers}" python3 /kb-scripts/zookeeper.py get "${zNode}"; then + echo "Warning: exist redundant bookieID ${zNode}" + zkURL="${zkServers}" python3 /kb-scripts/zookeeper.py delete "${zNode}" + fi + return 0 +} + +start_bookies() { + merge_configs + + local journalDirectories + local ledgerDirectories + journalDirectories=$(get_directory 'journalDirectories') + ledgerDirectories=$(get_directory 'ledgerDirectories') + + create_directories "${journalDirectories}" "${ledgerDirectories}" + + if check_empty_directories "${journalDirectories}" "${ledgerDirectories}"; then + if ! handle_empty_directories; then + echo "Error: Failed to handle empty directories. Exiting." >&2 + exit 1 + fi + fi + + OPTS="${OPTS} -Dlog4j2.formatMsgNoLookups=true" + exec bin/pulsar bookie +} + +# This is magic for shellspec ut framework. +# Sometime, functions are defined in a single shell script. +# You will want to test it. but you do not want to run the script. +# When included from shellspec, __SOURCED__ variable defined and script +# end here. The script path is assigned to the __SOURCED__ variable. +${__SOURCED__:+false} : || return 0 + +# main +load_common_library +start_bookies \ No newline at end of file diff --git a/addons/pulsar/scripts/start-broker.sh b/addons/pulsar/scripts/start-broker.sh index 4a1616303..420400686 100644 --- a/addons/pulsar/scripts/start-broker.sh +++ b/addons/pulsar/scripts/start-broker.sh @@ -1,62 +1,109 @@ #!/bin/bash -set -x + +# shellcheck disable=SC2154 +# shellcheck disable=SC2034 +ut_mode="false" +test || __() { + # when running in non-unit test mode, set the options "set -ex". + set -ex; +} extract_ordinal_from_object_name() { local object_name="$1" - local ordinal="${object_name##*-}" - echo "$ordinal" + echo "${object_name##*-}" } parse_advertised_svc_if_exist() { - local pod_name="${KB_POD_NAME}" - local pod_service_list="${1}" + # shellcheck disable=SC2153 + local pod_name="${POD_NAME}" + local pod_service_list="$1" - if [[ "$pod_service_list" == "" ]]; then + if [[ -z "$pod_service_list" ]]; then echo "Ignoring." return 0 fi - # the value format of $pod_service_list is "pod1Svc:advertisedPort1,pod2Svc:advertisedPort2,..." IFS=',' read -ra advertised_ports <<< "$pod_service_list" - echo "~~~~~~advertised_ports:${advertised_ports}" - local found=false + echo "advertised_ports: ${advertised_ports[*]}" + + local pod_name_ordinal pod_name_ordinal=$(extract_ordinal_from_object_name "$pod_name") - echo "~~~~~~pod_name_ordinal:${pod_name_ordinal}" + echo "pod_name_ordinal: $pod_name_ordinal" + for advertised_port in "${advertised_ports[@]}"; do - IFS=':' read -ra parts <<< "$advertised_port" - local svc_name="${parts[0]}" - local port="${parts[1]}" - svc_name_ordinal=$(extract_ordinal_from_object_name "$svc_name") - echo "~~~~~~svc_name:${svc_name},port:${port},svc_name_ordinal:${svc_name_ordinal}" - if [[ "$svc_name_ordinal" == "$pod_name_ordinal" ]]; then - echo "Found matching svcName and port for podName '$pod_name', BROKER_ADVERTISED_PORT: $pod_service_list. svcName: $svc_name, port: $port." - advertised_svc_port_value="$port" - found=true - break - fi + process_advertised_port "$advertised_port" "$pod_name_ordinal" "$pod_name" done - if [[ "$found" == false ]]; then - echo "Error: No matching svcName and port found for podName '$pod_name', BROKER_ADVERTISED_PORT: $pod_service_list. Exiting." - exit 1 + # check advertised_svc_port_value is set + if [[ -z "$advertised_svc_port_value" ]]; then + handle_no_matching_service + fi +} + +process_advertised_port() { + local advertised_port="$1" + local pod_name_ordinal="$2" + local pod_name="$3" + + IFS=':' read -ra parts <<< "$advertised_port" + local svc_name="${parts[0]}" + local port="${parts[1]}" + local svc_name_ordinal + svc_name_ordinal=$(extract_ordinal_from_object_name "$svc_name") + echo "svc_name: $svc_name, port: $port, svc_name_ordinal: $svc_name_ordinal, pod_name_ordinal: $pod_name_ordinal" + + if [[ "$svc_name_ordinal" == "$pod_name_ordinal" ]]; then + echo "Found matching svcName and port for podName '$pod_name', BROKER_ADVERTISED_PORT: $ADVERTISED_PORT_PULSAR. svcName: $svc_name, port: $port." + advertised_svc_port_value="$port" + return 0 fi } -if [[ "true" == "$KB_PULSAR_BROKER_NODEPORT" ]]; then +handle_no_matching_service() { + echo "Error: No matching svcName and port found for podName '$POD_NAME', BROKER_ADVERTISED_PORT: $ADVERTISED_PORT_PULSAR. Exiting." + exit 1 +} + +initialize_nodeport_config() { echo "init NodePort config:" parse_advertised_svc_if_exist "${ADVERTISED_PORT_PULSAR}" - nodeport_pulsar_domain="${KB_HOST_IP}:${advertised_svc_port_value}" + local nodeport_pulsar_domain="${POD_HOST_IP}:${advertised_svc_port_value}" + parse_advertised_svc_if_exist "${ADVERTISED_PORT_KAFKA}" - nodeport_kafka_domain="${KB_HOST_IP}:${advertised_svc_port_value}" + local nodeport_kafka_domain="${POD_HOST_IP}:${advertised_svc_port_value}" + export PULSAR_PREFIX_advertisedListeners="cluster:pulsar://${nodeport_pulsar_domain}" - echo "[cfg]set PULSAR_PREFIX_advertisedListeners=${PULSAR_PREFIX_advertisedListeners}" + echo "[cfg] set PULSAR_PREFIX_advertisedListeners=${PULSAR_PREFIX_advertisedListeners}" + export PULSAR_PREFIX_kafkaAdvertisedListeners="CLIENT://${nodeport_kafka_domain}" - echo "[cfg]set PULSAR_PREFIX_kafkaAdvertisedListeners=${PULSAR_PREFIX_kafkaAdvertisedListeners}" -fi + echo "[cfg] set PULSAR_PREFIX_kafkaAdvertisedListeners=${PULSAR_PREFIX_kafkaAdvertisedListeners}" +} + +merge_configuration_files() { + /kb-scripts/merge_pulsar_config.py conf/client.conf /opt/pulsar/conf/client.conf + /kb-scripts/merge_pulsar_config.py conf/broker.conf /opt/pulsar/conf/broker.conf + bin/apply-config-from-env.py conf/broker.conf + bin/apply-config-from-env.py conf/client.conf +} + +start_broker() { + ## TODO: $KB_PULSAR_BROKER_NODEPORT define in cluster annotation extra-envs, which need to be refactored + if [[ "$KB_PULSAR_BROKER_NODEPORT" == "true" ]]; then + initialize_nodeport_config + fi + + merge_configuration_files + + echo 'OK' > status + exec bin/pulsar broker +} -/kb-scripts/merge_pulsar_config.py conf/client.conf /opt/pulsar/conf/client.conf && \ -/kb-scripts/merge_pulsar_config.py conf/broker.conf /opt/pulsar/conf/broker.conf && \ -bin/apply-config-from-env.py conf/broker.conf && \ -bin/apply-config-from-env.py conf/client.conf && \ +# This is magic for shellspec ut framework. +# Sometime, functions are defined in a single shell script. +# You will want to test it. but you do not want to run the script. +# When included from shellspec, __SOURCED__ variable defined and script +# end here. The script path is assigned to the __SOURCED__ variable. +${__SOURCED__:+false} : || return 0 -echo 'OK' > status;exec bin/pulsar broker \ No newline at end of file +# main +start_broker \ No newline at end of file diff --git a/addons/pulsar/scripts/start-proxy.sh b/addons/pulsar/scripts/start-proxy.sh index c3f37f616..023002657 100755 --- a/addons/pulsar/scripts/start-proxy.sh +++ b/addons/pulsar/scripts/start-proxy.sh @@ -1,3 +1,11 @@ -#!/bin/sh -python3 /kb-scripts/merge_pulsar_config.py conf/proxy.conf /opt/pulsar/conf/proxy.conf && -bin/apply-config-from-env.py conf/proxy.conf && echo 'OK' > status && exec bin/pulsar proxy \ No newline at end of file +#!/bin/bash + +set -ex + +start_proxy() { + python3 /kb-scripts/merge_pulsar_config.py conf/proxy.conf /opt/pulsar/conf/proxy.conf && + bin/apply-config-from-env.py conf/proxy.conf && echo 'OK' > status && exec bin/pulsar proxy +} + +# main +start_proxy \ No newline at end of file diff --git a/addons/pulsar/scripts/start-zookeeper.sh b/addons/pulsar/scripts/start-zookeeper.sh index 8b07b8ddd..3d07ab828 100755 --- a/addons/pulsar/scripts/start-zookeeper.sh +++ b/addons/pulsar/scripts/start-zookeeper.sh @@ -1,8 +1,12 @@ #!/bin/bash -set -e +set -ex -export ZOOKEEPER_SERVERS=${KB_POD_LIST} +start_zookeeper() { + export ZOOKEEPER_SERVERS=${ZK_POD_NAME_LIST} + bin/apply-config-from-env.py conf/zookeeper.conf; + bin/generate-zookeeper-config.sh conf/zookeeper.conf; exec bin/pulsar zookeeper; +} -bin/apply-config-from-env.py conf/zookeeper.conf; -bin/generate-zookeeper-config.sh conf/zookeeper.conf; exec bin/pulsar zookeeper; +# main +start_zookeeper diff --git a/addons/pulsar/templates/_helpers.tpl b/addons/pulsar/templates/_helpers.tpl index 761c86ac1..ce1c3f860 100644 --- a/addons/pulsar/templates/_helpers.tpl +++ b/addons/pulsar/templates/_helpers.tpl @@ -50,6 +50,13 @@ app.kubernetes.io/name: {{ include "pulsar.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} +{{/* +Common annotations +*/}} +{{- define "pulsar.annotations" -}} +helm.sh/resource-policy: keep +{{- end }} + {{/* Create full image name */}} @@ -82,3 +89,318 @@ Generate major version of cluster {{- $majorVersion := (split "." $version)._0 -}} {{- printf "%s" ($majorVersion)}} {{- end }} + +{{/* +Define pulsar bookies reovery component definition regex pattern +*/}} +{{- define "pulsar.bkRecoveryCmpdRegexPattern" -}} +^pulsar-bookies-recovery- +{{- end -}} + +{{/* +Define pulsar v3.X bookies reovery component definition name +*/}} +{{- define "pulsar3.bkRecoveryCmpdName" -}} +pulsar-bookies-recovery-3-{{ .Chart.Version }} +{{- end -}} + +{{/* +Define pulsar v2.X bookies reovery component definition name +*/}} +{{- define "pulsar2.bkRecoveryCmpdName" -}} +pulsar-bookies-recovery-2-{{ .Chart.Version }} +{{- end -}} + +{{/* +Define pulsar bookkeeper component definition regex pattern +*/}} +{{- define "pulsar.bookkeeperCmpdRegexPattern" -}} +^pulsar-bookkeeper- +{{- end -}} + +{{/* +Define pulsar v3.X bookkeeper component definition name +*/}} +{{- define "pulsar3.bookkeeperCmpdName" -}} +pulsar-bookkeeper-3-{{ .Chart.Version }} +{{- end -}} + +{{/* +Define pulsar v2.X bookkeeper component definition name +*/}} +{{- define "pulsar2.bookkeeperCmpdName" -}} +pulsar-bookkeeper-2-{{ .Chart.Version }} +{{- end -}} + +{{/* +Define pulsar broker component definition regex pattern +*/}} +{{- define "pulsar.brokerCmpdRegexPattern" -}} +^pulsar-broker- +{{- end -}} + +{{/* +Define pulsar v3.X broker component definition name +*/}} +{{- define "pulsar3.brokerCmpdName" -}} +pulsar-broker-3-{{ .Chart.Version }} +{{- end -}} + +{{/* +Define pulsar v3.X broker component definition regex pattern +*/}} +{{- define "pulsar3.brokerCmpdRegexPattern" -}} +^pulsar-broker-3- +{{- end -}} + +{{/* +Define pulsar v2.X bookies reovery component definition name +*/}} +{{- define "pulsar2.brokerCmpdName" -}} +pulsar-broker-2-{{ .Chart.Version }} +{{- end -}} + +{{/* +Define pulsar v2.X broker component definition regex pattern +*/}} +{{- define "pulsar2.brokerCmpdRegexPattern" -}} +^pulsar-broker-2- +{{- end -}} + +{{/* +Define pulsar proxy component definition regex pattern +*/}} +{{- define "pulsar.proxyCmpdRegexPattern" -}} +^pulsar-proxy- +{{- end -}} + +{{/* +Define pulsar v3.X proxy component definition name +*/}} +{{- define "pulsar3.proxyCmpdName" -}} +pulsar-proxy-3-{{ .Chart.Version }} +{{- end -}} + +{{/* +Define pulsar v2.X bookies reovery component definition name +*/}} +{{- define "pulsar2.proxyCmpdName" -}} +pulsar-proxy-2-{{ .Chart.Version }} +{{- end -}} + +{{/* +Define pulsar zookeeper component definition regex pattern +*/}} +{{- define "pulsar.zookeeperCmpdRegexPattern" -}} +^pulsar-zookeeper- +{{- end -}} + +{{/* +Define pulsar v3.X zookeeper component definition name +*/}} +{{- define "pulsar3.zookeeperCmpdName" -}} +pulsar-zookeeper-3-{{ .Chart.Version }} +{{- end -}} + +{{/* +Define pulsar v2.X zookeeper component definition name +*/}} +{{- define "pulsar2.zookeeperCmpdName" -}} +pulsar-zookeeper-2-{{ .Chart.Version }} +{{- end -}} + +{{/* +Define pulsar scripts tpl name +*/}} +{{- define "pulsar.scriptsTplName" -}} +pulsar-scripts +{{- end -}} + +{{/* +Define pulsar tools scripts tpl name +*/}} +{{- define "pulsar.toolsScriptsTplName" -}} +pulsar-tools-script +{{- end -}} + +{{/* +Define pulsar bookies recovery env tpl name +*/}} +{{- define "pulsar.bookiesRecoveryEnvTplName" -}} +pulsar-bookies-recovery-env-tpl +{{- end -}} + +{{/* +Define pulsar bookies recovery env tpl name +*/}} +{{- define "pulsar.bookiesEnvTplName" -}} +pulsar-bookies-env-tpl +{{- end -}} + +{{/* +Define pulsar broker env tpl name +*/}} +{{- define "pulsar.brokerEnvTplName" -}} +pulsar-broker-env-tpl +{{- end -}} + +{{/* +Define pulsar proxy env tpl name +*/}} +{{- define "pulsar.proxyEnvTplName" -}} +pulsar-proxy-env-tpl +{{- end -}} + +{{/* +Define pulsar zookeeper env tpl name +*/}} +{{- define "pulsar.zookeeperEnvTplName" -}} +pulsar-zookeeper-env-tpl +{{- end -}} + +{{/* +Define pulsar env config constraint name +*/}} +{{- define "pulsar.envConstraintName" -}} +pulsar-env-constraints +{{- end -}} + +{{/* +Define pulsar v3.X bookies recovery config tpl name +*/}} +{{- define "pulsar3.bookiesConfigTplName" -}} +pulsar3-bookies-config-tpl +{{- end -}} + +{{/* +Define pulsar v2.X bookies recovery config tpl name +*/}} +{{- define "pulsar2.bookiesConfigTplName" -}} +pulsar2-bookies-config-tpl +{{- end -}} + +{{/* +Define pulsar v3.X bookies recovery config constraint name +*/}} +{{- define "pulsar3.bookiesConfigConstraintName" -}} +pulsar3-bookies-config-constraint +{{- end -}} + +{{/* +Define pulsar v2.X bookies recovery config constraint name +*/}} +{{- define "pulsar2.bookiesConfigConstraintName" -}} +pulsar2-bookies-config-constraint +{{- end -}} + +{{/* +Define pulsar v3.X broker config tpl name +*/}} +{{- define "pulsar3.brokerConfigTplName" -}} +pulsar3-broker-config-tpl +{{- end -}} + +{{/* +Define pulsar v2.X broker config tpl name +*/}} +{{- define "pulsar2.brokerConfigTplName" -}} +pulsar2-broker-config-tpl +{{- end -}} + +{{/* +Define pulsar v3.X broker config constraint name +*/}} +{{- define "pulsar3.brokerConfigConstraintName" -}} +pulsar3-broker-config-constraint +{{- end -}} + +{{/* +Define pulsar v2.X broker config constraint name +*/}} +{{- define "pulsar2.brokerConfigConstraintName" -}} +pulsar2-broker-config-constraint +{{- end -}} + +{{/* +Define pulsar v3.X proxy config tpl name +*/}} +{{- define "pulsar3.proxyConfigTplName" -}} +pulsar3-proxy-config-tpl +{{- end -}} + +{{/* +Define pulsar v2.X broker config tpl name +*/}} +{{- define "pulsar2.proxyConfigTplName" -}} +pulsar2-proxy-config-tpl +{{- end -}} + +{{/* +Define pulsar v3.X proxy config constraint name +*/}} +{{- define "pulsar3.proxyConfigConstraintName" -}} +pulsar3-proxy-config-constraint +{{- end -}} + +{{/* +Define pulsar v2.X proxy config constraint name +*/}} +{{- define "pulsar2.proxyConfigConstraintName" -}} +pulsar2-proxy-config-constraint +{{- end -}} + +{{/* +Define pulsar v3.X bookies image +*/}} +{{- define "pulsar3.bookiesImage" -}} +{{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.images.v3_0_2.bookie.tag }} +{{- end }} + +{{/* +Define pulsar v2.X bookies image +*/}} +{{- define "pulsar2.bookiesImage" -}} +{{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.images.v2_11_2.bookie.tag }} +{{- end }} + +{{/* +Define pulsar v3.X broker image +*/}} +{{- define "pulsar3.brokerImage" -}} +{{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.images.v3_0_2.broker.tag }} +{{- end }} + +{{/* +Define pulsar v2.X broker image +*/}} +{{- define "pulsar2.brokerImage" -}} +{{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.images.v2_11_2.broker.tag }} +{{- end }} + +{{/* +Define pulsar v3.X proxy image +*/}} +{{- define "pulsar3.proxyImage" -}} +{{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.images.v3_0_2.proxy.tag }} +{{- end }} + +{{/* +Define pulsar v2.X proxy image +*/}} +{{- define "pulsar2.proxyImage" -}} +{{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.images.v2_11_2.proxy.tag }} +{{- end }} + +{{/* +Define pulsar v3.X zookeeper image +*/}} +{{- define "pulsar3.zookeeperImage" -}} +{{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.images.v3_0_2.zookeeper.tag }} +{{- end }} + +{{/* +Define pulsar v2.X zookeeper image +*/}} +{{- define "pulsar2.zookeeperImage" -}} +{{ .Values.image.registry | default "docker.io" }}/{{ .Values.image.repository }}:{{ .Values.images.v2_11_2.zookeeper.tag }} +{{- end }} \ No newline at end of file diff --git a/addons/pulsar/templates/clusterdefinition.yaml b/addons/pulsar/templates/clusterdefinition.yaml index 27b6fd891..f5746ced3 100644 --- a/addons/pulsar/templates/clusterdefinition.yaml +++ b/addons/pulsar/templates/clusterdefinition.yaml @@ -9,11 +9,11 @@ spec: - name: pulsar-basic-cluster components: - name: broker - compDef: pulsar-broker-{{include "pulsar.major.version" .}} + compDef: {{ include "pulsar.brokerCmpdRegexPattern" . }} - name: bookies - compDef: pulsar-bookkeeper-{{include "pulsar.major.version" .}} + compDef: {{ include "pulsar.bookkeeperCmpdRegexPattern" . }} - name: zookeeper - compDef: pulsar-zookeeper-{{include "pulsar.major.version" .}} + compDef: {{ include "pulsar.zookeeperCmpdRegexPattern" . }} default: true orders: provision: @@ -28,15 +28,20 @@ spec: - name: pulsar-enhanced-cluster components: - name: broker - compDef: pulsar-broker-{{include "pulsar.major.version" .}} + ## regex pattern for broker component definition match pulsar 2.X and 3.X + compDef: {{ include "pulsar.brokerCmpdRegexPattern" . }} - name: bookies - compDef: pulsar-bookkeeper-{{include "pulsar.major.version" .}} + ## regex pattern for bookies component definition match pulsar 2.X and 3.X + compDef: {{ include "pulsar.bookkeeperCmpdRegexPattern" . }} - name: zookeeper - compDef: pulsar-zookeeper-{{include "pulsar.major.version" .}} + ## regex pattern for zk component definition match pulsar 2.X and 3.X + compDef: {{ include "pulsar.zookeeperCmpdRegexPattern" . }} - name: proxy - compDef: pulsar-proxy-{{include "pulsar.major.version" .}} + ## regex pattern for proxy component definition match pulsar 2.X and 3.X + compDef: {{ include "pulsar.proxyCmpdRegexPattern" . }} - name: bookies-recovery - compDef: pulsar-bkrecovery-{{include "pulsar.major.version" .}} + ## regex pattern for bookies recovery component definition match pulsar 2.X and 3.X + compDef: {{ include "pulsar.bkRecoveryCmpdRegexPattern" . }} orders: provision: - zookeeper,bookies-recovery diff --git a/addons/pulsar/templates/cmpd-bkrecovery.yaml b/addons/pulsar/templates/cmpd-bookies-recovery-2.yaml similarity index 74% rename from addons/pulsar/templates/cmpd-bkrecovery.yaml rename to addons/pulsar/templates/cmpd-bookies-recovery-2.yaml index 537aa90b8..4706c6783 100644 --- a/addons/pulsar/templates/cmpd-bkrecovery.yaml +++ b/addons/pulsar/templates/cmpd-bookies-recovery-2.yaml @@ -1,14 +1,16 @@ apiVersion: apps.kubeblocks.io/v1 kind: ComponentDefinition metadata: - name: pulsar-bkrecovery-{{include "pulsar.major.version" .}} + name: {{ include "pulsar2.bkRecoveryCmpdName" . }} labels: - {{- include "pulsar.labels" . | nindent 4 }} + {{- include "pulsar.labels" . | nindent 4 }} + annotations: + {{- include "pulsar.annotations" . | nindent 4 }} spec: provider: kubeblocks - description: Pulsar bookies auto-recovery. + description: Pulsar bookies recovery component definition serviceKind: pulsar - serviceVersion: {{ default .Chart.AppVersion .Values.clusterVersionOverride }} + serviceVersion: {{ .Values.defaultServiceVersion.recovery.major2 }} serviceRefDeclarations: - name: pulsarZookeeper serviceRefDeclarationSpecs: @@ -18,9 +20,9 @@ spec: updateStrategy: BestEffortParallel configs: - name: bookies-recovery-env - templateRef: {{ include "pulsar.name" . }}-recovery-env-tpl + templateRef: {{ include "pulsar.bookiesRecoveryEnvTplName" . }} namespace: {{ .Release.Namespace }} - constraintRef: pulsar-env-constraints + constraintRef: {{ include "pulsar.envConstraintName" . }} keys: - conf injectEnvTo: @@ -31,10 +33,13 @@ spec: - vscale scripts: - name: pulsar-scripts - templateRef: {{ include "pulsar.name" . }}-scripts + templateRef: {{ include "pulsar.scriptsTplName" . }} namespace: {{ .Release.Namespace }} volumeName: scripts defaultMode: 0555 + exporter: + scrapePath: /metrics + scrapePort: http runtime: securityContext: runAsNonRoot: true @@ -43,8 +48,8 @@ spec: runAsGroup: 0 initContainers: - name: check-bookies - image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.v3_0_2.bookie "root" .) }}" - imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.v3_0_2.bookie "root" .) }}" + image: {{ include "pulsar2.bookiesImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} command: - /kb-scripts/check-bookies.sh env: @@ -72,8 +77,8 @@ spec: - ALL privileged: false runAsGroup: 0 - image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.v3_0_2.bookie "root" .) }}" - imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.v3_0_2.bookie "root" .) }}" + image: {{ include "pulsar2.bookiesImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} command: - /kb-scripts/start-bookies-recovery.sh env: @@ -103,6 +108,3 @@ spec: mountPath: /kb-scripts - name: recovery-config-env mountPath: /opt/pulsar/none - exporter: - scrapePath: /metrics - scrapePort: http diff --git a/addons/pulsar/templates/cmpd-bookies-recovery-3.yaml b/addons/pulsar/templates/cmpd-bookies-recovery-3.yaml new file mode 100644 index 000000000..1d443cc40 --- /dev/null +++ b/addons/pulsar/templates/cmpd-bookies-recovery-3.yaml @@ -0,0 +1,110 @@ +apiVersion: apps.kubeblocks.io/v1 +kind: ComponentDefinition +metadata: + name: {{ include "pulsar3.bkRecoveryCmpdName" . }} + labels: + {{- include "pulsar.labels" . | nindent 4 }} + annotations: + {{- include "pulsar.annotations" . | nindent 4 }} +spec: + provider: kubeblocks + description: Pulsar bookies recovery component definition + serviceKind: pulsar + serviceVersion: {{ .Values.defaultServiceVersion.recovery.major3 }} + serviceRefDeclarations: + - name: pulsarZookeeper + serviceRefDeclarationSpecs: + - serviceKind: zookeeper + serviceVersion: ^3.8.\d{1,2}$ + optional: true + updateStrategy: BestEffortParallel + configs: + - name: bookies-recovery-env + templateRef: {{ include "pulsar.bookiesRecoveryEnvTplName" . }} + namespace: {{ .Release.Namespace }} + constraintRef: {{ include "pulsar.envConstraintName" . }} + keys: + - conf + injectEnvTo: + - bookies-recovery + - check-bookies + volumeName: recovery-config-env + reRenderResourceTypes: + - vscale + scripts: + - name: pulsar-scripts + templateRef: {{ include "pulsar.scriptsTplName" . }} + namespace: {{ .Release.Namespace }} + volumeName: scripts + defaultMode: 0555 + exporter: + scrapePath: /metrics + scrapePort: http + runtime: + securityContext: + runAsNonRoot: true + runAsUser: 10000 + fsGroup: 0 + runAsGroup: 0 + initContainers: + - name: check-bookies + image: {{ include "pulsar3.bookiesImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + command: + - /kb-scripts/check-bookies.sh + env: + {{- if .Values.debugEnabled }} + - name: PULSAR_LOG_ROOT_LEVEL + value: DEBUG + - name: PULSAR_LOG_LEVEL + value: DEBUG + {{- end }} + volumeMounts: + - name: scripts + mountPath: /kb-scripts + securityContext: + privileged: true + runAsNonRoot: false + runAsUser: 0 + containers: + - name: bookies-recovery + securityContext: + allowPrivilegeEscalation: false + runAsNonRoot: true + runAsUser: 10000 + capabilities: + drop: + - ALL + privileged: false + runAsGroup: 0 + image: {{ include "pulsar3.bookiesImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + command: + - /kb-scripts/start-bookies-recovery.sh + env: + {{- if .Values.debugEnabled }} + - name: PULSAR_LOG_ROOT_LEVEL + value: DEBUG + - name: PULSAR_LOG_LEVEL + value: DEBUG + {{- end }} + - name: SERVICE_PORT + value: "8000" + - name: httpServerEnabled + value: "true" + - name: httpServerPort + value: "8000" + - name: prometheusStatsHttpPort + value: "8000" + - name: useHostNameAsBookieID + value: "true" + ports: + - name: http + containerPort: 8000 + - name: bookie + containerPort: 3181 + volumeMounts: + - name: scripts + mountPath: /kb-scripts + - name: recovery-config-env + mountPath: /opt/pulsar/none diff --git a/addons/pulsar/templates/cmpd-bookkeeper.yaml b/addons/pulsar/templates/cmpd-bookkeeper-2.yaml similarity index 62% rename from addons/pulsar/templates/cmpd-bookkeeper.yaml rename to addons/pulsar/templates/cmpd-bookkeeper-2.yaml index df8298eb5..306845ec6 100644 --- a/addons/pulsar/templates/cmpd-bookkeeper.yaml +++ b/addons/pulsar/templates/cmpd-bookkeeper-2.yaml @@ -1,14 +1,16 @@ apiVersion: apps.kubeblocks.io/v1 kind: ComponentDefinition metadata: - name: pulsar-bookkeeper-{{include "pulsar.major.version" .}} + name: {{ include "pulsar2.bookkeeperCmpdName" . }} labels: - {{- include "pulsar.labels" . | nindent 4 }} + {{- include "pulsar.labels" . | nindent 4 }} + annotations: + {{- include "pulsar.annotations" . | nindent 4 }} spec: provider: kubeblocks - description: Pulsar bookkeeper. + description: Pulsar bookkeeper component definition serviceKind: pulsar - serviceVersion: {{ default .Chart.AppVersion .Values.clusterVersionOverride }} + serviceVersion: {{ .Values.defaultServiceVersion.bookkeeper.major2 }} serviceRefDeclarations: - name: pulsarZookeeper serviceRefDeclarationSpecs: @@ -18,9 +20,9 @@ spec: updateStrategy: BestEffortParallel configs: - name: bookies-env - templateRef: {{ include "pulsar.name" . }}-bookies-env-tpl + templateRef: {{ include "pulsar.bookiesEnvTplName" . }} namespace: {{ .Release.Namespace }} - constraintRef: pulsar-env-constraints + constraintRef: {{ include "pulsar.envConstraintName" . }} volumeName: bookies-env keys: - conf @@ -30,23 +32,51 @@ spec: reRenderResourceTypes: - vscale - name: bookies-config - templateRef: {{ include "pulsar.name" . }}{{include "pulsar.major.version" .}}-bookies-config-tpl + templateRef: {{ include "pulsar2.bookiesConfigTplName" . }} namespace: {{ .Release.Namespace }} volumeName: pulsar-bookies-config - constraintRef: pulsar{{include "pulsar.major.version" .}}-bookies-cc + constraintRef: {{ include "pulsar2.bookiesConfigConstraintName" . }} reRenderResourceTypes: - vscale scripts: - name: pulsar-scripts - templateRef: {{ include "pulsar.name" . }}-scripts + templateRef: {{ include "pulsar.scriptsTplName" . }} namespace: {{ .Release.Namespace }} volumeName: scripts defaultMode: 0555 + exporter: + scrapePath: /metrics + scrapePort: http + vars: + - name: BOOKKEEPER_COMP_REPLICAS + valueFrom: + componentVarRef: + optional: false + replicas: Required + - name: BOOKKEEPER_POD_FQDN_LIST + valueFrom: + componentVarRef: + optional: true + podFQDNs: Required + lifecycleActions: + memberLeave: + exec: + container: bookies + command: + - /bin/bash + - -c + - /kb-scripts/bookies-member-leave.sh + env: + - name: CURRENT_POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name runtime: initContainers: - name: init-bookies - image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.v3_0_2.bookie "root" .) }}" - imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.v3_0_2.bookie "root" .) }}" + image: {{ include "pulsar2.bookiesImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} command: - /kb-scripts/init-bookies.sh env: @@ -61,10 +91,16 @@ spec: volumeMounts: - name: scripts mountPath: /kb-scripts + env: + - name: CURRENT_POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name containers: - name: bookies - image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.v3_0_2.bookie "root" .) }}" - imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.v3_0_2.bookie "root" .) }}" + image: {{ include "pulsar2.bookiesImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} command: - /kb-scripts/start-bookies.sh env: @@ -76,12 +112,11 @@ spec: {{- end }} - name: SERVICE_PORT value: "8000" - - name: cluster_domain - value: {{ .Values.clusterDomain }} - lifecycle: - preStop: - exec: - command: [ "/kb-scripts/prestop-bookies.sh" ] + - name: CURRENT_POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name livenessProbe: failureThreshold: 60 httpGet: @@ -123,19 +158,7 @@ spec: name: ledgers - name: scripts mountPath: /kb-scripts - - name: annotations - mountPath: /etc/annotations - name: bookies-env mountPath: /opt/pulsar/none - name: pulsar-bookies-config - mountPath: /opt/pulsar/conf - volumes: - - name: annotations - downwardAPI: - items: - - path: "component-replicas" - fieldRef: - fieldPath: metadata.annotations['apps.kubeblocks.io/component-replicas'] - exporter: - scrapePath: /metrics - scrapePort: http + mountPath: /opt/pulsar/conf \ No newline at end of file diff --git a/addons/pulsar/templates/cmpd-bookkeeper-3.yaml b/addons/pulsar/templates/cmpd-bookkeeper-3.yaml new file mode 100644 index 000000000..eb2b1f834 --- /dev/null +++ b/addons/pulsar/templates/cmpd-bookkeeper-3.yaml @@ -0,0 +1,164 @@ +apiVersion: apps.kubeblocks.io/v1 +kind: ComponentDefinition +metadata: + name: {{ include "pulsar3.bookkeeperCmpdName" . }} + labels: + {{- include "pulsar.labels" . | nindent 4 }} + annotations: + {{- include "pulsar.annotations" . | nindent 4 }} +spec: + provider: kubeblocks + description: Pulsar bookkeeper component definition + serviceKind: pulsar + serviceVersion: {{ .Values.defaultServiceVersion.bookkeeper.major3 }} + serviceRefDeclarations: + - name: pulsarZookeeper + serviceRefDeclarationSpecs: + - serviceKind: zookeeper + serviceVersion: ^3.8.\d{1,2}$ + optional: true + updateStrategy: BestEffortParallel + configs: + - name: bookies-env + templateRef: {{ include "pulsar.bookiesEnvTplName" . }} + namespace: {{ .Release.Namespace }} + constraintRef: {{ include "pulsar.envConstraintName" . }} + volumeName: bookies-env + keys: + - conf + injectEnvTo: + - init-bookies + - bookies + reRenderResourceTypes: + - vscale + - name: bookies-config + templateRef: {{ include "pulsar3.bookiesConfigTplName" . }} + namespace: {{ .Release.Namespace }} + volumeName: pulsar-bookies-config + constraintRef: {{ include "pulsar3.bookiesConfigConstraintName" . }} + reRenderResourceTypes: + - vscale + scripts: + - name: pulsar-scripts + templateRef: {{ include "pulsar.scriptsTplName" . }} + namespace: {{ .Release.Namespace }} + volumeName: scripts + defaultMode: 0555 + exporter: + scrapePath: /metrics + scrapePort: http + vars: + - name: BOOKKEEPER_COMP_REPLICAS + valueFrom: + componentVarRef: + optional: false + replicas: Required + - name: BOOKKEEPER_POD_FQDN_LIST + valueFrom: + componentVarRef: + optional: true + podFQDNs: Required + lifecycleActions: + memberLeave: + exec: + container: bookies + command: + - /bin/bash + - -c + - /kb-scripts/bookies-member-leave.sh + env: + - name: CURRENT_POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + runtime: + initContainers: + - name: init-bookies + image: {{ include "pulsar3.bookiesImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + command: + - /kb-scripts/init-bookies.sh + env: + {{- if .Values.debugEnabled }} + - name: PULSAR_LOG_ROOT_LEVEL + value: DEBUG + - name: PULSAR_LOG_LEVEL + value: DEBUG + {{- end }} + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - name: scripts + mountPath: /kb-scripts + env: + - name: CURRENT_POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + containers: + - name: bookies + image: {{ include "pulsar3.bookiesImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + command: + - /kb-scripts/start-bookies.sh + env: + {{- if .Values.debugEnabled }} + - name: PULSAR_LOG_ROOT_LEVEL + value: DEBUG + - name: PULSAR_LOG_LEVEL + value: DEBUG + {{- end }} + - name: SERVICE_PORT + value: "8000" + - name: CURRENT_POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + livenessProbe: + failureThreshold: 60 + httpGet: + path: /api/v1/bookie/state + port: http + scheme: HTTP + initialDelaySeconds: 10 + periodSeconds: 30 + successThreshold: 1 + timeoutSeconds: 5 + ports: + - name: http + containerPort: 8000 + - name: bookie + containerPort: 3181 + readinessProbe: + failureThreshold: 60 + httpGet: + path: /api/v1/bookie/is_ready + port: http + scheme: HTTP + initialDelaySeconds: 10 + periodSeconds: 30 + successThreshold: 1 + timeoutSeconds: 5 + resources: + requests: + cpu: 200m + memory: 512Mi + securityContext: + runAsUser: 0 + runAsGroup: 10000 + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /pulsar/data/bookkeeper/journal + name: journal + - mountPath: /pulsar/data/bookkeeper/ledgers + name: ledgers + - name: scripts + mountPath: /kb-scripts + - name: bookies-env + mountPath: /opt/pulsar/none + - name: pulsar-bookies-config + mountPath: /opt/pulsar/conf \ No newline at end of file diff --git a/addons/pulsar/templates/cmpd-broker.yaml b/addons/pulsar/templates/cmpd-broker-2.yaml similarity index 61% rename from addons/pulsar/templates/cmpd-broker.yaml rename to addons/pulsar/templates/cmpd-broker-2.yaml index aaff6fde9..5f2f789ec 100644 --- a/addons/pulsar/templates/cmpd-broker.yaml +++ b/addons/pulsar/templates/cmpd-broker-2.yaml @@ -1,19 +1,31 @@ apiVersion: apps.kubeblocks.io/v1 kind: ComponentDefinition metadata: - name: pulsar-broker-{{include "pulsar.major.version" .}} + name: {{ include "pulsar2.brokerCmpdName" . }} labels: - {{- include "pulsar.labels" . | nindent 4 }} + {{- include "pulsar.labels" . | nindent 4 }} + annotations: + {{- include "pulsar.annotations" . | nindent 4 }} spec: provider: kubeblocks - description: Pulsar broker. + description: Pulsar broker component definition serviceKind: pulsar - serviceVersion: {{ default .Chart.AppVersion .Values.clusterVersionOverride }} + serviceVersion: {{ .Values.defaultServiceVersion.broker.major2 }} vars: + - name: CLUSTER_NAMESPACE + valueFrom: + clusterVarRef: + namespace: Required + - name: CLUSTER_NAME + valueFrom: + clusterVarRef: + clusterName: Required + - name: CLUSTER_DOMAIN + value: {{ .Values.clusterDomain }} - name: ADVERTISED_PORT_PULSAR valueFrom: serviceVarRef: - compDef: pulsar-broker-{{include "pulsar.major.version" .}} + compDef: {{ include "pulsar2.brokerCmpdRegexPattern" . }} name: advertised-listener optional: true port: @@ -22,12 +34,18 @@ spec: - name: ADVERTISED_PORT_KAFKA valueFrom: serviceVarRef: - compDef: pulsar-broker-{{include "pulsar.major.version" .}} + compDef: {{ include "pulsar2.brokerCmpdRegexPattern" . }} name: advertised-listener optional: true port: name: kafka-client option: Optional + - name: BROKER_COMPONENT_NAME + valueFrom: + componentVarRef: + compDef: {{ include "pulsar2.brokerCmpdRegexPattern" . }} + optional: false + componentName: Required services: - name: advertised-listener serviceName: advertised-listener @@ -51,9 +69,9 @@ spec: updateStrategy: BestEffortParallel configs: - name: broker-env - templateRef: {{ include "pulsar.name" . }}-broker-env-tpl + templateRef: {{ include "pulsar.brokerEnvTplName" . }} namespace: {{ .Release.Namespace }} - constraintRef: pulsar-env-constraints + constraintRef: {{ include "pulsar.envConstraintName" . }} keys: - conf injectEnvTo: @@ -64,16 +82,19 @@ spec: reRenderResourceTypes: - vscale - name: broker-config - templateRef: {{ include "pulsar.name" . }}{{include "pulsar.major.version" .}}-broker-config-tpl + templateRef: {{ include "pulsar2.brokerConfigTplName" . }} namespace: {{ .Release.Namespace }} - constraintRef: pulsar{{include "pulsar.major.version" .}}-brokers-cc + constraintRef: {{ include "pulsar2.brokerConfigConstraintName" . }} volumeName: pulsar-config scripts: - name: pulsar-scripts - templateRef: {{ include "pulsar.name" . }}-scripts + templateRef: {{ include "pulsar.scriptsTplName" . }} namespace: {{ .Release.Namespace }} volumeName: scripts defaultMode: 0555 + exporter: + scrapePath: /metrics/ + scrapePort: http runtime: securityContext: runAsNonRoot: true @@ -82,8 +103,8 @@ spec: runAsGroup: 0 initContainers: - name: init-broker-cluster - image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.v3_0_2.broker "root" .) }}" - imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.v3_0_2.broker "root" .) }}" + image: {{ include "pulsar2.brokerImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} command: - /kb-scripts/init-broker.sh env: @@ -94,23 +115,44 @@ spec: value: DEBUG {{- end }} - name: brokerServiceUrl - value: pulsar://$(KB_CLUSTER_NAME)-broker-bootstrap.$(KB_NAMESPACE).svc{{ .Values.clusterDomain }}:6650 + value: pulsar://$(CLUSTER_NAME)-broker-bootstrap.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):6650 - name: clusterName - value: $(KB_NAMESPACE)-$(KB_CLUSTER_COMP_NAME) + value: $(CLUSTER_NAMESPACE)-$(BROKER_COMPONENT_NAME) - name: webServiceUrl - value: http://$(KB_CLUSTER_NAME)-broker-bootstrap.$(KB_NAMESPACE).svc{{ .Values.clusterDomain }}:80 + value: http://$(CLUSTER_NAME)-broker-bootstrap.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):80 + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_HOST_IP + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: status.hostIP volumeMounts: - name: scripts mountPath: /kb-scripts - name: init-sysctl - image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.v3_0_2.broker "root" .) }}" - imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.v3_0_2.broker "root" .) }}" + image: {{ include "pulsar2.brokerImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} command: - /kb-scripts/init-broker-sysctl.sh securityContext: privileged: true runAsNonRoot: false runAsUser: 0 + env: + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_HOST_IP + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: status.hostIP volumeMounts: - name: scripts mountPath: /kb-scripts @@ -125,8 +167,8 @@ spec: - ALL privileged: false runAsGroup: 0 - image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.v3_0_2.broker "root" .) }}" - imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.v3_0_2.broker "root" .) }}" + image: {{ include "pulsar2.brokerImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} command: - /kb-scripts/start-broker.sh resources: @@ -141,19 +183,27 @@ spec: value: DEBUG {{- end }} - name: clusterName - value: $(KB_NAMESPACE)-$(KB_CLUSTER_COMP_NAME) + value: $(CLUSTER_NAMESPACE)-$(BROKER_COMPONENT_NAME) - name: SERVICE_PORT value: "8080" - name: brokerServiceUrl - value: pulsar://$(KB_CLUSTER_NAME)-broker-bootstrap.$(KB_NAMESPACE).svc{{ .Values.clusterDomain }}:6650 + value: pulsar://$(CLUSTER_NAME)-broker-bootstrap.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):6650 - name: webServiceUrl - value: http://$(KB_CLUSTER_NAME)-broker-bootstrap.$(KB_NAMESPACE).svc{{ .Values.clusterDomain }}:80 + value: http://$(CLUSTER_NAME)-broker-bootstrap.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):80 - name: POD_NAME - value: $(KB_POD_NAME) + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_HOST_IP + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: status.hostIP - name: PULSAR_PREFIX_internalListenerName value: cluster - name: PULSAR_PREFIX_advertisedListeners - value: cluster:pulsar://$(POD_NAME).$(KB_CLUSTER_COMP_NAME)-headless.$(KB_NAMESPACE).svc{{ .Values.clusterDomain }}:6650 + value: cluster:pulsar://$(POD_NAME).$(BROKER_COMPONENT_NAME)-headless.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):6650 # KoP configs: # https://github.com/streamnative/kop/blob/branch-3.0.0.4/docs/configuration.md#configuration - name: PULSAR_PREFIX_allowAutoTopicCreationType @@ -163,7 +213,7 @@ spec: - name: PULSAR_PREFIX_kafkaListeners value: CLIENT://0.0.0.0:9092 - name: PULSAR_PREFIX_kafkaAdvertisedListeners - value: CLIENT://$(POD_NAME).$(KB_CLUSTER_COMP_NAME)-headless.$(KB_NAMESPACE).svc{{ .Values.clusterDomain }}:9092 + value: CLIENT://$(POD_NAME).$(BROKER_COMPONENT_NAME)-headless.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):9092 ports: - name: pulsar containerPort: 6650 @@ -208,6 +258,3 @@ spec: mountPath: /opt/pulsar/conf - name: broker-env mountPath: /opt/pulsar/none - exporter: - scrapePath: /metrics/ - scrapePort: http diff --git a/addons/pulsar/templates/cmpd-broker-3.yaml b/addons/pulsar/templates/cmpd-broker-3.yaml new file mode 100644 index 000000000..30612eeec --- /dev/null +++ b/addons/pulsar/templates/cmpd-broker-3.yaml @@ -0,0 +1,260 @@ +apiVersion: apps.kubeblocks.io/v1 +kind: ComponentDefinition +metadata: + name: {{ include "pulsar3.brokerCmpdName" . }} + labels: + {{- include "pulsar.labels" . | nindent 4 }} + annotations: + {{- include "pulsar.annotations" . | nindent 4 }} +spec: + provider: kubeblocks + description: Pulsar broker component definition + serviceKind: pulsar + serviceVersion: {{ .Values.defaultServiceVersion.broker.major3 }} + vars: + - name: CLUSTER_NAMESPACE + valueFrom: + clusterVarRef: + namespace: Required + - name: CLUSTER_NAME + valueFrom: + clusterVarRef: + clusterName: Required + - name: CLUSTER_DOMAIN + value: {{ .Values.clusterDomain }} + - name: ADVERTISED_PORT_PULSAR + valueFrom: + serviceVarRef: + compDef: {{ include "pulsar3.brokerCmpdRegexPattern" . }} + name: advertised-listener + optional: true + port: + name: pulsar + option: Optional + - name: ADVERTISED_PORT_KAFKA + valueFrom: + serviceVarRef: + compDef: {{ include "pulsar3.brokerCmpdRegexPattern" . }} + name: advertised-listener + optional: true + port: + name: kafka-client + option: Optional + - name: BROKER_COMPONENT_NAME + valueFrom: + componentVarRef: + compDef: {{ include "pulsar3.brokerCmpdRegexPattern" . }} + optional: false + componentName: Required + services: + - name: advertised-listener + serviceName: advertised-listener + podService: true + disableAutoProvision: true + spec: + type: NodePort + ports: + - name: pulsar + port: 6650 + targetPort: pulsar + - name: kafka-client + port: 9092 + targetPort: kafka-client + serviceRefDeclarations: + - name: pulsarZookeeper + serviceRefDeclarationSpecs: + - serviceKind: zookeeper + serviceVersion: ^3.8.\d{1,2}$ + optional: true + updateStrategy: BestEffortParallel + configs: + - name: broker-env + templateRef: {{ include "pulsar.brokerEnvTplName" . }} + namespace: {{ .Release.Namespace }} + constraintRef: {{ include "pulsar.envConstraintName" . }} + keys: + - conf + injectEnvTo: + - init-broker-cluster + - broker + - init-pulsar-client-config + volumeName: broker-env + reRenderResourceTypes: + - vscale + - name: broker-config + templateRef: {{ include "pulsar3.brokerConfigTplName" . }} + namespace: {{ .Release.Namespace }} + constraintRef: {{ include "pulsar3.brokerConfigConstraintName" . }} + volumeName: pulsar-config + scripts: + - name: pulsar-scripts + templateRef: {{ include "pulsar.scriptsTplName" . }} + namespace: {{ .Release.Namespace }} + volumeName: scripts + defaultMode: 0555 + exporter: + scrapePath: /metrics/ + scrapePort: http + runtime: + securityContext: + runAsNonRoot: true + runAsUser: 10000 + fsGroup: 0 + runAsGroup: 0 + initContainers: + - name: init-broker-cluster + image: {{ include "pulsar3.brokerImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + command: + - /kb-scripts/init-broker.sh + env: + {{- if .Values.debugEnabled }} + - name: PULSAR_LOG_ROOT_LEVEL + value: DEBUG + - name: PULSAR_LOG_LEVEL + value: DEBUG + {{- end }} + - name: brokerServiceUrl + value: pulsar://$(CLUSTER_NAME)-broker-bootstrap.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):6650 + - name: clusterName + value: $(CLUSTER_NAMESPACE)-$(BROKER_COMPONENT_NAME) + - name: webServiceUrl + value: http://$(CLUSTER_NAME)-broker-bootstrap.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):80 + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_HOST_IP + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: status.hostIP + volumeMounts: + - name: scripts + mountPath: /kb-scripts + - name: init-sysctl + image: {{ include "pulsar3.brokerImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + command: + - /kb-scripts/init-broker-sysctl.sh + securityContext: + privileged: true + runAsNonRoot: false + runAsUser: 0 + env: + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_HOST_IP + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: status.hostIP + volumeMounts: + - name: scripts + mountPath: /kb-scripts + containers: + - name: broker + securityContext: + allowPrivilegeEscalation: false + runAsNonRoot: true + runAsUser: 10000 + capabilities: + drop: + - ALL + privileged: false + runAsGroup: 0 + image: {{ include "pulsar3.brokerImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + command: + - /kb-scripts/start-broker.sh + resources: + requests: + cpu: 200m + memory: 512Mi + env: + {{- if .Values.debugEnabled }} + - name: PULSAR_LOG_ROOT_LEVEL + value: DEBUG + - name: PULSAR_LOG_LEVEL + value: DEBUG + {{- end }} + - name: clusterName + value: $(CLUSTER_NAMESPACE)-$(BROKER_COMPONENT_NAME) + - name: SERVICE_PORT + value: "8080" + - name: brokerServiceUrl + value: pulsar://$(CLUSTER_NAME)-broker-bootstrap.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):6650 + - name: webServiceUrl + value: http://$(CLUSTER_NAME)-broker-bootstrap.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):80 + - name: POD_NAME + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: metadata.name + - name: POD_HOST_IP + valueFrom: + fieldRef: + apiVersion: v1 + fieldPath: status.hostIP + - name: PULSAR_PREFIX_internalListenerName + value: cluster + - name: PULSAR_PREFIX_advertisedListeners + value: cluster:pulsar://$(POD_NAME).$(BROKER_COMPONENT_NAME)-headless.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):6650 + # KoP configs: + # https://github.com/streamnative/kop/blob/branch-3.0.0.4/docs/configuration.md#configuration + - name: PULSAR_PREFIX_allowAutoTopicCreationType + value: partitioned + - name: PULSAR_PREFIX_kafkaProtocolMap + value: "CLIENT:PLAINTEXT" + - name: PULSAR_PREFIX_kafkaListeners + value: CLIENT://0.0.0.0:9092 + - name: PULSAR_PREFIX_kafkaAdvertisedListeners + value: CLIENT://$(POD_NAME).$(BROKER_COMPONENT_NAME)-headless.$(CLUSTER_NAMESPACE).svc.$(CLUSTER_DOMAIN):9092 + ports: + - name: pulsar + containerPort: 6650 + - name: http + containerPort: 8080 + - name: kafka-client + containerPort: 9092 + livenessProbe: + failureThreshold: 30 + httpGet: + path: /status.html + port: http + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 100 + readinessProbe: + failureThreshold: 3 + httpGet: + path: /status.html + port: http + scheme: HTTP + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 100 + startupProbe: + failureThreshold: 30 + httpGet: + path: /status.html + port: http + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 100 + volumeMounts: + - name: scripts + mountPath: /kb-scripts + - name: pulsar-config + mountPath: /opt/pulsar/conf + - name: broker-env + mountPath: /opt/pulsar/none diff --git a/addons/pulsar/templates/cmpd-proxy.yaml b/addons/pulsar/templates/cmpd-proxy-2.yaml similarity index 76% rename from addons/pulsar/templates/cmpd-proxy.yaml rename to addons/pulsar/templates/cmpd-proxy-2.yaml index 80de60989..6b33859fd 100644 --- a/addons/pulsar/templates/cmpd-proxy.yaml +++ b/addons/pulsar/templates/cmpd-proxy-2.yaml @@ -1,14 +1,16 @@ apiVersion: apps.kubeblocks.io/v1 kind: ComponentDefinition metadata: - name: pulsar-proxy-{{include "pulsar.major.version" .}} + name: {{ include "pulsar2.proxyCmpdName" . }} labels: - {{- include "pulsar.labels" . | nindent 4 }} + {{- include "pulsar.labels" . | nindent 4 }} + annotations: + {{- include "pulsar.annotations" . | nindent 4 }} spec: provider: kubeblocks - description: Pulsar proxy. + description: Pulsar proxy component definition serviceKind: pulsar - serviceVersion: {{ default .Chart.AppVersion .Values.clusterVersionOverride }} + serviceVersion: {{ .Values.defaultServiceVersion.proxy.major2 }} serviceRefDeclarations: - name: pulsarZookeeper serviceRefDeclarationSpecs: @@ -18,10 +20,10 @@ spec: updateStrategy: BestEffortParallel configs: - name: proxy-env - templateRef: {{ include "pulsar.name" . }}-proxy-env-tpl + templateRef: {{ include "pulsar.proxyEnvTplName" . }} namespace: {{ .Release.Namespace }} volumeName: proxy-env - constraintRef: pulsar-env-constraints + constraintRef: {{ include "pulsar.envConstraintName" . }} keys: - conf injectEnvTo: @@ -30,16 +32,29 @@ spec: reRenderResourceTypes: - vscale - name: proxy-config - templateRef: {{ include "pulsar.name" . }}{{include "pulsar.major.version" .}}-proxy-config-tpl + templateRef: {{ include "pulsar2.proxyConfigTplName" . }} namespace: {{ .Release.Namespace }} volumeName: pulsar-proxy-config - constraintRef: pulsar{{include "pulsar.major.version" .}}-proxy-cc + constraintRef: {{ include "pulsar2.proxyConfigConstraintName" . }} scripts: - name: pulsar-scripts - templateRef: {{ include "pulsar.name" . }}-scripts + templateRef: {{ include "pulsar.scriptsTplName" . }} namespace: {{ .Release.Namespace }} volumeName: scripts defaultMode: 0555 + exporter: + scrapePath: /metrics/ + scrapePort: http + vars: + - name: CLUSTER_NAMESPACE + valueFrom: + clusterVarRef: + namespace: Required + - name: PROXY_COMPONENT_NAME + valueFrom: + componentVarRef: + optional: false + componentName: Required runtime: securityContext: runAsNonRoot: true @@ -48,8 +63,8 @@ spec: runAsGroup: 0 initContainers: - name: check-broker - image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.v3_0_2.proxy "root" .) }}" - imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.v3_0_2.proxy "root" .) }}" + image: {{ include "pulsar2.proxyImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} command: - /kb-scripts/init-proxy.sh volumeMounts: @@ -66,8 +81,8 @@ spec: {{- end }} containers: - name: proxy - image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.v3_0_2.proxy "root" .) }}" - imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.v3_0_2.proxy "root" .) }}" + image: {{ include "pulsar2.proxyImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} command: - /kb-scripts/start-proxy.sh securityContext: @@ -89,7 +104,7 @@ spec: - name: SERVICE_PORT value: "8080" - name: clusterName - value: $(KB_NAMESPACE)-$(KB_CLUSTER_COMP_NAME) + value: $(CLUSTER_NAMESPACE)-$(PROXY_COMPONENT_NAME) - name: webServicePort value: "8080" ## in order to avoid the kb complex service association logic involved when using brokers, @@ -142,6 +157,3 @@ spec: mountPath: /opt/pulsar/none - name: pulsar-proxy-config mountPath: /opt/pulsar/conf - exporter: - scrapePath: /metrics/ - scrapePort: http diff --git a/addons/pulsar/templates/cmpd-proxy-3.yaml b/addons/pulsar/templates/cmpd-proxy-3.yaml new file mode 100644 index 000000000..4174dfdc9 --- /dev/null +++ b/addons/pulsar/templates/cmpd-proxy-3.yaml @@ -0,0 +1,159 @@ +apiVersion: apps.kubeblocks.io/v1 +kind: ComponentDefinition +metadata: + name: {{ include "pulsar3.proxyCmpdName" . }} + labels: + {{- include "pulsar.labels" . | nindent 4 }} + annotations: + {{- include "pulsar.annotations" . | nindent 4 }} +spec: + provider: kubeblocks + description: Pulsar proxy component definition + serviceKind: pulsar + serviceVersion: {{ .Values.defaultServiceVersion.proxy.major3 }} + serviceRefDeclarations: + - name: pulsarZookeeper + serviceRefDeclarationSpecs: + - serviceKind: zookeeper + serviceVersion: ^3.8.\d{1,2}$ + optional: true + updateStrategy: BestEffortParallel + configs: + - name: proxy-env + templateRef: {{ include "pulsar.proxyEnvTplName" . }} + namespace: {{ .Release.Namespace }} + volumeName: proxy-env + constraintRef: {{ include "pulsar.envConstraintName" . }} + keys: + - conf + injectEnvTo: + - proxy + - check-broker + reRenderResourceTypes: + - vscale + - name: proxy-config + templateRef: {{ include "pulsar3.proxyConfigTplName" . }} + namespace: {{ .Release.Namespace }} + volumeName: pulsar-proxy-config + constraintRef: {{ include "pulsar3.proxyConfigConstraintName" . }} + scripts: + - name: pulsar-scripts + templateRef: {{ include "pulsar.scriptsTplName" . }} + namespace: {{ .Release.Namespace }} + volumeName: scripts + defaultMode: 0555 + exporter: + scrapePath: /metrics/ + scrapePort: http + vars: + - name: CLUSTER_NAMESPACE + valueFrom: + clusterVarRef: + namespace: Required + - name: PROXY_COMPONENT_NAME + valueFrom: + componentVarRef: + optional: false + componentName: Required + runtime: + securityContext: + runAsNonRoot: true + runAsUser: 10000 + fsGroup: 0 + runAsGroup: 0 + initContainers: + - name: check-broker + image: {{ include "pulsar3.proxyImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + command: + - /kb-scripts/init-proxy.sh + volumeMounts: + - name: scripts + mountPath: /kb-scripts + - name: proxy-env + mountPath: /opt/pulsar/none + env: + {{- if .Values.debugEnabled }} + - name: PULSAR_LOG_ROOT_LEVEL + value: DEBUG + - name: PULSAR_LOG_LEVEL + value: DEBUG + {{- end }} + containers: + - name: proxy + image: {{ include "pulsar3.proxyImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + command: + - /kb-scripts/start-proxy.sh + securityContext: + allowPrivilegeEscalation: false + runAsNonRoot: true + runAsUser: 10000 + capabilities: + drop: + - ALL + privileged: false + runAsGroup: 0 + env: + {{- if .Values.debugEnabled }} + - name: PULSAR_LOG_ROOT_LEVEL + value: DEBUG + - name: PULSAR_LOG_LEVEL + value: DEBUG + {{- end }} + - name: SERVICE_PORT + value: "8080" + - name: clusterName + value: $(CLUSTER_NAMESPACE)-$(PROXY_COMPONENT_NAME) + - name: webServicePort + value: "8080" + ## in order to avoid the kb complex service association logic involved when using brokers, + ## zk-based service discovery is used here to build the proxy. + ## but this is not secure to use service discovery(https://pulsar.apache.org/docs/3.0.x/administration-proxy/#use-service-discovery). + ## Todo: it needs to be iterated into the broker address in subsequent versions. +{{/* - name: brokerWebServiceURL*/}} +{{/* value: http://$(brokerSVC):80*/}} +{{/* - name: brokerServiceURL*/}} +{{/* value: pulsar://$(brokerSVC):6650*/}} + ports: + - name: pulsar + containerPort: 6650 + - name: http + containerPort: 8080 + livenessProbe: + failureThreshold: 3 + httpGet: + path: /status.html + port: http + scheme: HTTP + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 100 + readinessProbe: + failureThreshold: 3 + httpGet: + path: /status.html + port: http + scheme: HTTP + initialDelaySeconds: 30 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 100 + startupProbe: + failureThreshold: 20 + httpGet: + path: /status.html + port: http + scheme: HTTP + initialDelaySeconds: 5 + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 100 + volumeMounts: + - name: scripts + mountPath: /kb-scripts + - name: proxy-env + mountPath: /opt/pulsar/none + - name: pulsar-proxy-config + mountPath: /opt/pulsar/conf diff --git a/addons/pulsar/templates/cmpd-zookeeper.yaml b/addons/pulsar/templates/cmpd-zookeeper-2.yaml similarity index 75% rename from addons/pulsar/templates/cmpd-zookeeper.yaml rename to addons/pulsar/templates/cmpd-zookeeper-2.yaml index 61d7afa1b..6749a5744 100644 --- a/addons/pulsar/templates/cmpd-zookeeper.yaml +++ b/addons/pulsar/templates/cmpd-zookeeper-2.yaml @@ -1,31 +1,42 @@ apiVersion: apps.kubeblocks.io/v1 kind: ComponentDefinition metadata: - name: pulsar-zookeeper-{{include "pulsar.major.version" .}} + name: {{ include "pulsar2.zookeeperCmpdName" . }} labels: - {{- include "pulsar.labels" . | nindent 4 }} + {{- include "pulsar.labels" . | nindent 4 }} + annotations: + {{- include "pulsar.annotations" . | nindent 4 }} spec: provider: kubeblocks - description: Pulsar zookeeper. + description: Pulsar zookeeper component definition serviceKind: pulsar - serviceVersion: {{ default .Chart.AppVersion .Values.clusterVersionOverride }} + serviceVersion: {{ .Values.defaultServiceVersion.zookeeper.major2 }} updateStrategy: BestEffortParallel configs: - name: zookeeper-env - templateRef: {{ include "pulsar.name" . }}-zookeeper-env-tpl + templateRef: {{ include "pulsar.zookeeperEnvTplName" . }} namespace: {{ .Release.Namespace }} volumeName: zookeeper-config-env - constraintRef: pulsar-env-constraints + constraintRef: {{ include "pulsar.envConstraintName" . }} keys: - conf injectEnvTo: - zookeeper scripts: - name: pulsar-scripts - templateRef: {{ include "pulsar.name" . }}-scripts + templateRef: {{ include "pulsar.scriptsTplName" . }} namespace: {{ .Release.Namespace }} volumeName: scripts defaultMode: 0555 + exporter: + scrapePath: /metrics + scrapePort: http + vars: + - name: ZK_POD_NAME_LIST + valueFrom: + componentVarRef: + optional: true + podNames: Required runtime: securityContext: fsGroup: 0 @@ -34,8 +45,8 @@ spec: runAsUser: 10000 containers: - name: zookeeper - image: "{{ template "pulsar.imageFullName" (dict "image" .Values.images.v3_0_2.zookeeper "root" .) }}" - imagePullPolicy: "{{ template "pulsar.imagePullPolicy" (dict "image" .Values.images.v3_0_2.zookeeper "root" .) }}" + image: {{ include "pulsar2.zookeeperImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} command: - /kb-scripts/start-zookeeper.sh env: @@ -94,7 +105,4 @@ spec: - name: scripts mountPath: /kb-scripts - name: zookeeper-config-env - mountPath: /opt/pulsar/none - exporter: - scrapePath: /metrics - scrapePort: http + mountPath: /opt/pulsar/none \ No newline at end of file diff --git a/addons/pulsar/templates/cmpd-zookeeper-3.yaml b/addons/pulsar/templates/cmpd-zookeeper-3.yaml new file mode 100644 index 000000000..e0520dc95 --- /dev/null +++ b/addons/pulsar/templates/cmpd-zookeeper-3.yaml @@ -0,0 +1,108 @@ +apiVersion: apps.kubeblocks.io/v1 +kind: ComponentDefinition +metadata: + name: {{ include "pulsar3.zookeeperCmpdName" . }} + labels: + {{- include "pulsar.labels" . | nindent 4 }} + annotations: + {{- include "pulsar.annotations" . | nindent 4 }} +spec: + provider: kubeblocks + description: Pulsar zookeeper component definition + serviceKind: pulsar + serviceVersion: {{ .Values.defaultServiceVersion.zookeeper.major3 }} + updateStrategy: BestEffortParallel + configs: + - name: zookeeper-env + templateRef: {{ include "pulsar.zookeeperEnvTplName" . }} + namespace: {{ .Release.Namespace }} + volumeName: zookeeper-config-env + constraintRef: {{ include "pulsar.envConstraintName" . }} + keys: + - conf + injectEnvTo: + - zookeeper + scripts: + - name: pulsar-scripts + templateRef: {{ include "pulsar.scriptsTplName" . }} + namespace: {{ .Release.Namespace }} + volumeName: scripts + defaultMode: 0555 + exporter: + scrapePath: /metrics + scrapePort: http + vars: + - name: ZK_POD_NAME_LIST + valueFrom: + componentVarRef: + optional: true + podNames: Required + runtime: + securityContext: + fsGroup: 0 + runAsGroup: 0 + runAsNonRoot: true + runAsUser: 10000 + containers: + - name: zookeeper + image: {{ include "pulsar3.zookeeperImage" . }} + imagePullPolicy: {{ default "IfNotPresent" .Values.image.pullPolicy }} + command: + - /kb-scripts/start-zookeeper.sh + env: + {{- if .Values.debugEnabled }} + - name: PULSAR_LOG_ROOT_LEVEL + value: DEBUG + - name: PULSAR_LOG_LEVEL + value: DEBUG + {{- end }} + - name: SERVICE_PORT + value: "8000" + - name: EXTERNAL_PROVIDED_SERVERS + value: "false" + - name: OPTS + value: "-Dlog4j2.formatMsgNoLookups=true" + ports: + - name: client + containerPort: 2181 + - name: tcp-quorum + containerPort: 2888 + - name: tcp-election + containerPort: 3888 + - name: http + containerPort: 8000 + livenessProbe: + exec: + command: + - bash + - -c + - echo ruok | nc -q 1 localhost 2181 | grep imok + failureThreshold: 10 + initialDelaySeconds: 5 + periodSeconds: 30 + successThreshold: 1 + timeoutSeconds: 30 + resources: + requests: + cpu: 50m + memory: 256Mi + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + privileged: false + runAsGroup: 0 + runAsNonRoot: true + runAsUser: 10000 + terminationMessagePath: /dev/termination-log + terminationMessagePolicy: File + volumeMounts: + - mountPath: /pulsar/data + name: data + - mountPath: /pulsar/data-log + name: data-log + - name: scripts + mountPath: /kb-scripts + - name: zookeeper-config-env + mountPath: /opt/pulsar/none \ No newline at end of file diff --git a/addons/pulsar/templates/cmpv-bkrecovery.yaml b/addons/pulsar/templates/cmpv-bkrecovery.yaml index e3dc959cd..55bad7583 100644 --- a/addons/pulsar/templates/cmpv-bkrecovery.yaml +++ b/addons/pulsar/templates/cmpv-bkrecovery.yaml @@ -1,13 +1,14 @@ apiVersion: apps.kubeblocks.io/v1 kind: ComponentVersion metadata: - name: pulsar-bkrecovery + name: pulsar-bookies-recovery labels: {{- include "pulsar.labels" . | nindent 4 }} spec: compatibilityRules: - compDefs: - - pulsar-bkrecovery + ## regex pattern for bookies recovery component definition match pulsar 2.X and 3.X + - {{ include "pulsar.bkRecoveryCmpdRegexPattern" . }} releases: - 2.11.2 - 3.0.2 diff --git a/addons/pulsar/templates/cmpv-bookkeeper.yaml b/addons/pulsar/templates/cmpv-bookkeeper.yaml index c02d4ab61..ee61be41b 100644 --- a/addons/pulsar/templates/cmpv-bookkeeper.yaml +++ b/addons/pulsar/templates/cmpv-bookkeeper.yaml @@ -7,7 +7,8 @@ metadata: spec: compatibilityRules: - compDefs: - - pulsar-bookkeeper + ## regex pattern for bookkeeper component definition match pulsar 2.X and 3.X + - {{ include "pulsar.bookkeeperCmpdRegexPattern" . }} releases: - 2.11.2 - 3.0.2 diff --git a/addons/pulsar/templates/cmpv-broker.yaml b/addons/pulsar/templates/cmpv-broker.yaml index 6390f399e..48d270f91 100644 --- a/addons/pulsar/templates/cmpv-broker.yaml +++ b/addons/pulsar/templates/cmpv-broker.yaml @@ -7,7 +7,7 @@ metadata: spec: compatibilityRules: - compDefs: - - pulsar-broker + - {{ include "pulsar.brokerCmpdRegexPattern" . }} releases: - 2.11.2 - 3.0.2 diff --git a/addons/pulsar/templates/cmpv-proxy.yaml b/addons/pulsar/templates/cmpv-proxy.yaml index 95adc0b41..be1e9fae4 100644 --- a/addons/pulsar/templates/cmpv-proxy.yaml +++ b/addons/pulsar/templates/cmpv-proxy.yaml @@ -7,7 +7,7 @@ metadata: spec: compatibilityRules: - compDefs: - - pulsar-proxy + - {{ include "pulsar.proxyCmpdRegexPattern" . }} releases: - 2.11.2 - 3.0.2 diff --git a/addons/pulsar/templates/cmpv-zookeeper.yaml b/addons/pulsar/templates/cmpv-zookeeper.yaml index d67ba96e9..7ade17f46 100644 --- a/addons/pulsar/templates/cmpv-zookeeper.yaml +++ b/addons/pulsar/templates/cmpv-zookeeper.yaml @@ -7,7 +7,7 @@ metadata: spec: compatibilityRules: - compDefs: - - pulsar-zookeeper + - {{ include "pulsar.zookeeperCmpdRegexPattern" . }} releases: - 2.11.2 - 3.0.2 diff --git a/addons/pulsar/templates/config/bookies-configmap.yaml b/addons/pulsar/templates/config/bookies-env-configmap.yaml similarity index 76% rename from addons/pulsar/templates/config/bookies-configmap.yaml rename to addons/pulsar/templates/config/bookies-env-configmap.yaml index 2a26e575c..811d3641a 100644 --- a/addons/pulsar/templates/config/bookies-configmap.yaml +++ b/addons/pulsar/templates/config/bookies-env-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}-bookies-env-tpl + name: {{ include "pulsar.bookiesEnvTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: diff --git a/addons/pulsar/templates/config/bookies-recovery-configmap.yaml b/addons/pulsar/templates/config/bookies-recovery-env-configmap.yaml similarity index 75% rename from addons/pulsar/templates/config/bookies-recovery-configmap.yaml rename to addons/pulsar/templates/config/bookies-recovery-env-configmap.yaml index 20776a8e2..805ee789d 100644 --- a/addons/pulsar/templates/config/bookies-recovery-configmap.yaml +++ b/addons/pulsar/templates/config/bookies-recovery-env-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}-recovery-env-tpl + name: {{ include "pulsar.bookiesRecoveryEnvTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: diff --git a/addons/pulsar/templates/config/broker-configmap.yaml b/addons/pulsar/templates/config/broker-env-configmap.yaml similarity index 76% rename from addons/pulsar/templates/config/broker-configmap.yaml rename to addons/pulsar/templates/config/broker-env-configmap.yaml index 38ea80e31..74644456f 100644 --- a/addons/pulsar/templates/config/broker-configmap.yaml +++ b/addons/pulsar/templates/config/broker-env-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}-broker-env-tpl + name: {{ include "pulsar.brokerEnvTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: diff --git a/addons/pulsar/templates/config/proxy-configmap.yaml b/addons/pulsar/templates/config/proxy-env-configmap.yaml similarity index 77% rename from addons/pulsar/templates/config/proxy-configmap.yaml rename to addons/pulsar/templates/config/proxy-env-configmap.yaml index a971e782f..81bfc1d6e 100644 --- a/addons/pulsar/templates/config/proxy-configmap.yaml +++ b/addons/pulsar/templates/config/proxy-env-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}-proxy-env-tpl + name: {{ include "pulsar.proxyEnvTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: diff --git a/addons/pulsar/templates/config/pulsar-tools-configmap.yaml b/addons/pulsar/templates/config/pulsar-tools-configmap.yaml index 9dbd0cedc..09749da72 100644 --- a/addons/pulsar/templates/config/pulsar-tools-configmap.yaml +++ b/addons/pulsar/templates/config/pulsar-tools-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: pulsar-tools-script + name: {{ include "pulsar.toolsScriptsTplName" . }} data: update-dynamic-config.sh: | #!/bin/sh diff --git a/addons/pulsar/templates/config/pulsar2-config-configmap.yaml b/addons/pulsar/templates/config/pulsar2-config-configmap.yaml index 4adc16a8a..a42965380 100644 --- a/addons/pulsar/templates/config/pulsar2-config-configmap.yaml +++ b/addons/pulsar/templates/config/pulsar2-config-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}2-broker-config-tpl + name: {{ include "pulsar2.brokerConfigTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: @@ -18,7 +18,7 @@ data: apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}2-bookies-config-tpl + name: {{ include "pulsar2.bookiesConfigTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: @@ -30,7 +30,7 @@ data: apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}2-proxy-config-tpl + name: {{ include "pulsar2.proxyConfigTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: diff --git a/addons/pulsar/templates/config/pulsar3-config-configmap.yaml b/addons/pulsar/templates/config/pulsar3-config-configmap.yaml index 711e276a9..3863e915f 100644 --- a/addons/pulsar/templates/config/pulsar3-config-configmap.yaml +++ b/addons/pulsar/templates/config/pulsar3-config-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}3-broker-config-tpl + name: {{ include "pulsar3.brokerConfigTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: @@ -18,7 +18,7 @@ data: apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}3-bookies-config-tpl + name: {{ include "pulsar3.bookiesConfigTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: @@ -30,7 +30,7 @@ data: apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}3-proxy-config-tpl + name: {{ include "pulsar3.proxyConfigTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: diff --git a/addons/pulsar/templates/config/zookeeper-configmap.yaml b/addons/pulsar/templates/config/zookeeper-env-configmap.yaml similarity index 76% rename from addons/pulsar/templates/config/zookeeper-configmap.yaml rename to addons/pulsar/templates/config/zookeeper-env-configmap.yaml index 759cbac8c..826fe5f5f 100644 --- a/addons/pulsar/templates/config/zookeeper-configmap.yaml +++ b/addons/pulsar/templates/config/zookeeper-env-configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}-zookeeper-env-tpl + name: {{ include "pulsar.zookeeperEnvTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: diff --git a/addons/pulsar/templates/configconstraints.yaml b/addons/pulsar/templates/configconstraints.yaml index 535e21927..21695e670 100644 --- a/addons/pulsar/templates/configconstraints.yaml +++ b/addons/pulsar/templates/configconstraints.yaml @@ -1,7 +1,7 @@ apiVersion: apps.kubeblocks.io/v1beta1 kind: ConfigConstraint metadata: - name: pulsar-env-constraints + name: {{ include "pulsar.envConstraintName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} spec: @@ -12,28 +12,13 @@ spec: fileFormatConfig: format: yaml ---- -apiVersion: apps.kubeblocks.io/v1beta1 -kind: ConfigConstraint -metadata: - name: pulsar-common-constraints - labels: - {{- include "pulsar.labels" . | nindent 4 }} -spec: - parametersSchema: - cue: "" - - # pulsar configuration file format - fileFormatConfig: - format: props-plus - --- {{- $cc := .Files.Get "config/2.11.2/broker-config-effect-scope.yaml" | fromYaml }} apiVersion: apps.kubeblocks.io/v1beta1 kind: ConfigConstraint metadata: - name: pulsar2-brokers-cc + name: {{ include "pulsar2.brokerConfigConstraintName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} spec: @@ -91,7 +76,7 @@ spec: apiVersion: apps.kubeblocks.io/v1beta1 kind: ConfigConstraint metadata: - name: pulsar3-brokers-cc + name: {{ include "pulsar3.brokerConfigConstraintName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} spec: @@ -148,7 +133,7 @@ spec: apiVersion: apps.kubeblocks.io/v1beta1 kind: ConfigConstraint metadata: - name: pulsar2-bookies-cc + name: {{ include "pulsar2.bookiesConfigConstraintName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} spec: @@ -165,7 +150,7 @@ spec: apiVersion: apps.kubeblocks.io/v1beta1 kind: ConfigConstraint metadata: - name: pulsar3-bookies-cc + name: {{ include "pulsar3.bookiesConfigConstraintName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} spec: @@ -182,7 +167,7 @@ spec: apiVersion: apps.kubeblocks.io/v1beta1 kind: ConfigConstraint metadata: - name: pulsar2-proxy-cc + name: {{ include "pulsar2.proxyConfigConstraintName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} spec: @@ -199,7 +184,7 @@ spec: apiVersion: apps.kubeblocks.io/v1beta1 kind: ConfigConstraint metadata: - name: pulsar3-proxy-cc + name: {{ include "pulsar3.proxyConfigConstraintName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} spec: diff --git a/addons/pulsar/templates/scripts.yaml b/addons/pulsar/templates/scripts.yaml index 15f5f1200..212e31317 100644 --- a/addons/pulsar/templates/scripts.yaml +++ b/addons/pulsar/templates/scripts.yaml @@ -1,8 +1,12 @@ apiVersion: v1 kind: ConfigMap metadata: - name: {{ include "pulsar.name" . }}-scripts + name: {{ include "pulsar.scriptsTplName" . }} labels: {{- include "pulsar.labels" . | nindent 4 }} data: + common.sh: |- + #!/bin/bash + {{- include "kblib.compvars.get_target_pod_fqdn_from_pod_fqdn_vars" $ | nindent 4 }} + {{- include "kblib.strings.is_empty" $ | nindent 4 }} {{- include "pulsar.extend.scripts" . | nindent 2 }} \ No newline at end of file diff --git a/addons/pulsar/values.yaml b/addons/pulsar/values.yaml index 58d76a82c..fb6c21974 100644 --- a/addons/pulsar/values.yaml +++ b/addons/pulsar/values.yaml @@ -1,14 +1,8 @@ # Default values for Pulsar. -clusterVersionOverride: "" nameOverride: "" -fullnameOverride: "" - -## @param commonLabels Labels to add to all deployed objects -## -commonLabels: {} -commonAnnotations: {} +fullnameOverride: "" ## @param debugEnabled # @@ -44,8 +38,8 @@ images: v2_11_2: bookie: repository: apecloud/pulsar - pullPolicy: "" - tag: "" + pullPolicy: IfNotPresent + tag: 2.11.2 zookeeper: # Zookeeper component is used for metadata, shouldn't need update following tag value for common @@ -95,8 +89,25 @@ metrics: service: port: 1234 - -clusterDomain: ".cluster.local" +clusterDomain: "cluster.local" # cloud provider: ["aws","gcp","aliyun","tencentCloud", "huaweiCloud", "azure"] -cloudProvider: "" \ No newline at end of file +cloudProvider: "" + +## @param define default serviceVersion of each Component +defaultServiceVersion: + recovery: + major2: "2.11.2" + major3: "3.0.2" + bookkeeper: + major2: "2.11.2" + major3: "3.0.2" + broker: + major2: "2.11.2" + major3: "3.0.2" + proxy: + major2: "2.11.2" + major3: "3.0.2" + zookeeper: + major2: "2.11.2" + major3: "3.0.2" \ No newline at end of file diff --git a/examples/pulsar/cluster-cmpd.yaml b/examples/pulsar/cluster-cmpd.yaml index 5159474a8..298156352 100644 --- a/examples/pulsar/cluster-cmpd.yaml +++ b/examples/pulsar/cluster-cmpd.yaml @@ -107,7 +107,7 @@ spec: requests: storage: 20Gi - name: bookies-recovery - componentDef: pulsar-bkrecovery + componentDef: pulsar-bookies-recovery replicas: 1 resources: limits: