Skip to content

Commit

Permalink
Feat: 🚀 Prepared addon for Kube-State-Matrics (#29)
Browse files Browse the repository at this point in the history
* feat: Prepared kube-state-metrics

* feat: remove unnecessary vars and tflint warnings

* fix: fix main.tf error, remove cluster name

* fix: update velero readme

* fix: update node group name and readme

* fix: remove useless resources

* fix: remove extra conf arg

* fix: remove dependency error
  • Loading branch information
nileshgadgi authored Sep 27, 2023
1 parent 1492bbd commit e2a1861
Show file tree
Hide file tree
Showing 19 changed files with 701 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- name: Generate TF Docs
uses: terraform-docs/gh-actions@v1.0.0
with:
working-dir: addons/aws-ebs-csi-driver,addons/aws-efs-csi-driver,addons/aws-load-balancer-controller,addons/aws-node-termination-handler,addons/calico-tigera,addons/cluster-autoscaler,addons/external-secrets,addons/fluent-bit,addons/helm,addons/ingress-nginx,addons/istio-ingress,addons/karpenter,addons/kiali-server,addons/kubeclarity,addons/metrics-server,addons/nri-bundle # config,modules/guardduty,modules/inspector
working-dir: addons/aws-ebs-csi-driver,addons/aws-efs-csi-driver,addons/aws-load-balancer-controller,addons/aws-node-termination-handler,addons/calico-tigera,addons/cluster-autoscaler,addons/external-secrets,addons/fluent-bit,addons/helm,addons/ingress-nginx,addons/istio-ingress,addons/karpenter,addons/kiali-server,addons/kubeclarity,addons/metrics-server,addons/nri-bundle,addons/velero,addons/kube-state-metrics
git-push: true
template: |-
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Expand Down
112 changes: 0 additions & 112 deletions .tflint.hcl

This file was deleted.

24 changes: 24 additions & 0 deletions _examples/complete/config/override-kube-state-matrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## Node affinity for particular node in which labels key is "Infra-Services" and value is "true"

affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "eks.amazonaws.com/nodegroup"
operator: In
values:
- "critical"


## Using limits and requests
resources:
limits:
cpu: 300m
memory: 250Mi
requests:
cpu: 50m
memory: 150Mi

podAnnotations:
co.elastic.logs/enabled: "true"
3 changes: 3 additions & 0 deletions _examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ module "addons" {
aws_node_termination_handler = true
aws_efs_csi_driver = true
aws_ebs_csi_driver = true
kube_state_metrics = true
# karpenter = false # -- Set to `false` or comment line to Uninstall Karpenter if installed using terraform.
calico_tigera = true
new_relic = true
Expand Down Expand Up @@ -192,6 +193,7 @@ module "addons" {
fluent_bit_helm_config = { values = [file("./config/override-fluent-bit.yaml")] }
velero_helm_config = { values = [file("./config/override-velero.yaml")] }
new_relic_helm_config = { values = [file("./config/override-new-relic.yaml")] }
kube_state_metrics_helm_config = { values = [file("./config/override-kube-state-matrics.yaml")] }

# -- Override Helm Release attributes
metrics_server_extra_configs = var.metrics_server_extra_configs
Expand All @@ -210,6 +212,7 @@ module "addons" {
fluent_bit_extra_configs = var.fluent_bit_extra_configs
velero_extra_configs = var.velero_extra_configs
new_relic_extra_configs = var.new_relic_extra_configs
kube_state_metrics_extra_configs = var.kube_state_metrics_extra_configs

# -- Custom IAM Policy Json for Addon's ServiceAccount
cluster_autoscaler_iampolicy_json_content = file("./custom-iam-policies/cluster-autoscaler.json")
Expand Down
5 changes: 5 additions & 0 deletions _examples/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,9 @@ variable "velero_extra_configs" {
variable "new_relic_extra_configs" {
type = any
default = {}
}

variable "kube_state_metrics_extra_configs" {
type = any
default = {}
}
25 changes: 25 additions & 0 deletions addons/kube-state-metrics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Kube-State-Metrics Helm Chart

kube-state-metrics (KSM) is a simple service that listens to the Kubernetes API server and generates metrics about the state of the objects. (See examples in the Metrics section below.) It is not focused on the health of the individual Kubernetes components, but rather on the health of the various objects inside, such as deployments, nodes and pods. Look into this [official Doc](https://github.com/kubernetes/kube-state-metrics) of Kube-State-Metrics for more further information.


## Installation
Below terraform script shows how to use External Secrets Terraform Addon, A complete example is also given [here](https://github.com/clouddrove/terraform-helm-eks-addons/blob/master/_examples/complete/main.tf).


```hcl
module "addons" {
source = "clouddrove/eks-addons/aws"
version = "0.0.6"
depends_on = [module.eks]
eks_cluster_name = module.eks.cluster_name
kube_state_metrics = true
kube_state_metrics_helm_config = { values = [file("./config/override-kube-state-matrics.yaml")] }
}
```


<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Loading

0 comments on commit e2a1861

Please sign in to comment.