Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:support kafka 2.7 using external zookeeper #1297

Merged
merged 9 commits into from
Dec 11, 2024

Conversation

lancelot1989
Copy link
Contributor

resolves #1296

@shanshanying
Copy link
Contributor

Hi @lancelot1989

thanks for your PR. we will review it ASAP.
PTAL @caiq1nyu

caiq1nyu
caiq1nyu previously approved these changes Dec 10, 2024
runAsNonRoot: true
runAsUser: 1001
command:
{{/* - sleep*/}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is better to remove the test code :)

Copy link
Contributor Author

@lancelot1989 lancelot1989 Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed,thanks for your remind

fieldRef:
apiVersion: v1
fieldPath: status.hostIP
- name: KAFKA_CFG_PROCESS_ROLES
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'Process role' is a concept in the kraft architecture. For 'cmpd-broker' of Kafka 2.7, this component is actually a certain 'broker', and this environment variable is not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

# Represents the endpoint of the service connection credential.
endpoint:
# your external zk endpoints here
value: "zookeeper-cluster-zookeeper-0.zookeeper-cluster-zookeeper-headless.default:2181,zookeeper-cluster-zookeeper-1.zookeeper-cluster-zookeeper-headless.default:2181,zookeeper-cluster-zookeeper-2.zookeeper-cluster-zookeeper-headless.default:2181/test"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. However, for scenarios where multiple clusters share zk, can we consider entrusting the control logic of metadata conflicts to addon instead of relying on specifying '/test' when defining ServiceDescriptor?

For example:

  • the only thing defined in ServiceDescriptor is the zk base address:
 endpoint:
    # your external zk endpoints here
    value: "zk-1.zookeeper-cluster-zookeeper-headless.default:2181"
  • an env defined in cmpd-broker such as: ZK_SUB_PATH=kafka1, the default value is KB_CLUSTER_NAME. Finally, in broker-env.tpl, KB_KAFKA_ZOOKEEPER_CONN will process into 'zk-1.zookeeper-cluster-zookeeper-headless.default:2181/kafka1'

The benefits of this in shared zk are:

  • Avoid defining a ServiceDescriptor cr for a set of kafka, but define one for each zk
  • The core configuration for controlling zk path conflicts is in the Kafka Cluster yaml, not the weakly controlled object ServiceDescriptor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good advice,using env KB_KAFKA_ZK_SUB_PATH

caiq1nyu
caiq1nyu previously approved these changes Dec 11, 2024
shanshanying
shanshanying previously approved these changes Dec 11, 2024
{{- else }}
{{- $zk_server = printf "%s-zookeeper.%s.svc:2181" $clusterName $namespace }}
{{- end }}
KB_KAFKA_ZOOKEEPER_CONN: {{ $zk_server }}
Copy link
Contributor

@Y-Rookie Y-Rookie Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to obtain KB_KAFKA_ZOOKEEPER_CONN through the cmpd.vars.serviceRefVarRef(Not serviceVarRef) API instead of using the built-in $.cluster and $.component variables, which is a deprecated approach.

Of course, we can update all deprecated references in a follow-up PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your remind, using cmpd.vars.serviceRefVarRef will be a more convenient way.

${__SOURCED__:+false} : || return 0

# main
start_server
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any significant differences in the startup method between Kafka 2.7 and the current versions? Is it necessary to maintain a separate startup script for 2.7? Can we reuse the existing one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too significant differences, but i think this new script maybe useful for kafka 2.x, and a separate script can keep the logic clean between 2.x and 3.x

- name: KAFKA_CFG_INTER_BROKER_LISTENER_NAME
value: "INTERNAL"
- name: KB_KAFKA_ZK_SUB_PATH
value: $(KB_CLUSTER_NAME)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove references to the built-in variable KB_CLUSTER_NAME. Please explicitly define CLUSTER_NAME through the Vars API before referencing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

zjx20
zjx20 previously approved these changes Dec 11, 2024
2. explicitly define CLUSTER_NAME through the Vars API
@lancelot1989 lancelot1989 dismissed stale reviews from zjx20, shanshanying, and caiq1nyu via 11dfbb4 December 11, 2024 06:33
@shanshanying
Copy link
Contributor

@lancelot1989 please rebase main branch.

@shanshanying shanshanying merged commit 68cd6cd into apecloud:main Dec 11, 2024
6 checks passed
@shanshanying
Copy link
Contributor

/cherry-pick release-1.0-beta

apecloud-bot pushed a commit that referenced this pull request Dec 11, 2024
Co-authored-by: lancelot1989 <[email protected]>
(cherry picked from commit 68cd6cd)
@apecloud-bot
Copy link
Collaborator

🤖 says: cherry pick action finished successfully 🎉!
See: https://github.com/apecloud/kubeblocks-addons/actions/runs/12274120092

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Features]support kafka 2.x using external zookeeper
6 participants