blob: 08d89a54fa1fd60dfa3f9ec93961137434b06d1d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
---
title: "Installation"
description: Installation notes of www on k3s
tags:
- hugo
- k3s
- kubernetes
---
## Introduction
This is a static website built using hugo.
The CI/CD is a work in progress, for now the installation is made from a crude kubernetes manifest. The instructions have been updated for the search feature.
## Kubernetes manifests
```yaml
apiVersion: v1
kind: Namespace
metadata:
name: www
---
apiVersion: apps/v1
kind: Deployment
metadata:
namespace: www
name: www
labels:
app: www
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
selector:
matchLabels:
app: www
template:
metadata:
labels:
app: www
spec:
containers:
- name: www
image: quay.io/adyxax/www:2021110901
ports:
- containerPort: 80
readinessProbe:
httpGet:
path: '/'
port: 80
initialDelaySeconds: 1
timeoutSeconds: 1
livenessProbe:
httpGet:
path: '/'
port: 80
initialDelaySeconds: 1
timeoutSeconds: 1
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "sleep 10"]
- name: search
image: quay.io/adyxax/www-search:2021110901
ports:
- containerPort: 8080
readinessProbe:
httpGet:
path: '/search/'
port: 8080
initialDelaySeconds: 1
timeoutSeconds: 1
livenessProbe:
httpGet:
path: '/search/'
port: 8080
initialDelaySeconds: 1
timeoutSeconds: 1
lifecycle:
preStop:
exec:
command: ["/bin/sh", "-c", "sleep 10"]
---
apiVersion: v1
kind: Service
metadata:
namespace: www
name: www
spec:
type: ClusterIP
selector:
app: www
ports:
- protocol: TCP
port: 80
targetPort: 80
name: www
- protocol: TCP
port: 8080
targetPort: 8080
name: search
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: www
name: www
spec:
ingressClassName: nginx
tls:
- secretName: wildcard-adyxax-org
rules:
- host: www.adyxax.org
http:
paths:
- path: '/'
pathType: Prefix
backend:
service:
name: www
port:
number: 80
- path: '/search'
pathType: Prefix
backend:
service:
name: www
port:
number: 8080
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: www
name: redirects
annotations:
nginx.ingress.kubernetes.io/permanent-redirect: https://www.adyxax.org/
nginx.ingress.kubernetes.io/permanent-redirect-code: "308"
spec:
ingressClassName: nginx
tls:
- secretName: wildcard-adyxax-org
rules:
- host: adyxax.org
- host: wiki.adyxax.org
```
## DNS CNAME
Terraform is only used for the dns record on this app for legacy reasons
```hcl
resource "cloudflare_record" "pass-cname" {
zone_id = lookup(data.cloudflare_zones.adyxax-org.zones[0], "id")
name = "www"
value = "myth.adyxax.org"
type = "CNAME"
proxied = false
}
```
## Certificate
For now I do not manage my certificates with terraform but manually. Once every two months I run :
```sh
acme.sh --config-home "$HOME/.acme.sh" --server letsencrypt --dns dns_cf --issue -d adyxax.org -d *.adyxax.org --force
kubectl -n www create secret tls wildcard-adyxax-org --cert=$HOME/.acme.sh/adyxax.org/fullchain.cer \
--key=$HOME/.acme.sh/adyxax.org/adyxax.org.key -o yaml --save-config --dry-run=client | kubectl apply -f -
```
|