mirror of
https://github.com/BreizhHardware/cours-ISEN-MD.git
synced 2026-03-18 21:50:46 +01:00
Obisidian vault auto-backup: 20-01-2026 10:32:23 on . 2 files edited
This commit is contained in:
2
.obsidian/workspace.json
vendored
2
.obsidian/workspace.json
vendored
@@ -206,9 +206,9 @@
|
||||
},
|
||||
"active": "e11a6a080eb83632",
|
||||
"lastOpenFiles": [
|
||||
"ISEN/Cloud Computing/CIPA4/Cloud Computing Cours 5.md",
|
||||
"ISEN/Cloud Computing/CIPA4/Cloud Computing Cours 2.md",
|
||||
"ISEN/Cloud Computing/CIPA4/Cloud Computing Cours 1.md",
|
||||
"ISEN/Cloud Computing/CIPA4/Cloud Computing Cours 5.md",
|
||||
"ISEN/Cloud Computing/CIPA4/Cloud Computing Cours 4.md",
|
||||
"ISEN/Cloud Computing/CIPA4/Cloud Computing Cours 3.md",
|
||||
"ISEN/English/CIPA4/16 janv 2026.md",
|
||||
|
||||
@@ -233,9 +233,213 @@ output "demo-flask-url" {
|
||||
}
|
||||
|
||||
output "nginx-url" {
|
||||
value = "https://${openstack_networking_floatingip_v2.frontend_fip.address}"
|
||||
value = "https://${openstack_networking_floatingip_v2.frontend_fip.address}.xip.opensteak.fr"
|
||||
}
|
||||
```
|
||||
|
||||
## 104
|
||||
`main.tf`
|
||||
```tf
|
||||
resource "kubernetes_config_map" "nginx-config" {
|
||||
metadata {
|
||||
name = "nginx-config"
|
||||
}
|
||||
|
||||
data = {
|
||||
"nginx.conf" = <<EOF
|
||||
events {}
|
||||
|
||||
http {
|
||||
server {
|
||||
listen 80;
|
||||
location / {
|
||||
proxy_pass http://demo-flask:8080;
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_deployment" "demo-flask" {
|
||||
metadata {
|
||||
name = "demo-flask"
|
||||
}
|
||||
|
||||
spec {
|
||||
replicas = 1
|
||||
|
||||
selector {
|
||||
match_labels = {
|
||||
app = "demo-flask"
|
||||
}
|
||||
}
|
||||
|
||||
template {
|
||||
metadata {
|
||||
labels = {
|
||||
app = "demo-flask"
|
||||
}
|
||||
}
|
||||
|
||||
spec {
|
||||
container {
|
||||
image = "arnaudmorin/demo-flask:latest"
|
||||
name = "demo-flask"
|
||||
|
||||
port {
|
||||
container_port = 8080
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_service" "demo-flask" {
|
||||
metadata {
|
||||
name = "demo-flask"
|
||||
}
|
||||
|
||||
spec {
|
||||
selector = {
|
||||
app = "demo-flask"
|
||||
}
|
||||
|
||||
port {
|
||||
port = 8080
|
||||
target_port = 8080
|
||||
}
|
||||
|
||||
type = "ClusterIP"
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_deployment" "nginx-frontend" {
|
||||
metadata {
|
||||
name = "nginx-frontend"
|
||||
}
|
||||
|
||||
spec {
|
||||
replicas = 1
|
||||
|
||||
selector {
|
||||
match_labels = {
|
||||
app = "nginx-frontend"
|
||||
}
|
||||
}
|
||||
|
||||
template {
|
||||
metadata {
|
||||
labels = {
|
||||
app = "nginx-frontend"
|
||||
}
|
||||
}
|
||||
|
||||
spec {
|
||||
container {
|
||||
image = "nginx:latest"
|
||||
name = "nginx"
|
||||
|
||||
port {
|
||||
container_port = 80
|
||||
}
|
||||
|
||||
volume_mount {
|
||||
name = "nginx-config"
|
||||
mount_path = "/etc/nginx/nginx.conf"
|
||||
sub_path = "nginx.conf"
|
||||
}
|
||||
}
|
||||
|
||||
volume {
|
||||
name = "nginx-config"
|
||||
config_map {
|
||||
name = "nginx-config"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
resource "kubernetes_service" "nginx-frontend" {
|
||||
metadata {
|
||||
name = "nginx-frontend"
|
||||
}
|
||||
|
||||
spec {
|
||||
selector = {
|
||||
app = "nginx-frontend"
|
||||
}
|
||||
|
||||
port {
|
||||
port = 80
|
||||
target_port = 80
|
||||
}
|
||||
|
||||
type = "LoadBalancer"
|
||||
}
|
||||
|
||||
wait_for_load_balancer = false
|
||||
}
|
||||
|
||||
resource "kubernetes_ingress_v1" "frontend" {
|
||||
metadata {
|
||||
name = "frontend"
|
||||
annotations = {
|
||||
"cert-manager.io/cluster-issuer" = "letsencrypt-prod"
|
||||
}
|
||||
}
|
||||
|
||||
spec {
|
||||
tls {
|
||||
secret_name = "frontend-tls"
|
||||
hosts = ["135.125.246.84.xip.opensteak.fr"]
|
||||
}
|
||||
|
||||
rule {
|
||||
host = "135.125.246.84.xip.opensteak.fr"
|
||||
http {
|
||||
path {
|
||||
path = "/"
|
||||
backend {
|
||||
service {
|
||||
name = "nginx-frontend"
|
||||
port {
|
||||
number = 80
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output "demo-flask-url" {
|
||||
value = "http://${kubernetes_service.demo-flask.metadata[0].name}:8080"
|
||||
}
|
||||
|
||||
output "nginx-url" {
|
||||
value = "https://135.125.246.84.xip.opensteak.fr/"
|
||||
}
|
||||
```
|
||||
|
||||
`provider.tf`
|
||||
```tf
|
||||
terraform {
|
||||
required_providers {
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
version = "~> 2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "kubernetes" {
|
||||
config_path = "/etc/rancher/k3s/k3s.yaml"
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user