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

Use standard storage class by default, demonstrate kustomization per hosting provider #270

Merged
merged 21 commits into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
36903cf
Defaults to \”standard" storage class for all persistence
solsson May 3, 2019
8f949e4
With the new defaults there'll be no need for minikube storageclasses
solsson May 3, 2019
1bf9744
I haven't used Docker's k8s for a while but
solsson May 3, 2019
5ef2914
Overlays can be based on overlays
solsson May 3, 2019
ba342ee
Merge branch 'combine-kustomizations' into storagclass-kustomize
solsson May 3, 2019
ed0844c
Includes RBAC in variants
solsson May 3, 2019
44717ce
Replaces variant as-is with scale-[brokers]-[zks]
solsson May 3, 2019
d86263f
Regional, i.e. multi-zone, volumes for 2 of 5 zk pods is now a variant
solsson May 3, 2019
1d47004
Updates docs for removal of ./configure and status of apply -f
solsson May 3, 2019
d168b48
Migrates AWS and AKS examples from ./configure to overlays
solsson May 3, 2019
bebd7b8
Cool
solsson May 3, 2019
553f327
Quickstart shouldn't overwrite anything that exists
solsson May 3, 2019
02140ec
Kustomize is a good fit for maintaining a setup over time
solsson May 3, 2019
8a4db1f
Adds a variant with scale 1 + localhost listener + auto topic creation
solsson May 3, 2019
86e760e
Braches work too, if they are misspelt identically :)
solsson May 3, 2019
bfd64ca
Results in a "found conflict between different patches"
solsson May 6, 2019
94c5bed
Duplicates overrides to avoid a Kustomization conflict
solsson May 6, 2019
99fd504
Unsets the JMX_PORT env with the intention of making kafka lighter
solsson May 6, 2019
baa35cf
Reflects some new developments
solsson May 6, 2019
dc7a4a4
The new quickstart section replaces the old "fewer nodes"
solsson May 6, 2019
61555c3
Documents the apply flaw where it happens, see #269
solsson May 6, 2019
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
38 changes: 23 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ To quote [@arthurk](https://github.com/Yolean/kubernetes-kafka/issues/82#issueco
## Getting started

We suggest you `apply -f` manifests in the following order:
* Your choice of storage classes from [./configure](./configure/)
* [namespace](./00-namespace.yml)
* [./rbac-namespace-default](./rbac-namespace-default/)
* [./zookeeper](./zookeeper/)
* [./kafka](./kafka/)

That'll give you client "bootstrap" `bootstrap.kafka.svc.cluster.local:9092`.

With the introduction of [-k](#kustomize) support, apply `-f` will report `error: unable to decode "zookeeper/kustomization.yaml": Object 'Kind' is missing in ...`. With kubectl v1.14+ you can avoid that using: `kubectl apply -k variants/scale-3-5/`.

## Fork

Our only dependency is `kubectl`. Not because we dislike Helm or Operators, but because we think plain manifests make it easier to collaborate.
Expand All @@ -30,21 +31,35 @@ If you begin to rely on this kafka setup we recommend you fork, for example to e
With the introduction of [app customization](https://kubectl.docs.kubernetes.io/pages/app_customization/introduction.html) in `kubectl` 1.14 there's an alternative to forks. We as a community can maintain a set of overlays.

See the [variants](./variants) folder for different overlays. For example to scale to 1 kafka broker try `kubectl apply -k variants/scale-1/`.
Variants also include examples of how to configure volumes for GKE, AWS and AKS with different storage classes.

### Quickstart

Currently `apply -k` replaces `apply -f ./zookeeper; apply -f ./kafka`.
The original commands now result in `error: unable to decode "zookeeper/kustomization.yaml": Object 'Kind' is missing in ...`
and though they still seem to work you can get around that with a v1.14+ kubectl using: `kubectl apply -k variants/as-is/`.
```
kubectl create namespace kafka && \
kubectl apply -k github.com/Yolean/kubernetes-kafka/variants/dev-small/?ref=storagclass-kustomize
```

When all pods are Ready, test with for example `kafkacat -b localhost:9094 -L` over `kubectl -n kafka port-forward kafka-0 9094`.

### Maintaining your own kustomization

`kubectl apply -k` takes a single overlay, meaning that you can't compose different overlays from this repo.
You'll probably want to maintain your own variant.
One option is to keep kubernets-kafka as a git submodule and edit the relative path from an example variant.
Start your variant as a new folder in your choice of version control, with a base `kustomization.yaml` pointing to a tag or revision in this repository:

```
bases:
- github.com/Yolean/kubernetes-kafka/rbac-namespace-default/?ref=553f327
- github.com/Yolean/kubernetes-kafka/kafka/?ref=553f327
- github.com/Yolean/kubernetes-kafka/zookeeper/?ref=553f327
```

Then pick and chose from patches our [example variants](https://github.com/Yolean/kubernetes-kafka/tree/master/variants) to tailor your Kafka setup.

## Version history

| tag | k8s ≥ | highlights |
| ------ | ----- | ----------- |
| v6.0.0 | 1.11+ | Kafka 2.2.0 + `apply -k` (kubectl 1.14+) |
| v5.1.0 | 1.11+ | Kafka 2.1.1 |
| v5.0.3 | 1.11+ | Zookeeper fix [#227](https://github.com/Yolean/kubernetes-kafka/pull/227) + [maxClientCnxns=1](https://github.com/Yolean/kubernetes-kafka/pull/230#issuecomment-445953857) |
| v5.0 | 1.11+ | Destabilize because in Docker we want Java 11 [#197](https://github.com/Yolean/kubernetes-kafka/pull/197) [#191](https://github.com/Yolean/kubernetes-kafka/pull/191) |
Expand All @@ -61,21 +76,14 @@ Have a look at:
* [./linkedin-burrow](./linkedin-burrow/)
* [or plain JMX](https://github.com/Yolean/kubernetes-kafka/pull/96)
* what's happening in the [monitoring](https://github.com/Yolean/kubernetes-kafka/labels/monitoring) label.
* Note that this repo is intentionally light on [automation](https://github.com/Yolean/kubernetes-kafka/labels/automation). We think every SRE team must build the operational knowledge first.
* Note that this repo is intentionally light on [automation](https://github.com/Yolean/kubernetes-kafka/labels/automation). We think every SRE team must build the operational knowledge first. But there is an example of a [Cruise Control](./cruise-control/) setup.

## Outside (out-of-cluster) access

Available for:

* [Brokers](./outside-services/)

## Fewer than three nodes?

For [minikube](https://github.com/kubernetes/minikube/), [youkube](https://github.com/Yolean/youkube) etc:

* [Scale 1](https://github.com/Yolean/kubernetes-kafka/pull/44)
* [Scale 2](https://github.com/Yolean/kubernetes-kafka/pull/118)

## Stream...

* [Kubernetes events to Kafka](./events-kube/)
Expand Down
5 changes: 0 additions & 5 deletions configure/README.md

This file was deleted.

6 changes: 0 additions & 6 deletions configure/docker-storageclass-broker.yml

This file was deleted.

6 changes: 0 additions & 6 deletions configure/docker-storageclass-zookeeper.yml

This file was deleted.

21 changes: 0 additions & 21 deletions configure/minikube-storageclasses.yml

This file was deleted.

2 changes: 1 addition & 1 deletion kafka/50kafka.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ spec:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: kafka-broker
storageClassName: standard
resources:
requests:
storage: 10Gi
3 changes: 3 additions & 0 deletions rbac-namespace-default/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- node-reader.yml
- pod-labler.yml
7 changes: 7 additions & 0 deletions variants/aks-managed/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bases:
- ../scale-3-5
resources:
- aks-storageclass-broker-managed.yaml
- aks-storageclass-zookeeper-managed.yaml
patchesStrategicMerge:
- volume-claims.yaml
32 changes: 32 additions & 0 deletions variants/aks-managed/volume-claims.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kafka
namespace: kafka
spec:
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: kafka-broker
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: pzoo
namespace: kafka
spec:
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: kafka-zookeeper
resources:
requests:
storage: 1Gi
7 changes: 7 additions & 0 deletions variants/aws-gp2/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bases:
- ../scale-3-5
resources:
- aws-storageclass-broker-gp2.yaml
- aws-storageclass-zookeeper-gp2.yaml
patchesStrategicMerge:
- volume-claims.yaml
32 changes: 32 additions & 0 deletions variants/aws-gp2/volume-claims.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kafka
namespace: kafka
spec:
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: kafka-broker
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: pzoo
namespace: kafka
spec:
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: kafka-zookeeper
resources:
requests:
storage: 1Gi
8 changes: 8 additions & 0 deletions variants/dev-small/auto-create-topics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--override"},
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "advertised.listeners=PLAINTEXT://:9092,OUTSIDE://localhost:9094"},
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--override"},
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "auto.create.topics.enable=true"},
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--override"},
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "num.partitions=1"}
]
13 changes: 13 additions & 0 deletions variants/dev-small/jmx-disable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kafka
namespace: kafka
spec:
template:
spec:
containers:
- name: broker
env:
- name: JMX_PORT
value: ""
19 changes: 19 additions & 0 deletions variants/dev-small/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# With kubectl -n kafka port-forward kafka-0 9094
bases:
- ../scale-1-ephemeral
patchesStrategicMerge:
- jmx-disable.yaml
patchesJson6902:
# Currently these duplicate each others' directives to avoid an apply -k error: found conflict between different patches
- target:
group: apps
version: v1
kind: StatefulSet
name: kafka
path: listener-localhost.json
- target:
group: apps
version: v1
kind: StatefulSet
name: kafka
path: auto-create-topics.json
8 changes: 8 additions & 0 deletions variants/dev-small/listener-localhost.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--override"},
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "advertised.listeners=PLAINTEXT://:9092,OUTSIDE://localhost:9094"},
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--override"},
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "auto.create.topics.enable=true"},
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "--override"},
{"op": "add", "path": "/spec/template/spec/containers/0/command/-", "value": "num.partitions=1"}
]
8 changes: 8 additions & 0 deletions variants/gke-regional/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
bases:
- ../scale-3-5
resources:
- gke-storageclass-broker-pd.yaml
- gke-storageclass-zookeeper-ssd.yaml
- gke-storageclass-zookeeper-regional-euwest1cd-ssh.yaml
patchesStrategicMerge:
- volume-claims.yaml
48 changes: 48 additions & 0 deletions variants/gke-regional/volume-claims.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: kafka
namespace: kafka
spec:
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: kafka-broker
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: pzoo
namespace: kafka
spec:
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: kafka-zookeeper
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: zoo
namespace: kafka
spec:
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: kafka-zookeeper-regional
resources:
requests:
storage: 1Gi
1 change: 0 additions & 1 deletion variants/scale-1-ephemeral/kafka.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ metadata:
name: kafka
namespace: kafka
spec:
replicas: 1
template:
spec:
volumes:
Expand Down
10 changes: 1 addition & 9 deletions variants/scale-1-ephemeral/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
bases:
- ../../kafka
- ../../zookeeper
- ../scale-1
patchesStrategicMerge:
- kafka.yaml
- zookeeper.yaml
patchesJson6902:
- target:
group: apps
version: v1
kind: StatefulSet
name: kafka
path: kafka-scale1-overrides.json
23 changes: 4 additions & 19 deletions variants/scale-1-ephemeral/zookeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,8 @@ metadata:
name: pzoo
namespace: kafka
spec:
replicas: 1
template:
spec:
initContainers:
- name: init-config
env:
- name: PZOO_REPLICAS
value: '1'
- name: ZOO_REPLICAS
value: '0'
volumes:
- name: data
emptyDir: {}
Expand All @@ -32,16 +24,9 @@ metadata:
name: zoo
namespace: kafka
spec:
replicas: 0
template:
spec:
initContainers:
- name: init-config
env:
# There's no validation on these numbers adding up to a coherent zk config, so watch out
- name: PZOO_REPLICAS
value: '1'
- name: ZOO_REPLICAS
value: '0'
- name: ID_OFFSET
value: '2'
volumes:
- name: data
emptyDir: {}
volumeClaimTemplates: []
1 change: 1 addition & 0 deletions variants/scale-1/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bases:
- ../../rbac-namespace-default
- ../../kafka
- ../../zookeeper
patchesStrategicMerge:
Expand Down
Loading