Prerequisites

Registry Credential

When building a function, you’ll need to push your function container image to a container registry like Docker Hub or Quay.io. To do that you’ll need to generate a secret for your container registry first.

You can create this secret by filling in the REGISTRY_SERVER, REGISTRY_USER and REGISTRY_PASSWORD fields, and then run the following command.

  1. REGISTRY_SERVER=https://index.docker.io/v1/
  2. REGISTRY_USER=<your_registry_user>
  3. REGISTRY_PASSWORD=<your_registry_password>
  4. kubectl create secret docker-registry push-secret \
  5. --docker-server=$REGISTRY_SERVER \
  6. --docker-username=$REGISTRY_USER \
  7. --docker-password=$REGISTRY_PASSWORD

Kafka

Async functions can be triggered by events in message queues like Kafka, here you can find steps to setup a Kafka cluster for demo purpose.

  1. Install strimzi-kafka-operator in the default namespace.

    1. helm repo add strimzi https://strimzi.io/charts/
    2. helm install kafka-operator -n default strimzi/strimzi-kafka-operator
  2. Run the following command to create a Kafka cluster and Kafka Topic in the default namespace. The Kafka and Zookeeper clusters created by this command have a storage type of ephemeral and are demonstrated using emptyDir.

    Here we create a 1-replica Kafka server named <kafka-server> and a 1-replica topic named <kafka-topic> with 10 partitions

    1. cat <<EOF | kubectl apply -f -
    2. apiVersion: kafka.strimzi.io/v1beta2
    3. kind: Kafka
    4. metadata:
    5. name: <kafka-server>
    6. namespace: default
    7. spec:
    8. kafka:
    9. version: 3.1.0
    10. replicas: 1
    11. listeners:
    12. - name: plain
    13. port: 9092
    14. type: internal
    15. tls: false
    16. - name: tls
    17. port: 9093
    18. type: internal
    19. tls: true
    20. config:
    21. offsets.topic.replication.factor: 1
    22. transaction.state.log.replication.factor: 1
    23. transaction.state.log.min.isr: 1
    24. default.replication.factor: 1
    25. min.insync.replicas: 1
    26. inter.broker.protocol.version: "3.1"
    27. storage:
    28. type: ephemeral
    29. zookeeper:
    30. replicas: 1
    31. storage:
    32. type: ephemeral
    33. entityOperator:
    34. topicOperator: {}
    35. userOperator: {}
    36. ---
    37. apiVersion: kafka.strimzi.io/v1beta2
    38. kind: KafkaTopic
    39. metadata:
    40. name: <kafka-topic>
    41. namespace: default
    42. labels:
    43. strimzi.io/cluster: <kafka-server>
    44. spec:
    45. partitions: 10
    46. replicas: 1
    47. config:
    48. retention.ms: 7200000
    49. segment.bytes: 1073741824
    50. EOF
  3. Run the following command to check Pod status and wait for Kafka and Zookeeper to run and start.

    1. $ kubectl get po
    2. NAME READY STATUS RESTARTS AGE
    3. <kafka-server>-entity-operator-568957ff84-nmtlw 3/3 Running 0 8m42s
    4. <kafka-server>-kafka-0 1/1 Running 0 9m13s
    5. <kafka-server>-zookeeper-0 1/1 Running 0 9m46s
    6. strimzi-cluster-operator-687fdd6f77-cwmgm 1/1 Running 0 11m

    Run the following command to view the metadata for the Kafka cluster.

    1. $ kafkacat -L -b <kafka-server>-kafka-brokers:9092

Last modified June 19, 2022: Add quickstarts (#110) (0e5f9dd)