Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add Kustomize Support #233

Merged
merged 1 commit into from
Jun 28, 2021
Merged

Conversation

qclaogui
Copy link
Contributor

Signed-off-by: Weifeng Wang qclaogui@gmail.com

Add Kustomize Support

Kustomize background

Kustomize is a CNCF project that is a part of Kubernetes. It's included in
the kubectl in order to allow users to customize their configurations without introducing templates.

Usage

kustomize encourages defining multiple variants - e.g. dev, staging and prod, as overlays on a common base.

It’s possible to create an additional overlay to compose these variants together - just declare the overlays as the bases of a new kustomization.

deploy/base provides a common base for kafka_exporter deploy to Kubernetes. People should Create variants using overlays to deploy in their own environment.

An overlay is just another kustomization, referring to the base, and referring to patches to apply to that base.
This arrangement makes it easy to manage your configuration with git. The base could have files from an upstream repository managed by someone else. The overlays could be in a repository you own. Arranging the repo clones as siblings on disk avoids the need for git submodules (though that works fine, if you are a submodule fan).

Signed-off-by: Weifeng Wang <qclaogui@gmail.com>
ports:
- name: http-metrics
containerPort: 9308
protocol: TCP

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should set the kafka server endpoint?

@qclaogui
Copy link
Contributor Author

Hi @oldthreefeng, thanks for your reply.
We should try to keep the base simple, users could specify the configuration in the overlays environment. For example, I want to monitor a Kafka cluster in a dev environment:

  1. Create development Environment:
    mkdir -p deploy/overlays/dev && cd deploy/overlays/dev

  2. Create kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: kafka-exporter

resources:
- github.com/qclaogui/kafka_exporter/deploy/base?ref=add-kustomize-support

patchesStrategicMerge:
- patch_args.yaml

images:
- name: danielqsj/kafka-exporter
  newTag: v1.3.1
  1. Create patch_args.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: kafka-exporter
spec:
  template:
    spec:
      containers:
      - name: kafka-exporter
        args:
        - --log.level=debug
        - --log.enable-sarama
        - --kafka.version=2.6.1
        #  - --sasl.enabled
        #  - --no-sasl.handshake
        #  - --sasl.username=xxx
        #  - --sasl.password=xxx
        #  - --sasl.mechanism=scram-sha512
        #  - --tls.enabled
        #  - --tls.insecure-skip-tls-verify
        - --kafka.server=xxx:9092
        - --kafka.server=xxx:9092

File structure:

└── deploy
   └── overlays
       └── dev
           ├── kustomization.yaml
           └── patch_args.yaml
  1. Generate customized YAML with:

kustomize build deploy/overlays/dev > deploy/overlays/dev/deploy.yaml

or directly applied to a cluster:

kustomize build deploy/overlays/dev | kubectl apply -f -

@danielqsj
Copy link
Owner

/lgtm
thanks @qclaogui @oldthreefeng

@danielqsj danielqsj merged commit 962ebc8 into danielqsj:master Jun 28, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants