This commit is contained in:
nora 2023-08-26 23:47:11 +02:00
parent a143a02b4c
commit ee0c5f9cec
18 changed files with 3 additions and 341 deletions

View file

@ -1,22 +1,7 @@
# Infra setup # Infra setup
- VPS see `new` for the new infra
- nilstrieb.dev
- docker.nilstrieb.dev
- Github Pages ## things that shall not be forgotten
- blog.nilstrieb.dev
nilstrieb.dev redirects to blog.nilstrieb.dev there once was some custom k8s cluster setup in `./k8s-cluster`. it was incomplete and pretty cursed.
docker.nilstrieb.dev proxies to an internal registry container.
The VPS has an nginx server at the front.
# useful links
## Install mongosh
https://www.mongodb.com/docs/mongodb-shell/install/#std-label-mdb-shell-install
# fresh setup
Follow the README in `scripts/README.md`

View file

@ -1,7 +0,0 @@
#!/usr/bin/env bash
set -eu pipefail
./docker/setup_net.sh
./registry/run.sh
./nginx/run.sh

View file

@ -1,12 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>uwu</title>
</head>
<body>
meow :3
</body>
</html>

View file

@ -1,84 +0,0 @@
https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/
- make sure that swap is disabled
# containerd runtime
https://github.com/containerd/containerd/blob/main/docs/getting-started.md
```sh
# containerd
CRD_VERSION="1.7.0"
curl -L "https://github.com/containerd/containerd/releases/download/v$VERSION/containerd-$VERSION-linux-amd64.tar.gz" -o "containerd-$VERSION-linux-amd64.tar.gz"
sudo tar Cxzvf /usr/local "containerd-$CRD_VERSION-linux-amd64.tar.gz"
sudo mkdir -p /usr/local/lib/systemd/system
sudo curl https://raw.githubusercontent.com/containerd/containerd/main/containerd.service -o /usr/local/lib/systemd/system/containerd.service
sudo systemctl daemon-reload
sudo systemctl enable --now containerd
```
```sh
# runc
RUNC_VERSION="1.1.4"
curl -L "https://github.com/opencontainers/runc/releases/download/v$RUNC_VERSION/runc.amd64" -o runc.amd64
sudo install -m 755 runc.amd64 /usr/local/sbin/runc
```
```sh
# cni plugin
CNIP_VERSION="1.2.0"
curl -L "https://github.com/containernetworking/plugins/releases/download/v$CNIP_VERSION/cni-plugins-linux-amd64-v$CNIP_VERSION.tgz" -o "cni-plugins-linux-amd64-v$CNIP_VERSION.tgz"
sudo mkdir -p /opt/cni/bin
sudo tar Cxzvf /opt/cni/bin "cni-plugins-linux-amd64-v$CNIP_VERSION.tgz"
```
```sh
mkdir -p /etc/containerd
sudo bash -c 'containerd config default > /etc/containerd/config.toml'
```
Set to true in `/etc/containerd/config.toml`
```toml
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
...
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = true
```
```sh
sudo systemctl restart containerd
```
# set it up
```
sudo kubeadm init --control-plane-endpoint=k8s-control.nilstrieb.dev --pod-network-cidr=192.168.0.0/16
kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/tigera-operator.yaml
```
# networking
[callico](https://docs.tigera.io/calico)
# other
`kubectl taint nodes --all node-role.kubernetes.io/control-plane-` to allow scheduling on the control plane. disable if needed.
# sonobuoy
```sh
SONO_VERSION=0.56.16
curl -L "https://github.com/vmware-tanzu/sonobuoy/releases/download/v$SONO_VERSION/sonobuoy_$(echo $SONO_VERSION)_linux_amd64.tar.gz" -o "sonobuoy_$(echo $SONO_VERSION)_linux_amd64.tar.gz"
tar -xvf "sonobuoy_$(echo $SONO_VERSION)_linux_amd64.tar.gz"
```
```sh
./sonobuoy run --wait
```

View file

@ -1,27 +0,0 @@
# This section includes base Calico installation configuration.
# For more information, see: https://projectcalico.docs.tigera.io/master/reference/installation/api#operator.tigera.io/v1.Installation
apiVersion: operator.tigera.io/v1
kind: Installation
metadata:
name: default
spec:
# Configures Calico networking.
calicoNetwork:
# Note: The ipPools section cannot be modified post-install.
ipPools:
- blockSize: 26
cidr: 192.168.0.0/16
encapsulation: VXLANCrossSubnet
natOutgoing: Enabled
nodeSelector: all()
---
# This section configures the Calico API server.
# For more information, see: https://projectcalico.docs.tigera.io/master/reference/installation/api#operator.tigera.io/v1.APIServer
apiVersion: operator.tigera.io/v1
kind: APIServer
metadata:
name: default
spec: {}

View file

@ -1,29 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
spec:
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello-world
image: nginx:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: hello-world-service
spec:
selector:
app: hello-world
ports:
- port: 80
targetPort: 4000

View file

@ -1,3 +0,0 @@
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
cgroupDriver: systemd

View file

@ -1,6 +1,5 @@
{ {
email nilstrieb@gmail.com email nilstrieb@gmail.com
# acme_ca https://api.letsencrypt.org/directory
} }
# https://gist.github.com/ryanburnette/d13575c9ced201e73f8169d3a793c1a3 # https://gist.github.com/ryanburnette/d13575c9ced201e73f8169d3a793c1a3

View file

@ -1,6 +0,0 @@
apiVersion: v1
data:
DISCORD_TOKEN: QQ==
kind: Secret
metadata:
name: karin

View file

@ -1,34 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: karin
spec:
selector:
matchLabels:
app: karin
replicas: 1
template:
metadata:
labels:
app: karin
spec:
containers:
- name: court-bot
image: discord-court-bot:1.0
envFrom:
- configMapRef:
name: karin
- secretRef:
name: karin
- secretRef:
name: mongodb
---
apiVersion: v1
kind: ConfigMap
metadata:
name: karin
data:
RUST_LOG: DEBUG
GUILD_ID: "459006129670979584"
DB_NAME: karin
SET_GLOBAL: ''

View file

@ -1,8 +0,0 @@
apiVersion: v1
data:
MONGO_URI: bW9uZ29kYjovL21vbmdvLTAubW9uZ28uZGVmYXVsdC5zdmMuY2x1c3Rlci5sb2NhbDoyNzAxNw==
MONGO_INITDB_ROOT_USERNAME: cm9vdA==
MONGO_INITDB_ROOT_PASSWORD: QQ==
kind: Secret
metadata:
name: mongodb

View file

@ -1,57 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: mongo
labels:
app: mongo
spec:
ports:
- port: 27017
name: mongodb
clusterIP: None
selector:
app: mongo
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mongo
spec:
serviceName: mongo
selector:
matchLabels:
app: mongo
replicas: 1
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: mongo:latest
command:
- "mongod"
- "--bind_ip"
- "0.0.0.0"
resources:
limits:
cpu: 400m
memory: 200M
ports:
- containerPort: 27017
volumeMounts:
- name: mongodb-data
mountPath: /data/db
envFrom:
- secretRef:
name: mongodb
volumeClaimTemplates:
- metadata:
name: mongodb-data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "standard"
resources:
requests:
storage: 100M

View file

@ -1,23 +0,0 @@
# Setup
## Setup host
- Install docker
- Install minikube (https://minikube.sigs.k8s.io/docs/start/)
- Install helm (https://helm.sh/docs/intro/install/)
- Run `setup-env.sh`
## Start minikube
`minikube start`
`./scripts/minikube-setup`
## Install cert-manager
`./scripts/cert-manager.sh`
i
## Apply configs
First, apply all the configs in `./kube` directly. Only apply `server-ingress.yaml`, not `local-ingress.yaml`!
Then, apply all configs in `./kube/apps`.

View file

@ -1,7 +0,0 @@
#!/usr/bin/env sh
# https://getbetterdevops.io/k8s-ingress-with-letsencrypt/
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install cert-manager jetstack/cert-manager --namespace cert-manager --create-namespace --set installCRDs=true

View file

@ -1,4 +0,0 @@
#!/usr/bin/env sh
minikube addons enable ingress
minikube addons enable ingress-dns

View file

@ -1,14 +0,0 @@
#!/usr/bin/env sh
if kubectl cert-manager 2>/dev/null >/dev/null ;
then
echo "The cert-manger kubectl plugin is already installed"
else
CERT_MANAGER_KUBECTL_VERSION="v1.6.1"
echo "Installing the cert-manager kubectl plugin: $CERT_MANAGER_KUBECTL_VERSION"
curl -L -o kubectl-cert-manager.tar.gz "https://github.com/jetstack/cert-manager/releases/download/$CERT_MANAGER_KUBECTL_VERSION/kubectl-cert_manager-linux-amd64.tar.gz"
tar xzf kubectl-cert-manager.tar.gz
sudo mv kubectl-cert_manager /usr/local/bin
fi

View file

@ -1,3 +0,0 @@
FROM ubuntu:latest
CMD ["echo", "Hello, World!"]

View file

@ -1,4 +0,0 @@
#!/usr/bin/env sh
# Hugo frontend:
curl -H "Host: hugo-chat.nilstrieb.dev" 127.0.0.1/index.html