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

[ANSIENG-4245] | scram support in kraft (#49) #1795

Open
wants to merge 25 commits into
base: 7.8.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
259581a
[ANSIENG-4245] | poc for scram in kraft (#49)
mansi-jain-1206 Sep 25, 2024
183951b
Scram kraft ansieng 4245 (#58)
mansi-jain-1206 Oct 16, 2024
f970a44
[ANSIENG-4245] | added more test
mansi-jain-1206 Oct 16, 2024
599a00f
[ANSIENG-4245] | added more test
mansi-jain-1206 Oct 16, 2024
b47eceb
[ANSIENG-4245] | added sample inventory file
mansi-jain-1206 Oct 17, 2024
0bccff5
[ANSIENG-4245] | added sample inventory file
mansi-jain-1206 Oct 17, 2024
65bb151
[ANSIENG-4245] | add eol
mansi-jain-1206 Oct 18, 2024
03d870a
[ANSIENG-4245] | modified message
mansi-jain-1206 Oct 21, 2024
d1b3b84
[ANSIENG-4245] | modified message
mansi-jain-1206 Oct 21, 2024
1d2b043
[ANSIENG-4245] | validation fix
mansi-jain-1206 Oct 23, 2024
f6ca8d8
[ANSIENG-4245] | linting issue fix
mansi-jain-1206 Oct 23, 2024
a8b82da
[ANSIENG-4245] | modified test
mansi-jain-1206 Oct 24, 2024
6d29100
[ANSIENG-4245] | assertion fix
mansi-jain-1206 Oct 24, 2024
8977cb7
[ANSIENG-4245] | Merge remote-tracking branch 'refs/remotes/origin/7.…
mansi-jain-1206 Oct 24, 2024
4d49e89
[ANSIENG-4245] | remove empty line
mansi-jain-1206 Oct 24, 2024
d8cbc4e
[ANSIENG-4245] | update sample inventory
mansi-jain-1206 Oct 24, 2024
267ec06
[ANSIENG-4245] | added scram,kerberos scenario
mansi-jain-1206 Oct 24, 2024
1000126
[ANSIENG-4245] | added validation in multiple protocols PR
mansi-jain-1206 Oct 24, 2024
b101353
[ANSIENG-4245] | path fix
mansi-jain-1206 Oct 24, 2024
a73eea0
[ANSIENG-4245] | modified test for multiple broker protocol
mansi-jain-1206 Oct 24, 2024
73be25f
[ANSIENG-4245] | update validation
mansi-jain-1206 Oct 25, 2024
9667416
[ANSIENG-4245] | add eol
mansi-jain-1206 Oct 25, 2024
9c2b68c
[ANSIENG-4245] | code review fix
mansi-jain-1206 Oct 25, 2024
970827a
[ANSIENG-4245] | add migration sample for migration
mansi-jain-1206 Oct 25, 2024
b835424
[ANSIENG-4245] | add migration sample for scram
mansi-jain-1206 Oct 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions docs/sample_inventories/scram_kraft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
##
## The following is an example inventory file of the configuration required for setting up Confluent Platform with Kraft Controller with SCRAM.
## You can use any of the below approaches to setup SCRAM communication with Kraft. Same can be followed for migration as well.
## Option 1: This will set up controller-controller and controller-broker communication via plain and other communication via scram.
## Option 2: This will set up controller-controller via plain and other communication via scram.

all:
vars:
ansible_connection: ssh
ansible_user: ec2-user
ansible_become: true
ansible_ssh_private_key_file: /home/ec2-user/guest.pem
ansible_python_interpreter: /usr/bin/python3

ssl_enabled: true
sasl_protocol: scram

## Option 1
kafka_controller_sasl_protocol: plain,scram

kafka_controller:
vars:
## Option 2
kafka_controller_sasl_protocol: plain,scram
Copy link
Member

Choose a reason for hiding this comment

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

please create 2 separate inventory files for these cases instead of adding 2 options here. I think we can also ignore this one and recommend adding in all for simplicity

hosts:
ec2-35-160-193-90.us-west-2.compute.amazonaws.com:
ec2-35-85-219-150.us-west-2.compute.amazonaws.com:
ec2-34-219-169-190.us-west-2.compute.amazonaws.com:

kafka_broker:
hosts:
ec2-35-91-214-11.us-west-2.compute.amazonaws.com:
ec2-54-71-228-219.us-west-2.compute.amazonaws.com:
ec2-54-218-9-145.us-west-2.compute.amazonaws.com:

schema_registry:
hosts:
ec2-35-160-193-90.us-west-2.compute.amazonaws.com:

kafka_connect:
hosts:
ec2-35-85-219-150.us-west-2.compute.amazonaws.com:

kafka_rest:
hosts:
ec2-34-219-169-190.us-west-2.compute.amazonaws.com:

ksql:
hosts:
ec2-35-91-214-11.us-west-2.compute.amazonaws.com:

control_center:
hosts:
ec2-35-85-219-150.us-west-2.compute.amazonaws.com:
12 changes: 8 additions & 4 deletions molecule/archive-scram-rhel/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
driver:
name: docker
platforms:
- name: zookeeper1
hostname: zookeeper1.confluent
- name: ${KRAFT_CONTROLLER:-zookeeper}1
hostname: ${KRAFT_CONTROLLER:-zookeeper}1.confluent
groups:
- zookeeper
- ${CONTROLLER_HOSTGROUP:-zookeeper}
- ${CONTROLLER_HOSTGROUP:-zookeeper}_migration
image: oraclelinux:8-slim
dockerfile: ../Dockerfile-rhel-tar.j2
command: ""
Expand Down Expand Up @@ -94,11 +95,14 @@ platforms:
networks:
- name: confluent
provisioner:
playbooks:
converge: ${MIGRATION_CONVERGE:-../collections_converge.yml}
inventory:
group_vars:
all:
ssl_enabled: true
sasl_protocol: scram
sasl_protocol: scram256
kafka_controller_sasl_protocol: plain,scram256

installation_method: archive

Expand Down
4 changes: 4 additions & 0 deletions molecule/archive-scram-rhel/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@
- name: Create Custom User
user:
name: "{{archive_owner}}"

- name: Install Zookeeper Cluster
import_playbook: confluent.platform.all
when: lookup('env', 'MIGRATION')|default('false') == 'true'
21 changes: 21 additions & 0 deletions molecule/archive-scram-rhel/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,27 @@
- archive.stat.pw_name == 'cp-custom'
quiet: true

- name: Verify - kafka_controller
hosts: kafka_controller
gather_facts: false
tasks:
- import_role:
name: variables
- import_role:
name: confluent.test
tasks_from: check_property.yml
vars:
file_path: /opt/confluent/etc/controller/server.properties
property: sasl.enabled.mechanisms
expected_value: SCRAM-SHA-256,PLAIN
- import_role:
name: confluent.test
tasks_from: check_property.yml
vars:
file_path: /opt/confluent/etc/controller/server.properties
property: sasl.mechanism.controller.protocol
expected_value: PLAIN

- name: Verify - kafka_connect
hosts: kafka_connect
gather_facts: false
Expand Down
9 changes: 5 additions & 4 deletions molecule/oauth-rbac-mds-scram-custom-rhel/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ platforms:
privileged: true
networks:
- name: confluent
# MDS Zookeeper and Kafka
# MDS Controller, Zookeeper and Kafka
- name: mds-${KRAFT_CONTROLLER:-zookeeper}1
hostname: mds-${KRAFT_CONTROLLER:-zookeeper}1.confluent
groups:
Expand Down Expand Up @@ -86,10 +86,10 @@ platforms:
networks:
- name: confluent
# Cluster 2 goups, groupnames will be changed during converge phase
- name: zookeeper1
hostname: zookeeper1.confluent
- name: ${KRAFT_CONTROLLER:-zookeeper}1
hostname: ${KRAFT_CONTROLLER:-zookeeper}1.confluent
groups:
- zookeeper2
- ${KRAFT_CONTROLLER:-zookeeper}2
- cluster2
image: rockylinux:9-minimal
dockerfile: ../Dockerfile-rhel-java17.j2
Expand Down Expand Up @@ -216,6 +216,7 @@ provisioner:

ssl_enabled: true
sasl_protocol: scram
kafka_controller_sasl_protocol: plain,scram

ssl_custom_certs: true
ssl_ca_cert_filepath: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}/generated_ssl_files/ca.crt"
Expand Down
4 changes: 4 additions & 0 deletions molecule/oauth-rbac-mds-scram-custom-rhel/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,7 @@

- name: Install MDS Cluster
import_playbook: confluent.platform.all

- name: Install Zookeeper Cluster
import_playbook: confluent.platform.all
when: lookup('env', 'MIGRATION')|default('false') == 'true'
1 change: 1 addition & 0 deletions molecule/rbac-scram-custom-rhel-fips/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ provisioner:

ssl_enabled: true
sasl_protocol: scram
kafka_controller_sasl_protocol: plain,scram
ssl_custom_certs: true
ssl_ca_cert_filepath: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}/generated_ssl_files/ca.crt"
ssl_signed_cert_filepath: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}/generated_ssl_files/{{inventory_hostname}}-ca1-signed.crt"
Expand Down
4 changes: 4 additions & 0 deletions molecule/rbac-scram-custom-rhel-fips/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@

- name: Provision LDAP Server
import_playbook: ../ldap.yml

- name: Install Zookeeper Cluster
import_playbook: confluent.platform.all
when: lookup('env', 'MIGRATION')|default('false') == 'true'
21 changes: 21 additions & 0 deletions molecule/rbac-scram-custom-rhel-fips/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@
### Validates that FIPS is in use in OpenSSL.
### Validates that both the Connectors are Running

- name: Verify - kafka_controller
hosts: kafka_controller
gather_facts: false
tasks:
- import_role:
name: variables
- import_role:
name: confluent.test
tasks_from: check_property.yml
vars:
file_path: /etc/controller/server.properties
property: sasl.enabled.mechanisms
expected_value: SCRAM-SHA-512,PLAIN
- import_role:
name: confluent.test
tasks_from: check_property.yml
vars:
file_path: /etc/controller/server.properties
property: sasl.mechanism.controller.protocol
expected_value: PLAIN

- name: Verify - kafka_broker
hosts: kafka_broker
gather_facts: false
Expand Down
74 changes: 71 additions & 3 deletions molecule/scram-rhel/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,37 @@
driver:
name: docker
platforms:
- name: zookeeper1
hostname: zookeeper1.confluent
- name: ${KRAFT_CONTROLLER:-zookeeper}1
hostname: ${KRAFT_CONTROLLER:-zookeeper}1.confluent
groups:
- zookeeper
- ${CONTROLLER_HOSTGROUP:-zookeeper}
- ${CONTROLLER_HOSTGROUP:-zookeeper}_migration
image: redhat/ubi8-minimal
dockerfile: ../Dockerfile-rhel-java17.j2
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
networks:
- name: confluent
- name: ${KRAFT_CONTROLLER:-zookeeper}2
hostname: ${KRAFT_CONTROLLER:-zookeeper}2.confluent
groups:
- ${CONTROLLER_HOSTGROUP:-zookeeper}
- ${CONTROLLER_HOSTGROUP:-zookeeper}_migration
image: redhat/ubi8-minimal
dockerfile: ../Dockerfile-rhel-java17.j2
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
networks:
- name: confluent
- name: ${KRAFT_CONTROLLER:-zookeeper}3
hostname: ${KRAFT_CONTROLLER:-zookeeper}3.confluent
groups:
- ${CONTROLLER_HOSTGROUP:-zookeeper}
- ${CONTROLLER_HOSTGROUP:-zookeeper}_migration
image: redhat/ubi8-minimal
dockerfile: ../Dockerfile-rhel-java17.j2
command: ""
Expand Down Expand Up @@ -91,7 +118,45 @@ platforms:
- "9021:9021"
networks:
- name: confluent
- name: controller1-mig
hostname: controller1-mig.confluent
groups:
- kafka_controller_migration
image: redhat/ubi8-minimal
dockerfile: ../Dockerfile-rhel-java17.j2
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
networks:
- name: confluent
- name: controller2-mig
hostname: controller2-mig.confluent
groups:
- kafka_controller_migration
image: redhat/ubi8-minimal
dockerfile: ../Dockerfile-rhel-java17.j2
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
networks:
- name: confluent
- name: controller3-mig
hostname: controller3-mig.confluent
groups:
- kafka_controller_migration
image: redhat/ubi8-minimal
dockerfile: ../Dockerfile-rhel-java17.j2
command: ""
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true
networks:
- name: confluent
provisioner:
playbooks:
converge: ${MIGRATION_CONVERGE:-../collections_converge.yml}
inventory:
group_vars:
all:
Expand All @@ -106,3 +171,6 @@ provisioner:

schema_registry_kafka_listener_name: client
kafka_broker_configure_control_plane_listener: true

kafka_controller:
kafka_controller_sasl_protocol: plain,scram
3 changes: 3 additions & 0 deletions molecule/scram-rhel/prepare.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: Install Zookeeper Cluster
import_playbook: confluent.platform.all
when: lookup('env', 'MIGRATION')|default('false') == 'true'
22 changes: 21 additions & 1 deletion molecule/scram-rhel/verify.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
---
### Validates that SCRAM is enabled on all components.
### Validates that SCRAM is enabled on all components except kafka controller.
- name: Verify - kafka_controller
hosts: kafka_controller
gather_facts: false
tasks:
- import_role:
name: variables
- import_role:
name: confluent.test
tasks_from: check_property.yml
vars:
file_path: /etc/controller/server.properties
property: sasl.enabled.mechanisms
expected_value: SCRAM-SHA-512,SCRAM-SHA-256,PLAIN
- import_role:
name: confluent.test
tasks_from: check_property.yml
vars:
file_path: /etc/controller/server.properties
property: sasl.mechanism.controller.protocol
expected_value: PLAIN

- name: Verify - kafka_broker
hosts: kafka_broker
Expand Down
23 changes: 23 additions & 0 deletions roles/common/tasks/config_validations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,26 @@
fail_msg: "OAuth is not supported on FIPS enabled cluster yet. Please disable FIPS or OAuth to setup the cluster."
when: auth_mode == 'oauth' or auth_mode == 'ldap_with_oauth'
tags: validate

- assert:
that:
- hostvars[item]['kafka_controller_sasl_protocol'].replace(" ", "").split(',') | length > 1
- hostvars[item]['kafka_controller_sasl_protocol'].replace(" ", "").split(',')[0] not in ['scram', 'scram256']
fail_msg: "kafka_controller_sasl_protocol in kafka controller cannot have first value as scram or scram256 since inter-controller communication via SCRAM is not supported. Please use other protocols along with it."
loop: "{{ groups['kafka_controller'] }}"
when:
mansi-jain-1206 marked this conversation as resolved.
Show resolved Hide resolved
- ('kafka_controller' in groups.keys() and groups['kafka_controller'] | length > 1) | bool
mansi-jain-1206 marked this conversation as resolved.
Show resolved Hide resolved
- hostvars[item]['kafka_controller_sasl_protocol'] is defined
tags: validate

- assert:
that:
- "'scram' in ({{ hostvars[item]['kafka_controller_sasl_protocol'].replace(' ', '').split(',') }} ) or 'scram256' in ( {{ hostvars[item]['kafka_controller_sasl_protocol'].replace(' ', '').split(',') }} )"
- hostvars[item]['kafka_controller_sasl_protocol'].replace(" ", "").split(',') | length > 1
fail_msg: "kafka_controller_sasl_protocol in kafka broker must have multiple values defined if it has scram or scram256 as one of the protocols and kafka controller is present."
mansi-jain-1206 marked this conversation as resolved.
Show resolved Hide resolved
loop: "{{ groups['kafka_broker'] }}"
when:
- ('kafka_broker' in groups.keys() and groups['kafka_broker'] | length > 0) | bool
- ('kafka_controller' in groups.keys() and groups['kafka_controller'] | length > 1) | bool
- hostvars[item]['kafka_controller_sasl_protocol'] is defined
tags: validate
Loading