Skip to content

Commit

Permalink
k8s: init attic api instances
Browse files Browse the repository at this point in the history
  • Loading branch information
ttrssreal committed Jan 11, 2025
1 parent dbf4888 commit 3f0a9e9
Show file tree
Hide file tree
Showing 9 changed files with 155 additions and 1 deletion.
18 changes: 18 additions & 0 deletions k8s/attic/attic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: attic
namespace: apps
spec:
project: apps
source:
repoURL: "https://github.com/ttrssreal/jix"
path: "k8s/attic/resources"
destination:
server: "https://kubernetes.default.svc"
namespace: attic
syncPolicy:
automated:
prune: true
selfHeal: true
allowEmpty: false
4 changes: 4 additions & 0 deletions k8s/attic/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: attic
22 changes: 22 additions & 0 deletions k8s/attic/resources/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: attic-config
data:
atticd.yaml: |
listen = "[::]:8080"
[chunking]
avg-size = 65536
max-size = 262144
min-size = 16384
nar-size-threshold = 65536
[database]
url = "postgresql://attic@ari/attic"
[storage]
bucket = "nix-cache-b5eea907c395"
endpoint = "https://nix-cache-b5eea907c395.s3.us-west-002.backblazeb2.com"
region = "us-west-002"
type = "s3"
51 changes: 51 additions & 0 deletions k8s/attic/resources/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: attic-api
namespace: attic
spec:
replicas: 2
selector:
matchLabels:
app: attic-api
template:
metadata:
labels:
app: attic-api
spec:
containers:
- name: attic-api
image: ghcr.io/zhaofengli/attic:b8c5ab4518f776624fee261385abb98348cd26cf
args: ["--mode", "api-server", "-f", "/etc/attic/atticd.yaml"]
env:
- name: ATTIC_SERVER_TOKEN_RS256_SECRET_BASE64
valueFrom:
secretKeyRef:
# FIXME: part of declarative secret management
name: attic-creds
key: token
- name: AWS_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
# FIXME: part of declarative secret management
name: attic-creds
key: key-id
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
# FIXME: part of declarative secret management
name: attic-creds
key: secret-key
volumeMounts:
- name: config
mountPath: "/etc/attic"
readOnly: true
ports:
- containerPort: 8080
volumes:
- name: config
configMap:
name: attic-config
items:
- key: "atticd.yaml"
path: "atticd.yaml"
24 changes: 24 additions & 0 deletions k8s/attic/resources/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: attic-api
namespace: attic
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production
spec:
ingressClassName: nginx
rules:
- host: cache.jessie.cafe
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: attic-api
port:
name: http
tls:
- hosts:
- cache.jessie.cafe
secretName: attic-api-cert
13 changes: 13 additions & 0 deletions k8s/attic/resources/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: v1
kind: Service
metadata:
name: attic-api
namespace: attic
spec:
selector:
app: attic-api
ports:
- name: http
protocol: TCP
port: 80
targetPort: 8080
1 change: 0 additions & 1 deletion nixos/ari/argocd/app.nix
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ in
inherit (config.jix.argocd) targetRevision;
repoURL = "https://github.com/ttrssreal/jix";
inherit path;
directory.recurse = true;
}) config.jix.argocd.sources;

destination = {
Expand Down
1 change: 1 addition & 0 deletions nixos/ari/kubernetes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
targetRevision = "e175c71b696752df431c2b313bd406731e7e149f";

sources = [
"k8s/attic"
"k8s/argocd-server"
"k8s/cert-manager"
"k8s/github-runners"
Expand Down
22 changes: 22 additions & 0 deletions nixos/ari/system.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
endpoint = "https://nix-cache-b5eea907c395.s3.us-west-002.backblazeb2.com";
};

database.url = "postgresql://attic@ari/attic";

# Data chunking
#
# Warning: If you change any of the values here, it will be
Expand All @@ -44,6 +46,26 @@
};
};
};

postgresql = {
enable = true;
enableTCPIP = true;

authentication = ''
host all all all trust
'';

ensureDatabases = [
"attic"
];

ensureUsers = [
{
name = "attic";
ensureDBOwnership = true;
}
];
};
};

boot.loader.grub = {
Expand Down

0 comments on commit 3f0a9e9

Please sign in to comment.