Skip to content

Commit

Permalink
much stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-thomas committed Dec 15, 2024
1 parent 0cb6724 commit fc4108e
Show file tree
Hide file tree
Showing 29 changed files with 310 additions and 155 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
__pycache__
.direnv
result
.env
2 changes: 1 addition & 1 deletion Justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rebuild:
sudo nixos-rebuild switch --flake .
apply:
kubectl apply -k ./infra/manifests
kustomize build infra/manifests --enable-helm | kubectl apply --prune --all -f -
1 change: 1 addition & 0 deletions devShell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ pkgs.mkShell {
inputs.agenix.packages.${system}.default
pkgs.age
pkgs.just
pkgs.envsubst
];
}
2 changes: 2 additions & 0 deletions hosts/common/home/optional/devsetup/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
v = "nvim";
EDITOR = "nvim";
k = "kubectl";
kga = "kubectl get all";
kl = "kubectl logs";
j = "just --choose";
};

Expand Down
5 changes: 5 additions & 0 deletions hosts/vt-pc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ in
enable = true;
};

environment.etc."resolv.conf".text = ''
nameserver 45.90.28.165
nameserver 45.90.30.165
'';

}
3 changes: 3 additions & 0 deletions hosts/vt-pc/home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
awscli2

tradingview

kustomize
kubernetes-helm
];

programs.btop.enable = true;
Expand Down
25 changes: 0 additions & 25 deletions infra/manifests/apps/hello/ingress.yaml

This file was deleted.

13 changes: 13 additions & 0 deletions infra/manifests/apps/nginx/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: nginx-cert
spec:
secretName: nginx-cert

dnsNames:
- nginx.homelab.v-thomas.com

issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ kind: Deployment
metadata:
name: deploy
spec:
replicas: 2
replicas: 1
template:
spec:
containers:
- name: whoami
image: traefik/whoami
- name: nginx
image: nginx:1.27.3-perl
ports:
- containerPort: 80
18 changes: 18 additions & 0 deletions infra/manifests/apps/nginx/ingressroutes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: traefik.io/v1alpha1
kind: IngressRoute
metadata:
name: nginx-ingressroute
namespace: default

spec:
entryPoints:
- websecure
tls:
secretName: nginx-cert

routes:
- match: Host(`nginx.homelab.v-thomas.com`)
kind: Rule
services:
- name: nginx-service
port: 80
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@ kind: Kustomization
resources:
- deployment.yaml
- service.yaml
- ingress.yaml
- ingressroutes.yaml
- certificate.yaml

namePrefix: whoami-
namePrefix: nginx-

labels:
- includeSelectors: true
pairs:
app.kubernetes.io/name: whoami


helmCharts: []
app.kubernetes.io/name: nginx
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ metadata:
spec:
ports:
- name: http
protocol: TCP
port: 80
1 change: 1 addition & 0 deletions infra/manifests/core/cert-manager/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
secret.yaml
21 changes: 21 additions & 0 deletions infra/manifests/core/cert-manager/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
If cloning.

Add
```yaml
# File: secret.yaml

apiVersion: v1
kind: Secret
metadata:
name: cloudflare-api-token
type: Opaque
stringData:
api-token: [secret]
```
Permissions:
- Zone - DNS - Edit
- Zone - Zone - Read
Zone resources:
Include - All Zones
35 changes: 35 additions & 0 deletions infra/manifests/core/cert-manager/cluster-issuer-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-staging
spec:
acme:
server: https://acme-staging-v02.api.letsencrypt.org/directory
email: [email protected]
privateKeySecretRef:
name: letsencrypt-staging
solvers:
- dns01:
cloudflare:
email: [email protected]
apiTokenSecretRef:
name: cloudflare-api-token
key: api-key
---
apiVersion: cert-manager.io/v1
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: [email protected]
privateKeySecretRef:
name: letsencrypt-prod
solvers:
- dns01:
cloudflare:
email: [email protected]
apiTokenSecretRef:
name: cloudflare-api-token
key: api-key
8 changes: 7 additions & 1 deletion infra/manifests/core/cert-manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,11 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
# Namespace "cert-manager" is created in the url.
- ./secret.yaml
- ./cluster-issuer-staging.yaml
- https://github.com/cert-manager/cert-manager/releases/download/v1.16.2/cert-manager.yaml

# secretGenerator:
# - name: letsencrypt-email
# literals:
# - email=$(EMAIL)
20 changes: 20 additions & 0 deletions infra/manifests/core/gateway-api/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: gateway-cert
spec:
secretName: gateway-cert

secretTemplate:
labels:
app.kubernetes.io/part-of: gateway
app.kubernetes.io/name: gateway-cert
app.kubernetes.io/component: certificate

dnsNames:
- homelab.v-thomas.com
- "*.homelab.v-thomas.com"

issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
57 changes: 57 additions & 0 deletions infra/manifests/core/gateway-api/gateway-class.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
apiVersion: gateway.networking.k8s.io/v1
kind: GatewayClass
metadata:
name: traefik
namespace: default
spec:
controllerName: traefik.io/gateway-controller
---
apiVersion: gateway.networking.k8s.io/v1
kind: Gateway
metadata:
name: traefik
namespace: default
spec:
gatewayClassName: traefik

# Only Routes from the same namespace are allowed.
listeners:
# - name: http
# protocol: HTTP
# port: 80
# allowedRoutes:
# namespaces:
# from: Same

- name: https
protocol: HTTPS
port: 443
tls:
mode: Terminate
certificateRefs:
- name: gateway-cert
namespace: default

allowedRoutes:
namespaces:
from: Same

# - name: tcp
# protocol: TCP
# port: 3000
# allowedRoutes:
# namespaces:
# from: Same
#
# - name: tls
# protocol: TLS
# port: 3443
# tls:
# mode: Terminate
# certificateRefs:
# - name: secret-tls
# namespace: default
#
# allowedRoutes:
# namespaces:
# from: Same
6 changes: 6 additions & 0 deletions infra/manifests/core/gateway-api/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resources:
- https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.2.0/standard-install.yaml
- https://raw.githubusercontent.com/traefik/traefik/v3.2/docs/content/reference/dynamic-configuration/kubernetes-gateway-rbac.yml # When using traefik
- gateway-class.yaml
- certificate.yaml

2 changes: 1 addition & 1 deletion infra/manifests/core/metallb/ip-pool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: metallb-ip-pool
spec:
addresses:
- 192.168.76.64/27 # IPs from 64 to 95
- 192.168.76.64-192.168.76.99
---
apiVersion: metallb.io/v1beta1
kind: L2Advertisement
Expand Down
18 changes: 18 additions & 0 deletions infra/manifests/core/traefik/certificate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
name: traefik-cert
spec:
secretName: traefik-cert
secretTemplate:
labels:
app.kubernetes.io/part-of: ingress
app.kubernetes.io/name: traefik
app.kubernetes.io/component: certificate

dnsNames:
- traefik.homelab.v-thomas.com

issuerRef:
name: letsencrypt-prod
kind: ClusterIssuer
24 changes: 24 additions & 0 deletions infra/manifests/core/traefik/config/traefik.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
providers:
kubernetesCRD: {}

entryPoints:
web:
address: ":80"
websecure:
address: ":443"

accesslog:
filePath: /var/log/traefik/access.log

api:
insecure: true
dashboard: true
log:
level: DEBUG
#
# providers:
# kubernetesGateway:
#
# nativeLBByDefault: true
# # kubernetesIngress:
# # nativeLBByDefault: true
38 changes: 0 additions & 38 deletions infra/manifests/core/traefik/ingress.yaml

This file was deleted.

Loading

0 comments on commit fc4108e

Please sign in to comment.