Skip to content

Conversation

qclaogui
Copy link
Contributor

@qclaogui qclaogui commented Jun 14, 2021

Signed-off-by: Weifeng Wang [email protected]

What this PR does:

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.

cortex-kustomize provides a common base for Blocks Storage deployment to Kubernetes. People should Create variants using overlays to deploy Cortex 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).

Example

This is an example of monitoring Cortex by adding prometheus and grafana using kustomize

  1. Create development Environment

    mkdir -p deploy/overlays/dev

  1. Create kustomization.yaml

    apiVersion: kustomize.config.k8s.io/v1beta1
    kind: Kustomization
    
    namespace: cortex-monitoring-system
    
    resources:
    - github.com/qclaogui/cortex-kustomize/deploy/base/blocks?ref=main
    - add-grafana-dep.yaml
    - add-grafana-svc.yaml
    - add-retrieval-dep.yaml
    - add-retrieval-svc.yaml
    
    patchesStrategicMerge:
    - patch-nginx-svc.yaml
    
    images:
    - name: quay.io/cortexproject/cortex
     newTag: master-b6eea5f
    - name: minio/minio
     newTag: RELEASE.2021-06-17T00-10-46Z

File structure:

└── deploy
   └── overlays
       └── dev
           ├── add-grafana-dep.yaml
           ├── add-grafana-svc.yaml
           ├── add-retrieval-dep.yaml
           ├── add-retrieval-svc.yaml
           ├── kustomization.yaml
           └── patch-nginx-svc.yaml
  1. Deploy to a cluster

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

More example detailed https://github.com/qclaogui/cortex-kustomize-demo.

Happy Cortex
Which issue(s) this PR fixes:

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: Weifeng Wang <[email protected]>
@bboreham
Copy link
Contributor

Thank you for this PR.

We have generally not added configuration solutions to the Cortex repo since different people like different tools, hence https://github.com/cortexproject/cortex-helm-chart and https://github.com/grafana/cortex-jsonnet/ are in separate repos.
Also #4268 removes the config we do have, in k8s.

So my first reaction is this should also go in its own repo.

Wherever it does end up, the "usage" documentation would need to be visible in the repo, not just in the PR.

@qclaogui
Copy link
Contributor Author

Hey @bboreham Thanks for your reply, It sounds make sense to put it in a separate repo. I am looking into it during the weekends.

@qclaogui
Copy link
Contributor Author

I have moved the files to a separate repo called cortex-kustomize.

@qclaogui qclaogui closed this Jun 19, 2021
@qclaogui qclaogui deleted the add-kustomize-support branch June 19, 2021 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants