Skip to content

Commit 86b471c

Browse files
committed
feat(example): devops-stack on scaleway
chore(scaleway): first example
1 parent 496f298 commit 86b471c

File tree

8 files changed

+331
-173
lines changed

8 files changed

+331
-173
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,14 @@ ehthumbs_vista.db
5555

5656
# Folder config file
5757
[Dd]esktop.ini
58+
.DS_STORE
59+
examples/*/secrets.yml
60+
examples/*/terraform.tfstate*
61+
examples/*/.terraform.lock.hcl
62+
examples/*/kubeconfig.yml
63+
examples/*/issue.txt
64+
examples/*/log.txt
65+
examples/*/*.png
66+
examples/*/*.html
67+
examples/*/issuers.yml
68+
**/*.swp

examples/scaleway/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
## Installation
2+
3+
Add your credentials to launch the project. At least the following environement variables are required: `SCW_ACCESS_KEY,SCW_ACCESS_KEY,SCW_DEFAULT_ORGANIZATION_ID,SCW_DEFAULT_PROJECT_ID,SCW_DEFAULT_PROJECT_ID`.
4+
5+
Configure the stack by modifying `inputs.tfvars` (e.g: cluster\_name) and launch the terraform apply with:
6+
7+
```bash
8+
terraform init
9+
terraform apply -var-file inputs.tfvars
10+
```
11+
12+
## Usage
13+
Get the kubeconfig file and the domain name with the following commands:
14+
15+
```bash
16+
terraform output -raw kubeconfig_file > kubeconfig.json
17+
terraform output base_domain
18+
```
19+
20+
Your application are available at the following address: $APP\_NAME.apps.$CLUSTER\_NAME.$BASE\_DOMAIN.
21+
e.g: prometheus.apps.devops-stack.51-51-52-52.np.io
22+
23+
For authentication on oidc, users and password are available in the output:
24+
```bash
25+
terraform output passwords
26+
```
27+

examples/scaleway/inputs.tfvars

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# ###################################################
2+
# Input for module which creates the scaleway cluster
3+
# ###################################################
4+
cluster_name = "devops-stack"
5+
cluster_description = "Devops-stack on cloud provider scaleway"
6+
cluster_tags = ["demo", "dev", "devops-stack", "test", ]
7+
cluster_type = "multicloud"
8+
kubernetes_version = "1.27.10"
9+
admission_plugins = ["PodNodeSelector", ]
10+
node_pools = {
11+
config1 = {
12+
node_type = "DEV1-M"
13+
size = 2
14+
min_size = 2
15+
max_size = 2
16+
autoscaling = true
17+
autohealing = true
18+
container_runtime = "containerd"
19+
wait_for_pool_ready = true
20+
}
21+
}
22+
23+
# #########################
24+
# Additional cluster config
25+
# #########################
26+
base_domain = "gs-fr-dev.camptocamp.com"
27+
lb_name = "devops-stack"
28+
zone = "fr-par-1"
29+
lb_type = "LB-S"
30+
31+
# Ingress
32+
ingress_enable_service_monitor = false
33+
34+
# Keycloak
35+
cluster_issuer = "ca-issuer"
36+
37+
# Cert-manager
38+
cert_manager_enable_service_monitor = false

examples/scaleway/main.tf

Lines changed: 109 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,42 @@
1-
locals {
2-
cluster_name = "scaleway-test"
3-
cluster_region = "fr-par"
4-
cluster_zone = "fr-par-1"
5-
tags = ["test", "${local.cluster_name}"]
6-
}
7-
8-
module "cluster" {
9-
source = "git::https://github.com/camptocamp/devops-stack.git//modules/scaleway?ref=v1-alpha"
10-
11-
kubernetes_version = "1.24.3"
12-
13-
cluster_type = "kapsule"
14-
cluster_name = local.cluster_name
15-
cluster_tags = local.tags
16-
region = local.cluster_region
17-
zone = local.cluster_zone
18-
lb_type = "LB-S"
19-
1+
# ###########################
2+
# INFRA + K8s PHASE
3+
# ###########################
4+
module "scaleway" {
5+
source = "[email protected]:camptocamp/devops-stack-module-cluster-scaleway.git"
6+
7+
base_domain = var.base_domain
8+
cluster_name = var.cluster_name
9+
cluster_description = var.cluster_description
10+
cluster_tags = var.cluster_tags
11+
cluster_type = var.cluster_type
12+
kubernetes_version = var.kubernetes_version
13+
lb_name = var.lb_name
14+
lb_type = var.lb_type
15+
zone = var.zone
16+
node_pools = var.node_pools
2017
}
2118

19+
# ###########################
20+
# BOOTSPRAP APPLICATION PHASE
21+
# ###########################
2222

2323
module "argocd_bootstrap" {
24-
source = "git::https://github.com/camptocamp/devops-stack-module-argocd.git//bootstrap?ref=v1-alpha"
25-
cluster_name = local.cluster_name
26-
base_domain = module.cluster.base_domain
27-
cluster_issuer = "letsencrypt-prod"
28-
29-
argocd = {
30-
admin_enabled = "true"
31-
}
32-
33-
depends_on = [
34-
module.cluster,
35-
]
24+
source = "git::https://github.com/camptocamp/devops-stack-module-argocd.git//bootstrap?ref=v4.4.0"
3625
}
3726

27+
module "ingress_controller" {
28+
source = "git::https://github.com/camptocamp/devops-stack-module-traefik.git?ref=v5.0.0"
3829

39-
module "ingress" {
40-
source = "git::https://github.com/camptocamp/devops-stack-module-traefik.git//scaleway?ref=v1-alpha"
41-
42-
cluster_name = local.cluster_name
43-
argocd_namespace = module.argocd_bootstrap.argocd_namespace
44-
base_domain = module.cluster.base_domain
30+
cluster_name = var.cluster_name
31+
base_domain = module.scaleway.base_domain
32+
enable_service_monitor = var.ingress_enable_service_monitor
4533

4634
helm_values = [{
4735
traefik = {
4836
service = {
4937
type = "LoadBalancer"
5038
annotations = {
51-
"service.beta.kubernetes.io/scw-loadbalancer-id" = module.cluster.lb_id
39+
"service.beta.kubernetes.io/scw-loadbalancer-id" = module.scaleway.lb_id
5240
}
5341
}
5442
}
@@ -60,131 +48,103 @@ module "ingress" {
6048
}
6149

6250
module "cert-manager" {
63-
source = "git::https://github.com/camptocamp/devops-stack-module-cert-manager.git//scaleway?ref=remove-read-only-attribut"
64-
65-
cluster_name = local.cluster_name
66-
argocd_namespace = module.argocd_bootstrap.argocd_namespace
67-
base_domain = module.cluster.base_domain
51+
source = "git::https://github.com/camptocamp/devops-stack-module-cert-manager.git//self-signed?ref=v8.1.0"
6852

69-
helm_values = [{
70-
cert-manager = {
71-
clusterIssuers = {
72-
letsencrypt = {
73-
enabled = true
74-
}
75-
acme = {
76-
solvers = [
77-
{
78-
http01 = {
79-
ingress = {}
80-
}
81-
}
82-
]
83-
}
84-
}
85-
}
86-
}]
53+
enable_service_monitor = var.cert_manager_enable_service_monitor
8754

8855
dependency_ids = {
8956
argocd = module.argocd_bootstrap.id
9057
}
9158
}
9259

93-
module "argocd" {
94-
source = "git::https://github.com/camptocamp/devops-stack-module-argocd.git?ref=v1-alpha"
60+
module "authentication_with_keycloak" {
61+
source = "git::https://github.com/camptocamp/devops-stack-module-keycloak.git?ref=v2.0.1"
9562

96-
bootstrap_values = module.argocd_bootstrap.bootstrap_values
63+
cluster_name = var.cluster_name
9764
argocd_namespace = module.argocd_bootstrap.argocd_namespace
65+
base_domain = var.base_domain
66+
cluster_issuer = var.cluster_issuer
9867

99-
oidc = {}
68+
dependency_ids = {
69+
ingress_controller = module.ingress_controller.id
70+
cert-manager = module.cert-manager.id
71+
}
72+
}
10073

101-
helm_values = [{
102-
argo-cd = {
103-
global = {
104-
image = {
105-
repository = "camptocamp/argocd"
106-
tag = "v2.3.4_c2c.3"
107-
}
108-
}
109-
server = {
110-
config = {
111-
configManagementPlugins = <<-EOT
112-
- name: kustomized-helm
113-
init:
114-
command: ["/bin/sh", "-c"]
115-
args: ["helm dependency build || true"]
116-
generate:
117-
command: ["/bin/sh", "-c"]
118-
args: ["echo \"$HELM_VALUES\" | helm template . --name-template $ARGOCD_APP_NAME --namespace $ARGOCD_APP_NAMESPACE $HELM_ARGS -f - --include-crds > all.yaml && kustomize build"]
119-
- name: helmfile
120-
init:
121-
command: ["argocd-helmfile"]
122-
args: ["init"]
123-
generate:
124-
command: ["argocd-helmfile"]
125-
args: ["generate"]
126-
lockRepo: true
127-
EOT
128-
}
129-
}
74+
module "authorization_with_keycloak" {
75+
source = "git::https://github.com/camptocamp/devops-stack-module-keycloak.git//oidc_bootstrap?ref=v2.0.1"
76+
77+
cluster_name = var.cluster_name
78+
base_domain = var.base_domain
79+
cluster_issuer = var.cluster_issuer
80+
user_map = {
81+
jdoe = {
82+
username = "jdoe"
83+
84+
first_name = "John"
85+
last_name = "Doe"
13086
}
131-
}]
87+
}
88+
dependency_ids = {
89+
keycloak = module.authentication_with_keycloak.id
90+
}
91+
}
92+
93+
94+
module "kube-prometheus-stack" {
95+
source = "git::https://github.com/camptocamp/devops-stack-module-kube-prometheus-stack?ref=v9.2.0"
96+
97+
cluster_name = var.cluster_name
98+
base_domain = module.scaleway.base_domain
99+
cluster_issuer = var.cluster_issuer
100+
101+
metrics_storage_main = null
102+
103+
prometheus = {
104+
oidc = module.authorization_with_keycloak.oidc
105+
}
106+
alertmanager = {
107+
oidc = module.authorization_with_keycloak.oidc
108+
}
109+
grafana = {
110+
oidc = module.authorization_with_keycloak.oidc
111+
}
132112

133113
dependency_ids = {
134-
argocd = module.argocd_bootstrap.id
135-
cert_manager = module.cert-manager.id
114+
ingress_controller = module.ingress_controller.id
115+
cert-manager = module.cert-manager.id
116+
oidc = module.authentication_with_keycloak.id
136117
}
137118
}
138119

139-
#module "monitoring" {
140-
# source = "git::https://github.com/camptocamp/devops-stack-module-kube-prometheus-stack.git?ref=v1-alpha"
141-
#
142-
# cluster_name = local.cluster_name
143-
#
144-
# prometheus = {
145-
# oidc = {
146-
# issuer_url = module.oidc.issuer_url
147-
# api_url = "${module.oidc.issuer_url}/healthz"
148-
# client_id = module.oidc.clients.prometheus.id
149-
# client_secret = module.oidc.clients.prometheus.secret
150-
#
151-
# oauth2_proxy_extra_args = [
152-
# ]
153-
# }
154-
# }
155-
#
156-
# alertmanager = {
157-
# oidc = {
158-
# issuer_url = module.oidc.issuer_url
159-
# api_url = "${module.oidc.issuer_url}/healthz"
160-
# client_id = module.oidc.clients.alertmanager.id
161-
# client_secret = module.oidc.clients.alertmanager.secret
162-
#
163-
# oauth2_proxy_extra_args = [
164-
# ]
165-
# }
166-
# }
167-
#
168-
# grafana = {
169-
# oidc = {
170-
# oauth_url = "${module.oidc.issuer_url}/auth"
171-
# token_url = "${module.oidc.issuer_url}/token"
172-
# api_url = "${module.oidc.issuer_url}/userinfo"
173-
# client_id = module.oidc.clients.grafana.id
174-
# client_secret = module.oidc.clients.grafana.secret
175-
#
176-
# oauth2_proxy_extra_args = [
177-
# ]
178-
# }
179-
# }
180-
#
181-
# argocd_namespace = module.argocd_bootstrap.argocd_namespace
182-
# base_domain = module.cluster.base_domain
183-
# cluster_issuer = "letsencrypt-prod"
184-
# metrics_archives = {}
185-
#
186-
# dependency_ids = {
187-
# argocd = module.argocd_bootstrap.id
188-
# oidc = module.oidc.id
189-
# }
190-
#}
120+
module "argocd" {
121+
source = "git::https://github.com/camptocamp/devops-stack-module-argocd.git?ref=v4.4.0"
122+
123+
base_domain = module.scaleway.base_domain
124+
cluster_name = var.cluster_name
125+
cluster_issuer = var.cluster_issuer
126+
server_secretkey = module.argocd_bootstrap.argocd_server_secretkey
127+
accounts_pipeline_tokens = module.argocd_bootstrap.argocd_accounts_pipeline_tokens
128+
129+
admin_enabled = true
130+
#app_autosync = {}
131+
132+
oidc = {
133+
name = "OIDC"
134+
issuer = module.authorization_with_keycloak.oidc.issuer_url
135+
clientID = module.authorization_with_keycloak.oidc.client_id
136+
clientSecret = module.authorization_with_keycloak.oidc.client_secret
137+
requestedIDTokenClaims = {
138+
groups = {
139+
essential = true
140+
}
141+
}
142+
}
143+
144+
dependency_ids = {
145+
ingress_controller = module.ingress_controller.id
146+
cert-manager = module.cert-manager.id
147+
oidc = module.authorization_with_keycloak.id
148+
# kube-prometheus-stack = module.kube-prometheus-stack.id
149+
}
150+
}

0 commit comments

Comments
 (0)