Skip to content

MinIO and Koperator

Cesar Celis Hernandez edited this page Aug 8, 2022 · 21 revisions

Related links:

Objective:

Notify an image got uploaded via Kafka in k8s environment with Koperator and MinIO.

Steps:

  1. Create the cluster
kind delete clusters kind
kind delete clusters kind
kind create cluster --config ~/operator/testing/kind-config.yaml
  1. Install cert manager
kubectl create -f https://github.com/jetstack/cert-manager/releases/download/v1.6.2/cert-manager.yaml
  1. Install Zookeeper:
helm repo add pravega https://charts.pravega.io
helm repo update
helm install zookeeper-operator --namespace=zookeeper --create-namespace pravega/zookeeper-operator
kubectl create --namespace zookeeper -f - <<EOF
apiVersion: zookeeper.pravega.io/v1beta1
kind: ZookeeperCluster
metadata:
    name: zookeeper
    namespace: zookeeper
spec:
    replicas: 1
EOF
  1. Install Koperator:
kubectl create --validate=false -f https://github.com/banzaicloud/koperator/releases/download/v0.21.2/kafka-operator.crds.yaml
helm repo add banzaicloud-stable https://kubernetes-charts.banzaicloud.com/
helm repo update
helm install kafka-operator --namespace=kafka --create-namespace banzaicloud-stable/kafka-operator
  1. Create Kafka Cluster:
kubectl create -n kafka -f https://raw.githubusercontent.com/banzaicloud/koperator/master/config/samples/simplekafkacluster.yaml
  1. Create the topic:
cat << EOF | kubectl apply -n kafka -f -
apiVersion: kafka.banzaicloud.io/v1alpha1
kind: KafkaTopic
metadata:
    name: my-topic
spec:
    clusterRef:
        name: kafka
    name: my-topic
    partitions: 1
    replicationFactor: 1
    config:
        "retention.ms": "604800000"
        "cleanup.policy": "delete"
EOF
  1. Using Ubuntu Pod consume any notification:
root@ubuntu:/# kafkacat -C -b 10.244.1.4:29092 -t my-topic
  1. Install the MinIO Operator:
kubectl apply -k ~/operator/resources
  1. Install MinIO Tenant:
kubectl apply -k ~/operator/examples/kustomization/tenant-lite
  1. Using an Ubuntu Pod inside the cluster, configure Kafka notification, restart server and upload the image:
root@ubuntu:/# mc admin config set myminio notify_kafka:1 tls_skip_verify="off"  queue_dir="" queue_limit="0" sasl="off" sasl_password="" sasl_username="" tls_client_auth="0" tls="off" client_tls_cert="" client_tls_key="" brokers="10.244.1.4:29093" topic="my-topic" version="" --insecure
Successfully applied new settings.
Please restart your server 'mc admin service restart myminio'.
root@ubuntu:/# mc admin service restart myminio --insecure
Restart command successfully sent to `myminio`. Type Ctrl-C to quit or wait to follow the status of the restart process.
...
Restarted `myminio` successfully in 1 seconds
root@ubuntu:/# touch rose.jpg
echo "a" > rose.jpg
root@ubuntu:/# 
root@ubuntu:/# 
root@ubuntu:/# mc cp rose.jpg myminio/images --insecure
mc cp rose.jpg myminio/images --insecure
mc cp rose.jpg myminio/images --insecure
/rose.jpg:                                  2 B / 2 B ┃▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓┃ 30 B/s 0sroot@ubuntu:/# 
  1. Look at consumer, you should see the notification:
{"EventName":"s3:ObjectCreated:Put","Key":"images/rose.jpg","Records":[{"eventVersion":"2.0","eventSource":"minio:s3","awsRegion":"","eventTime":"2022-08-08T18:57:45.129Z","eventName":"s3:ObjectCreated:Put","userIdentity":{"principalId":"minio"},"requestParameters":{"principalId":"minio","region":"","sourceIPAddress":"10.244.2.19"},"responseElements":{"content-length":"0","x-amz-request-id":"1709739F2A493AB1","x-minio-deployment-id":"bba6bc73-d95c-4039-bb20-271ca323aec1","x-minio-origin-endpoint":"https://minio.tenant-lite.svc.cluster.local"},"s3":{"s3SchemaVersion":"1.0","configurationId":"Config","bucket":{"name":"images","ownerIdentity":{"principalId":"minio"},"arn":"arn:aws:s3:::images"},"object":{"key":"rose.jpg","size":2,"eTag":"60b725f10c9c85c70d97880dfe8191b3","contentType":"image/jpeg","userMetadata":{"content-type":"image/jpeg"},"sequencer":"1709739F2B7C7BC2"}},"source":{"host":"10.244.2.19","port":"","userAgent":"MinIO (linux; amd64) minio-go/v7.0.31 mc/RELEASE.2022-08-05T08-01-28Z"}}]}
Clone this wiki locally