Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add Consul Helm chart for cluster #2

Merged
merged 2 commits into from
Oct 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions consul/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions consul/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Consul `doks`

> This directory contains [Digital Ocean](https://registry.terraform.io/providers/digitalocean/digitalocean) Resources.

## Requirements

* Terraform CLI `1.0.8` or newer
* a Digital Ocean [account](https://m.do.co/c/b73b4af31c09)

## Deployment

This deploys the following components to a Digital Ocean Kubernetes cluster.

- Consul and Prometheus (via Helm chart)
- Grafana (via Helm chart)
- Jaeger (via Kubernetes resource)
18 changes: 18 additions & 0 deletions consul/data-sources.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# see https://www.terraform.io/docs/language/state/remote-state-data.html#example-usage-remote-backend-
data "terraform_remote_state" "clusters" {
backend = "remote"

config = {
organization = "a-demo-organization"

workspaces = {
name = "multi-cloud-k8s-outputs"
}
}
}

# see https://registry.terraform.io/providers/digitalocean/digitalocean/latest/docs/data-sources/kubernetes_cluster
data "digitalocean_kubernetes_cluster" "cluster" {
# dynamically retrieve the DOKS Cluster Name from Terraform State from the `outputs` Workspace
name = data.terraform_remote_state.clusters.outputs.clusters.doks.cluster_name
}
26 changes: 26 additions & 0 deletions consul/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module "consul_on_doks" {
source = "./modules/consul"

providers = {
helm = helm.doks
kubernetes = kubernetes.doks
}
}

module "grafana_on_doks" {
source = "./modules/grafana"

providers = {
helm = helm.doks
kubernetes = kubernetes.doks
}
}

module "jaeger_on_doks" {
source = "./modules/jaeger"

providers = {
helm = helm.doks
kubernetes = kubernetes.doks
}
}
18 changes: 18 additions & 0 deletions consul/modules/consul/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Helm Deployment of HashiCorp Consul

See [hashicorp/consul-k8s](https://github.com/hashicorp/consul-k8s) for more information.

It enables the following:

### Consul

- Access control lists
- Agent metrics
- Proxy metrics
- Transparent proxy
- Consul UI at a load balancer
- Controller for CRDs

### Prometheus

- For collecting metrics from applications and Consul.
13 changes: 13 additions & 0 deletions consul/modules/consul/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# see https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release
resource "helm_release" "consul" {
chart = "consul"
name = "consul"
repository = "https://helm.releases.hashicorp.com/"

# see https://github.com/hashicorp/consul-k8s/tags
version = var.chart_version # NOTE: this is NOT the version of Consul to use

values = [
file("${path.module}/values.yml")
]
}
16 changes: 16 additions & 0 deletions consul/modules/consul/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
terraform {
# see https://www.terraform.io/docs/language/settings/index.html#specifying-provider-requirements
required_providers {
# see https://registry.terraform.io/providers/hashicorp/helm/2.3.0/docs
helm = {
source = "hashicorp/helm"
version = "2.3.0"
}

# see https://registry.terraform.io/providers/hashicorp/kubernetes/2.5.0/docs
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.5.0"
}
}
}
31 changes: 31 additions & 0 deletions consul/modules/consul/values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
joatmon08 marked this conversation as resolved.
Show resolved Hide resolved

global:
name: consul
acls:
manageSystemACLs: true
metrics:
enabled: true
enableAgentMetrics: true

prometheus:
enabled: true

server:
replicas: 1

client:
enabled: true

connectInject:
enabled: true
transparentProxy:
defaultEnabled: true

ui:
enabled: true
service:
type: LoadBalancer

controller:
enabled: true
5 changes: 5 additions & 0 deletions consul/modules/consul/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "chart_version" {
type = string
description = "Specify the exact chart version to install."
joatmon08 marked this conversation as resolved.
Show resolved Hide resolved
default = "0.34.1"
}
10 changes: 10 additions & 0 deletions consul/modules/grafana/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Helm Deployment of Grafana

See [grafana/helm-charts](https://github.com/grafana/helm-charts) for more information.

It enables the following:

### Grafana

- Dashboard for [Kong API Gateway](https://grafana.com/grafana/dashboards/7424)
- Dashboard for the [joatmon08/expense-report](https://github.com/joatmon08/expense-report/blob/main/grafana/app.json)
13 changes: 13 additions & 0 deletions consul/modules/grafana/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# see https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release
resource "helm_release" "grafana" {
chart = "grafana"
name = "grafana"
repository = "https://grafana.github.io/helm-charts/"

# see https://github.com/grafana/helm-charts/tags
version = var.chart_version # NOTE: this is NOT the version of Grafana to use

values = [
file("${path.module}/values.yml")
]
}
16 changes: 16 additions & 0 deletions consul/modules/grafana/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
terraform {
# see https://www.terraform.io/docs/language/settings/index.html#specifying-provider-requirements
required_providers {
# see https://registry.terraform.io/providers/hashicorp/helm/2.3.0/docs
helm = {
source = "hashicorp/helm"
version = "2.3.0"
}

# see https://registry.terraform.io/providers/hashicorp/kubernetes/2.5.0/docs
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.5.0"
}
}
}
39 changes: 39 additions & 0 deletions consul/modules/grafana/values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---

adminPassword: password
persistence:
enabled: true

service:
type: LoadBalancer

datasources:
datasources.yaml:
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
url: http://prometheus-server
access: proxy
isDefault: true

dashboardProviders:
dashboardproviders.yaml:
apiVersion: 1
providers:
- name: 'default'
orgId: 1
folder: ''
type: file
disableDeletion: false
editable: true
options:
path: /var/lib/grafana/dashboards/default
dashboards:
default:
kong-dash:
gnetId: 7424
revision: 5
datasource: Prometheus
app-dash:
url: https://raw.githubusercontent.com/joatmon08/expense-report/main/grafana/app.json
5 changes: 5 additions & 0 deletions consul/modules/grafana/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "chart_version" {
type = string
description = "Specify the exact chart version to install."
default = "6.16.10"
}
5 changes: 5 additions & 0 deletions consul/modules/jaeger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Kubernetes Deployment of Jaeger All-in-One

See [jaegertracing/jaeger-kubernetes](https://github.com/jaegertracing/jaeger-kubernetes/tree/master/all-in-one) for more information.

It enables a Jaeger collector with an all-in-one deployment. Supports Zipkin HTTP spans.
Loading