provider-kafka

module
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2024 License: Apache-2.0

README

provider-kafka

provider-kafka is a Crossplane Provider that is used to manage Kafka resources.

Usage

  1. Create a provider secret containing a json like the following, see expected schema here:

    {
      "brokers":[
        "kafka-dev-0.kafka-dev-headless:9092"
       ],
       "sasl":{
         "mechanism":"PLAIN",
         "username":"user",
         "password":"<your-password>"
       }
    }
    
  2. Create a k8s secret containing above config:

    kubectl -n crossplane-system create secret generic kafka-creds --from-file=credentials=kc.json
    
  3. Create a ProviderConfig, see this as an example.

  4. Create a managed resource see, see this for an example creating a Kafka topic.

Development

Setting up a Development Kafka Cluster

The following instructions will setup a development environment where you will have a locally running Kafka installation (SASL-Plain enabled). To change the configuration of your instance further, please see available helm parameters here.

  1. (Optional) Create a local kind cluster unless you want to develop against an existing k8s cluster.

  2. Install the Kafka helm chart:

    helm repo add bitnami https://charts.bitnami.com/bitnami
    kubectl create ns kafka-cluster
    helm upgrade --install kafka-dev -n kafka-cluster bitnami/kafka \
      --version 20.0.5 \
      --set auth.clientProtocol=sasl \
      --set deleteTopicEnable=true \
      --set authorizerClassName="kafka.security.authorizer.AclAuthorizer" \
      --wait
    

    Username is "user", obtain password using the following

    kubectl -n kafka-cluster exec kafka-dev-0 -- cat /opt/bitnami/kafka/config/kafka_jaas.conf
    

    Create the Kubernetes secret by adding a JSON filed called kc.json with the following contents

    {
       "brokers": [
          "kafka-dev-0.kafka-dev-headless:9092"
       ],
       "sasl": {
          "mechanism": "PLAIN",
          "username": "user",
          "password": "<password-you-obtained-in-step-2>"
       }
    }
    

    Once this file is created, apply it by running the following command

    kubectl -n kafka-cluster create secret generic kafka-creds --from-file=credentials=kc.json
    
  3. Install kubefwd.

  4. Run kubefwd for kafka-cluster namespace which will make internal k8s services locally accessible:

    sudo kubefwd svc -n kafka-cluster
    
  5. To run tests, export the KAFKA_PASSWORD environment variable using the password from step 2

    export KAFKA_PASSWORD="<password-you-obtained-in-step-2>"
    
  6. (optional) Install the kafka cli.

  7. (optional) Configure the kafka cli to talk against local Kafka installation:

    1. Create a config file for the client with the following content at ~/.kcl/config.toml:

      seed_brokers = ["kafka-dev-0.kafka-dev-headless:9092"]
      timeout_ms = 10000
      
      [sasl]
      method = "plain"
      user = "user"
      pass = "<password-you-obtained-in-step-2>"
      
      1. Verify that cli could talk to the Kafka cluster:
      export  KCL_CONFIG_DIR=~/.kcl
      
      kcl metadata --all
      
Building and Running the provider locally

Run against a Kubernetes cluster:

make run

Build, push, and install:

make all

Build image:

make image

Push image:

make push

Build binary:

make build

Directories

Path Synopsis
Package apis contains Kubernetes API for the Template provider.
Package apis contains Kubernetes API for the Template provider.
acl
Package acl contains group Sample API versions
Package acl contains group Sample API versions
acl/v1alpha1
Package v1alpha1 contains the v1alpha1 group Sample resources of the Template provider.
Package v1alpha1 contains the v1alpha1 group Sample resources of the Template provider.
topic
Package topic contains group Sample API versions
Package topic contains group Sample API versions
topic/v1alpha1
Package v1alpha1 contains the v1alpha1 group Sample resources of the Template provider.
Package v1alpha1 contains the v1alpha1 group Sample resources of the Template provider.
v1alpha1
Package v1alpha1 contains the core resources of the Template provider.
Package v1alpha1 contains the core resources of the Template provider.
cmd
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL