prole/k8s/opentofu/deployment.yaml

113 lines
2.9 KiB
YAML

apiVersion: v1
kind: ConfigMap
metadata:
name: opentofu-nginx
data:
default.conf: |
server {
listen 8080;
server_name _;
auth_basic "OpenTofu";
auth_basic_user_file /etc/nginx/auth/auth;
location / {
root /usr/share/nginx/html;
index index.html;
}
}
index.html: |
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>OpenTofu</title>
<style>
body { font-family: "SF Pro Text", "Segoe UI", sans-serif; background: #f5f5f0; color: #1d1d1f; }
.wrap { max-width: 720px; margin: 60px auto; padding: 32px; background: #fff; border-radius: 16px; box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
h1 { margin-top: 0; font-size: 28px; }
code { background: #f2f2f2; padding: 2px 6px; border-radius: 6px; }
</style>
</head>
<body>
<div class="wrap">
<h1>OpenTofu Pipeline Ready</h1>
<p>This service hosts the OpenTofu control plane for Knoe deployments.</p>
<p>Pipeline root (on disk): <code>deploy/opentofu/k3s</code></p>
</div>
</body>
</html>
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: opentofu
labels:
app: opentofu
spec:
replicas: 1
selector:
matchLabels:
app: opentofu
template:
metadata:
labels:
app: opentofu
spec:
containers:
- name: opentofu-ui
image: nginx:1.27-alpine
ports:
- name: http
containerPort: 8080
volumeMounts:
- name: nginx-config
mountPath: /etc/nginx/conf.d
- name: ui-content
mountPath: /usr/share/nginx/html
- name: opentofu-auth
mountPath: /etc/nginx/auth
readOnly: true
- name: opentofu-runner
image: ghcr.io/opentofu/opentofu:1.8.2
command: ["sh", "-c", "tofu version && tail -f /dev/null"]
env:
- name: OPENTOFU_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: opentofu-admin
key: admin_password
volumes:
- name: nginx-config
configMap:
name: opentofu-nginx
items:
- key: default.conf
path: default.conf
- name: ui-content
configMap:
name: opentofu-nginx
items:
- key: index.html
path: index.html
- name: opentofu-auth
secret:
secretName: opentofu-admin
items:
- key: auth
path: auth
---
apiVersion: v1
kind: Service
metadata:
name: opentofu
spec:
type: LoadBalancer
selector:
app: opentofu
ports:
- name: http
port: 8080
targetPort: http