-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from sentoz/sidecar
add Sidecar mode
- Loading branch information
Showing
7 changed files
with
231 additions
and
30 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,10 @@ ARG JQ_VERSION="1.6" | |
|
||
LABEL maintainer="[email protected]" | ||
|
||
ENV SIDECAR_MODE=false | ||
ENV KAFKA_CONNECT_HOST=localhost | ||
ENV KAFKA_CONNECT_PORT=8083 | ||
|
||
ENV REQUEST_DELAY=30 | ||
|
||
RUN apk add --update --no-cache \ | ||
bash curl sort && \ | ||
|
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
- apiVersion: batch/v1beta1 | ||
kind: CronJob | ||
metadata: | ||
name: connector-restart-cronjob | ||
spec: | ||
schedule: "*/5 * * * *" | ||
jobTemplate: | ||
spec: | ||
template: | ||
metadata: | ||
labels: | ||
parent: "cronjob-connector-restart" | ||
spec: | ||
containers: | ||
- name: cronjob-connector-restart | ||
image: {IMAGE_URL} | ||
imagePullPolicy: IfNotPresent | ||
resources: | ||
limits: | ||
cpu: 10m | ||
memory: 10Mi | ||
requests: | ||
cpu: 50m | ||
memory: 50Mi | ||
env: | ||
- name: KAFKA_CONNECT_HOST | ||
value: 'kafka-connect' | ||
- name: KAFKA_CONNECT_PORT | ||
value: '8083' | ||
- name: SIDECAR_MODE | ||
value: 'false' | ||
restartPolicy: OnFailure |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
--- | ||
- kind: Deployment | ||
apiVersion: apps/v1 | ||
metadata: | ||
name: kafka-connect | ||
app: kafka-connect | ||
spec: | ||
strategy: | ||
type: Recreate | ||
triggers: | ||
- type: ConfigChange | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: kafka-connect | ||
template: | ||
metadata: | ||
labels: | ||
template: kafka-connect | ||
name: kafka-connect | ||
app: kafka | ||
spec: | ||
containers: | ||
- name: connector-restart | ||
image: {IMAGE_URL} | ||
env: | ||
- name: KAFKA_CONNECT_HOST | ||
value: localhost | ||
- name: KAFKA_CONNECT_PORT | ||
value: "8083" | ||
- name: REQUEST_DELAY | ||
value: "30" | ||
- name: SIDECAR_MODE | ||
value: "true" | ||
resources: | ||
limits: | ||
cpu: '10m' | ||
memory: '10Mi' | ||
requests: | ||
cpu: '50m' | ||
memory: '50Mi' | ||
- name: kafka-connect | ||
image: debezium/connect:1.4 | ||
ports: | ||
- containerPort: 8080 | ||
protocol: TCP | ||
- containerPort: 8443 | ||
protocol: TCP | ||
- containerPort: 7600 | ||
protocol: TCP | ||
- containerPort: 57600 | ||
protocol: TCP | ||
resources: | ||
limits: | ||
cpu: 500m | ||
memory: 1500Mi | ||
requests: | ||
cpu: 500m | ||
memory: 1500Mi | ||
env: | ||
- name: REST_HOST_NAME | ||
value: localhost | ||
... | ||
... | ||
... | ||
restartPolicy: Always | ||
dnsPolicy: ClusterFirst | ||
affinity: | ||
podAntiAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: app | ||
operator: In | ||
values: | ||
- kafka-connect | ||
namespaces: | ||
- NAMESPACE | ||
topologyKey: kubernetes.io/hostname | ||
enableServiceLinks: false |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Run in kubernetes as a cron job | ||
|
||
Here's how to set up a container to run in cron job mode. | ||
|
||
You can read about CronJobs in [doc](https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/) | ||
|
||
* [Run in kubernetes as a cron job](#run-in-kubernetes-as-a-cron-job) | ||
* [Configuring kafka connect](#configuring-kafka-connect) | ||
* [Deploy cron job](#deploy-cron-job) | ||
|
||
## Configuring kafka connect | ||
|
||
The main thing that needs to be done is: | ||
|
||
* create a service for kafka connect | ||
* ask the value of the `REST_HOST_NAME` variable is equal to the service name | ||
|
||
## Deploy cron job | ||
|
||
> ⚠️ **Attention!** ⚠️ | ||
> | ||
> This is an example to demonstrate how it works. | ||
> Do not do this in a production environment, | ||
> this is just an example. | ||
> | ||
> First, customize the manifest to suit your environment. | ||
```shell | ||
kubectl apply -n kube-dump -f deploy/cronjob.yaml | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Run in kubernetes as a sidecar container | ||
|
||
Here's how to set up a container to run in sidecar mode. | ||
|
||
You can read about sidecar in [doc](https://kubernetes.io/docs/concepts/workloads/pods/#workload-resources-for-managing-pods) | ||
|
||
* [Run in kubernetes as a sidecar container](#run-in-kubernetes-as-a-sidecar-container) | ||
* [Configuring kafka connect](#configuring-kafka-connect) | ||
* [Deploy sidecar](#deploy-sidecar) | ||
|
||
## Configuring kafka connect | ||
|
||
The main thing that needs to be done is: | ||
|
||
* ask the value of the `REST_HOST_NAME` variable is equal to the **localhost** | ||
|
||
## Deploy sidecar | ||
|
||
> ⚠️ **Attention!** ⚠️ | ||
> | ||
> This is an example to demonstrate how it works. | ||
> Do not do this in a production environment, | ||
> this is just an example. | ||
> | ||
> First, customize the manifest to suit your environment. | ||
```shell | ||
kubectl apply -n kube-dump -f deploy/sidecar.yaml | ||
``` |