Last active
May 11, 2020 22:13
-
-
Save maiamcc/4336a0ef15ff3cb77faa2cdeb6872d5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Description: | |
# First, install the Strimzi Kafka operator resources. | |
# | |
# Then apply CLUSTER_YAML which defines a Kafka custom resource; this creates the following pods: | |
# - cluster-kafka-0 | |
# - cluster-zookeeper-[0-2] | |
# - strimzi-cluster-operator-[hash] | |
# | |
# These pods must be ready for a dependent service (stubbed out here as busybox). | |
# | |
# Upon running 'tilt up', the operator is applied and the cluster is created. No pod id or logs ever | |
# show up under the 'cluster' resource, even if that resource or the Tiltfile itself is refreshed. | |
# Therefore, 'cluster' is always in the Pending state and busybox1 never starts. However, upon | |
# exiting tilt and running 'tilt up' again, the 'cluster' pods are linked and everything goes into | |
# the Running state. | |
ns_yaml = """ | |
apiVersion: v1 | |
kind: Namespace | |
metadata: | |
name: kafka | |
""" | |
k8s_yaml(blob(ns_yaml)) | |
strimzi_yaml = local("curl -L -s https://strimzi.io/install/latest?namespace=kafka", quiet = True) | |
k8s_yaml(strimzi_yaml) | |
k8s_resource("strimzi-cluster-operator", resource_deps=["uncategorized"]) | |
k8s_kind("Kafka") # CRD for the Strimzi cluster operator | |
CLUSTER_YAML = """ | |
apiVersion: kafka.strimzi.io/v1beta1 | |
kind: Kafka | |
metadata: | |
name: cluster | |
namespace: kafka | |
spec: | |
kafka: | |
version: 2.4.0 | |
replicas: 1 | |
listeners: | |
plain: {} | |
config: | |
offsets.topic.replication.factor: 1 | |
transaction.state.log.replication.factor: 1 | |
transaction.state.log.min.isr: 1 | |
log.message.format.version: "2.4" | |
storage: | |
type: ephemeral | |
zookeeper: | |
replicas: 3 | |
storage: | |
type: ephemeral | |
entityOperator: | |
topicOperator: {} | |
userOperator: {} | |
""" | |
k8s_yaml(blob(CLUSTER_YAML)) | |
k8s_resource( | |
workload = "cluster", | |
extra_pod_selectors = { | |
"strimzi.io/cluster": "cluster", | |
"strimzi.io/kind": "Kafka", | |
}, | |
resource_deps = ["strimzi-cluster-operator"], | |
) | |
TEST_YAML = """ | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
name: busybox1 | |
namespace: kafka | |
labels: | |
app: busybox1 | |
spec: | |
containers: | |
- image: busybox | |
command: | |
- sleep | |
- "3600" | |
imagePullPolicy: IfNotPresent | |
name: busybox | |
restartPolicy: Always | |
""" | |
k8s_yaml(blob(TEST_YAML)) | |
k8s_resource("busybox1", resource_deps = ["cluster"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment