-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: deploy the sandbox environment for s42 devs (#255)
**Describe the pull request** With the new IaC, the sandbox is not automated anymore. **Breaking changes ?** no Signed-off-by: 42Atomys <contact@atomys.fr>
- Loading branch information
Showing
15 changed files
with
2,522 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,7 +130,7 @@ module "istio" { | |
} | ||
} | ||
] | ||
}, | ||
} | ||
] | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
resource "kubernetes_config_map" "stud42_config" { | ||
metadata { | ||
name = "stud42-config" | ||
namespace = var.namespace | ||
labels = { | ||
"kubernetes.io/name" = "stud42-config" | ||
"app.kubernetes.io/part-of" = "stud42" | ||
"app.kubernetes.io/managed-by" = "terraform" | ||
"app.kubernetes.io/created-by" = "github-actions" | ||
} | ||
} | ||
|
||
data = { | ||
"stud42.yaml" = templatefile("${path.root}/../apps/configs/stud42/stud42.yaml.tftpl", { | ||
rootDomain = var.rootDomain | ||
namespace = var.namespace | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
|
||
module "jwtks_service" { | ||
source = "../../modules/service" | ||
|
||
name = "jwtks-service" | ||
appName = "jwtks-service" | ||
appVersion = var.appVersion | ||
namespace = var.namespace | ||
image = "ghcr.io/42atomys/stud42:${var.appVersion}" | ||
|
||
command = ["stud42cli"] | ||
args = ["--config", "/config/stud42.yaml", "serve", "jwtks"] | ||
|
||
nodeSelector = { | ||
nodepool = "small" | ||
} | ||
|
||
podLabels = { | ||
# Disable istio sidecar injection for this pod due to the fact this is a | ||
# job and we dont implement the /quitquitquit endpoint of envoy actually. | ||
"sidecar.istio.io/inject" = "false" | ||
} | ||
|
||
replicas = 1 | ||
autoscaling = { | ||
enabled = true | ||
minReplicas = 1 | ||
maxReplicas = 10 | ||
metrics = { | ||
cpu = { | ||
targetAverageUtilization = 75 | ||
} | ||
} | ||
} | ||
|
||
prometheus = { | ||
enabled = false | ||
} | ||
|
||
podSecurityContext = { | ||
fsGroup = 1001 | ||
} | ||
|
||
containerSecurityContext = { | ||
runAsGroup = 1001 | ||
runAsNonRoot = true | ||
runAsUser = 1001 | ||
} | ||
|
||
resources = { | ||
limits = { | ||
memory = "60Mi" | ||
} | ||
requests = { | ||
cpu = "100m" | ||
memory = "40Mi" | ||
} | ||
} | ||
|
||
ports = { | ||
signing = { | ||
containerPort = 5000 | ||
istioProtocol = "grpc" | ||
} | ||
|
||
wellknow = { | ||
containerPort = 5500 | ||
istioProtocol = "http" | ||
} | ||
} | ||
|
||
env = { | ||
GO_ENV = var.namespace | ||
} | ||
|
||
envFromSecret = { | ||
SENTRY_DSN = { | ||
key = "JWTKS_SERVICE_DSN" | ||
name = "sentry-dsns" | ||
} | ||
S42_SERVICE_TOKEN = { | ||
key = "TOKEN" | ||
name = "s42-service-token" | ||
} | ||
} | ||
|
||
volumeMounts = [ | ||
{ | ||
volumeName = "configuration" | ||
mountPath = "/config" | ||
readOnly = true | ||
}, | ||
{ | ||
volumeName = "certs-grpc" | ||
mountPath = "/etc/certs/grpc" | ||
readOnly = true | ||
}, | ||
{ | ||
volumeName = "certs-jwk" | ||
mountPath = "/etc/certs/jwk" | ||
readOnly = true | ||
} | ||
] | ||
|
||
volumesFromConfig = { | ||
configuration = { | ||
configMapName = "stud42-config" | ||
} | ||
} | ||
|
||
volumesFromSecret = { | ||
certs-grpc = { | ||
secretName = "jwtks-service-grpc-internal-tls" | ||
} | ||
certs-jwk = { | ||
# secret defined in the secrets.tf file, not on the app module | ||
# TODO: move it to the app module (add sealedSecret to the app module) | ||
secretName = "jwtks-service-certs-jwk" | ||
} | ||
} | ||
|
||
certificates = { | ||
grpc-internal = { | ||
dnsNames = ["jwtks-service", "jwtks-service.${var.namespace}.svc.cluster.local"] | ||
issuerRefKind = "ClusterIssuer" | ||
issuerRefName = "selfsigned-issuer" | ||
} | ||
} | ||
|
||
secrets = var.hasProvidedJWTKSCertificates ? { | ||
certs-jwk = { | ||
data = { | ||
"private.key" = file("${path.root}/../../../certs/private.key") | ||
"public.pem" = file("${path.root}/../../../certs/public.pem") | ||
} | ||
} | ||
} : {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
locals { | ||
// reversedRootDomain is the root domain name, reversed, for use in the | ||
// reverse proxy configuration. For example, if the root domain is | ||
// example.tld, the reversed root domain is tld-example | ||
// If the root domain is pr-23.previews.example.tld, the reversed root | ||
// domain is tld-example-previews | ||
reversedRootDomain = join( | ||
"-", | ||
slice( | ||
reverse(split(".", var.rootDomain)), | ||
0, | ||
min(3, length(split(".", var.rootDomain))) | ||
) | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
terraform { | ||
required_providers { | ||
kubernetes = { | ||
source = "hashicorp/kubernetes" | ||
version = ">= 2.14" | ||
} | ||
helm = { | ||
source = "hashicorp/helm" | ||
version = ">= 2.7.1" | ||
} | ||
} | ||
} | ||
|
||
provider "kubernetes" { | ||
config_path = "~/.kube/config" | ||
|
||
ignore_labels = [ | ||
"security.istio.io/tlsMode", | ||
"service.istio.io/canonical-name", | ||
"service.istio.io/canonical-revision" | ||
] | ||
|
||
ignore_annotations = [ | ||
"sidecar.istio.io/status", | ||
] | ||
} | ||
|
||
provider "helm" { | ||
kubernetes { | ||
config_path = "~/.kube/config" | ||
} | ||
} |
Oops, something went wrong.