Skip to content

Commit

Permalink
Feat: Introducing Grafana(7.0.2) and Prometheus(25.4.0) Addon (#44)
Browse files Browse the repository at this point in the history
* feat: introducing jaeger and prometheus

* update default override for testing

* ran terraform format command

* update ref branch in ci

* readme: Update add-on's readme

* update default setting for jaeger dependency

* readme: Update add-on's readme

* updated a jaeger with manifest file deployment

* readme: Update add-on's readme

* feat: added grafana helm addon

* readme: Update add-on's readme

* fix: fix typo in grafana resurce

* fix: fix terraform format

* fix: remove test example

* fix: added grafana in complete example

* feat: update multi document apply in single yaml for jaeger addon

* ran terraform format command

* fix- update trigger point for readme workflow

* fix: added output in the root structure to get addons details in example

* fix- terraform code format command ran

* fix: removed jaeger manifest deployment

* fix- terraform code format command ran

* fix: added jaeger helm config file for jaeger deploy

* fix- terraform code format command ran

* feat- added vs for grafana service

* feat- added grafana virtual service and update prometheus readme

* feat- added grafana virtual service and update prometheus readme

* fix: remove jaeger addon

---------

Co-authored-by: Anmol Nagpal <anmol@clouddrove.com>
Co-authored-by: clouddrove-ci <84795582+clouddrove-ci@users.noreply.github.com>
Co-authored-by: Himanshu Ahirwar <himanshu.ahirwar@clouddrove.com>
  • Loading branch information
4 people committed Jan 5, 2024
1 parent c353265 commit 7ad9b97
Show file tree
Hide file tree
Showing 38 changed files with 3,283 additions and 156 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ on:
push:
branches:
- master
paths:
- '_examples/**'
paths-ignore:
- '**/*README.md'
workflow_dispatch:

jobs:
Expand All @@ -26,7 +26,7 @@ jobs:
uses: actions/checkout@master
with:
fetch-depth: 0
ref: master
ref: ${{ github.head_ref }}
token: ${{ env.GH_TOKEN }}

- name: 'Set up Python 3.7'
Expand Down Expand Up @@ -84,13 +84,13 @@ jobs:
uses: actions/checkout@master
with:
fetch-depth: 0
ref: master
ref: ${{ github.head_ref }}
token: ${{ env.GH_TOKEN }}

- 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,addons/velero,addons/kube-state-metrics,addons/keda,addons/cert-manager,addons/filebeat,addons/reloader,addons/external-dns,addons/redis,addons/actions-runner-controller
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,addons/keda,addons/cert-manager,addons/filebeat,addons/reloader,addons/external-dns,addons/redis,addons/prometheus,addons/grafana,addons/actions-runner-controller
git-push: true
template: |-
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Expand Down
16 changes: 16 additions & 0 deletions _examples/complete/config/grafana/grafana-vs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: grafana
namespace: monitoring
spec:
hosts:
- dash.test.clouddrove.com
gateways:
- istio-system/istio-gateway
http:
- route:
- destination:
host: grafana
port:
number: 80
16 changes: 16 additions & 0 deletions _examples/complete/config/grafana/override-grafana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "eks.amazonaws.com/nodegroup"
operator: In
values:
- "critical"
resources:
limits:
cpu: 300m
memory: 250Mi
requests:
cpu: 50m
memory: 150Mi
36 changes: 36 additions & 0 deletions _examples/complete/config/override-prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
server:
## 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"

persistentVolume: # Persistent volume will not be deployed for prometheus server pod - Enable if EBS or EFS CSI Driver is installed
enabled: false

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

alertmanager: # Dependency for prometheus server
enabled: true
persistence: # Persistent volume will not be deployed for alertmanager - Enable if EBS or EFS CSI Driver is installed
enabled: false

kube-state-metrics: # Dependency for prometheus server
enabled: true

prometheus-node-exporter: # Dependency for prometheus server
enabled: true

prometheus-pushgateway: # Dependency for prometheus server
enabled: true
9 changes: 8 additions & 1 deletion _examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,13 @@ module "addons" {
external_dns = true
redis = true
actions_runner_controller = true
prometheus = true


# Grafaa Deployment
grafana = true
grafana_helm_config = { values = [file("./config/grafana/override-grafana.yaml")] }
grafana_manifests = var.grafana_manifests
grafana_extra_configs = var.grafana_extra_configs

# -- Addons with mandatory variable
istio_ingress = true
Expand Down Expand Up @@ -208,6 +213,7 @@ module "addons" {
external_dns_helm_config = { values = [file("./config/override-external-dns.yaml")] }
redis_helm_config = { values = [file("./config/override-redis.yaml")] }
actions_runner_controller_helm_config = { values = [file("./config/override-actions-runner-controller.yaml")] }
prometheus_helm_config = { values = [file("./config/override-prometheus.yaml")] }

# -- Override Helm Release attributes
metrics_server_extra_configs = var.metrics_server_extra_configs
Expand All @@ -234,6 +240,7 @@ module "addons" {
external_dns_extra_configs = var.external_dns_extra_configs
redis_extra_configs = var.redis_extra_configs
actions_runner_controller_extra_configs = var.actions_runner_controller_extra_configs
prometheus_extra_configs = var.prometheus_extra_configs

# -- Custom IAM Policy Json for Addon's ServiceAccount
cluster_autoscaler_iampolicy_json_content = file("./custom-iam-policies/cluster-autoscaler.json")
Expand Down
15 changes: 12 additions & 3 deletions _examples/complete/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,31 @@ provider "aws" {

provider "kubernetes" {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
token = data.aws_eks_cluster_auth.eks_cluster.token
cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks_cluster.certificate_authority[0].data)
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", data.aws_eks_cluster.eks_cluster.name]
command = "aws"
}
}

provider "helm" {
kubernetes {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
token = data.aws_eks_cluster_auth.eks_cluster.token
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", data.aws_eks_cluster.eks_cluster.name]
command = "aws"
}
}
}

provider "kubectl" {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
token = data.aws_eks_cluster_auth.eks_cluster.token
load_config_file = false
}

# ------------------------------------------------------------------------------
Expand Down
26 changes: 26 additions & 0 deletions _examples/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,29 @@ variable "actions_runner_controller_extra_configs" {
type = any
default = {}
}

# ------------------ PROMETHEUS --------------------------------------------------
variable "prometheus_extra_configs" {
type = any
default = {
atomic = true
namespace = "istio-system"
}
}

# ------------------------------- GRAFANA ------------------------------------------
variable "grafana_extra_configs" {
type = any
default = {
atomic = true
}
}

variable "grafana_manifests" {
type = object({
grafana_virtualservice_file_path = string
})
default = {
grafana_virtualservice_file_path = "./config/grafana/grafana-vs.yaml"
}
}
2 changes: 1 addition & 1 deletion _examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ terraform {
}
kubectl = {
source = "gavinbunney/kubectl"
version = ">= 1.7.0"
version = ">= 1.14.0"
}
}
}
16 changes: 16 additions & 0 deletions _examples/external-eks/config/grafana/grafana-vs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: grafana
namespace: istio-system
spec:
hosts:
- dash.test.clouddrove.com
gateways:
- istio-system/istio-gateway
http:
- route:
- destination:
host: grafana
port:
number: 80
16 changes: 16 additions & 0 deletions _examples/external-eks/config/grafana/override-grafana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "eks.amazonaws.com/nodegroup"
operator: In
values:
- "critical"
resources:
limits:
cpu: 300m
memory: 250Mi
requests:
cpu: 50m
memory: 150Mi
16 changes: 16 additions & 0 deletions _examples/external-eks/config/override-grafana.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "eks.amazonaws.com/nodegroup"
operator: In
values:
- "critical"
resources:
limits:
cpu: 300m
memory: 250Mi
requests:
cpu: 50m
memory: 150Mi
47 changes: 47 additions & 0 deletions _examples/external-eks/config/override-prometheus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
server:
service:
## If false, no Service will be created for the Prometheus server
##
enabled: true
annotations:
service.beta.kubernetes.io/aws-load-balancer-scheme: "internet-facing"
service.beta.kubernetes.io/aws-load-balancer-name: "prometheus"
labels: {}
clusterIP: ""

## 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"

## List of IP addresses at which the Prometheus server service is available
## Ref: https://kubernetes.io/docs/concepts/services-networking/service/#external-ips
##
externalIPs: []
loadBalancerIP: ""
loadBalancerSourceRanges: []
servicePort: 80
sessionAffinity: None
type: LoadBalancer

persistentVolume:
accessModes:
- ReadWriteOnce
enabled: true
mountPath: /data
size: 20Gi
storageClass: gp2

resources:
limits:
cpu: 300m
memory: 250Mi
requests:
cpu: 50m
memory: 150Mi
9 changes: 8 additions & 1 deletion _examples/external-eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ module "addons" {
filebeat = true
reloader = true
redis = true
prometheus = true

# Grafana Deployment
grafana = true
grafana_helm_config = { values = [file("./config/grafana/override-grafana.yaml")] }
grafana_manifests = var.grafana_manifests
grafana_extra_configs = var.grafana_extra_configs

# -- Addons with mandatory variable
istio_ingress = true
Expand Down Expand Up @@ -64,6 +70,7 @@ module "addons" {
filebeat_helm_config = { values = [file("./config/override-filebeat.yaml")] }
reloader_helm_config = { values = [file("./config/reloader/override-reloader.yaml")] }
redis_helm_config = { values = [file("./config/override-redis.yaml")] }
prometheus_helm_config = { values = [file("./config/override-prometheus.yaml")] }

# -- Override Helm Release attributes
metrics_server_extra_configs = var.metrics_server_extra_configs
Expand All @@ -88,7 +95,7 @@ module "addons" {
filebeat_extra_configs = var.filebeat_extra_configs
reloader_extra_configs = var.reloader_extra_configs
redis_extra_configs = var.redis_extra_configs

prometheus_extra_configs = var.prometheus_extra_configs

# -- Custom IAM Policy Json for Addon's ServiceAccount
external_secrets_iampolicy_json_content = file("./custom-iam-policies/external-secrets.json")
Expand Down
15 changes: 12 additions & 3 deletions _examples/external-eks/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,30 @@ provider "aws" {
provider "kubernetes" {
host = data.aws_eks_cluster.eks_cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks_cluster.certificate_authority[0].data)
token = join("", data.aws_eks_cluster_auth.eks_cluster[*].token)
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", data.aws_eks_cluster.eks_cluster.name]
command = "aws"
}
}

provider "helm" {
kubernetes {
host = data.aws_eks_cluster.eks_cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks_cluster.certificate_authority[0].data)
token = join("", data.aws_eks_cluster_auth.eks_cluster[*].token)
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", data.aws_eks_cluster.eks_cluster.name]
command = "aws"
}
}
}

provider "kubectl" {
host = data.aws_eks_cluster.eks_cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.eks_cluster.certificate_authority[0].data)
token = join("", data.aws_eks_cluster_auth.eks_cluster[*].token)
token = data.aws_eks_cluster_auth.eks_cluster.token
load_config_file = false
}

data "aws_eks_cluster_auth" "eks_cluster" {
Expand Down
Loading

0 comments on commit 7ad9b97

Please sign in to comment.