Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc updates #380

Closed
wants to merge 70 commits into from
Closed
Show file tree
Hide file tree
Changes from 62 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
aa797a2
add janky tf
james-otten Apr 27, 2024
a4a5c3b
helm
james-otten Apr 28, 2024
c998325
actions
james-otten Apr 28, 2024
ec254ae
actions
james-otten Apr 28, 2024
9826412
Merge branch 'main' into james/infra
james-otten Apr 28, 2024
f4a5b00
suppress
james-otten Apr 28, 2024
8f86d67
cleanup
james-otten Apr 28, 2024
f99ac88
bug fix
james-otten Apr 28, 2024
c3cf969
testing infra updates
james-otten Apr 28, 2024
2b80d6d
updates
james-otten Apr 28, 2024
c86ed7c
fix cd
james-otten Apr 28, 2024
bfde716
pin action
james-otten Apr 28, 2024
fbfbc71
helm docs
james-otten Apr 28, 2024
76bab63
Merge branch 'main' into james/infra
james-otten Apr 29, 2024
c76b0d8
pin action
james-otten Apr 29, 2024
ad3df4a
Merge branch 'main' into james/infra
james-otten Apr 30, 2024
19f464a
Merge branch 'main' into james/infra
james-otten May 1, 2024
b614f9f
wording
james-otten May 3, 2024
e31bcc0
explain
james-otten May 3, 2024
0b3ad3f
leanr tooo speil
james-otten May 3, 2024
b0082a6
typo
james-otten May 4, 2024
ea7155d
rm extra file
james-otten May 4, 2024
5ef1be1
rm debug stuff
james-otten May 4, 2024
09b8c4d
typo
james-otten May 4, 2024
b5e9faf
Merge branch 'main' into james/infra
james-otten May 4, 2024
a42d0ac
docs
james-otten May 4, 2024
a57c398
Update infra/README.md
james-otten May 4, 2024
ae0e447
Update infra/tf/main.tf
james-otten May 4, 2024
e0b480d
simplify step 1
james-otten May 6, 2024
194d2c2
updates
james-otten May 6, 2024
a1df39f
janky stage2 provisioner
james-otten May 6, 2024
bdf542d
docs
james-otten May 6, 2024
0dc3af4
local provisioner for ssh key
james-otten May 7, 2024
ef3120a
Update infra/tf/gen_ssh_key.sh
james-otten May 10, 2024
137d196
fixes
WillNilges May 11, 2024
73c6d04
Provision more stuff locally
WillNilges May 12, 2024
afe682c
delete scripts
WillNilges May 12, 2024
5d7b702
add gitignore
WillNilges May 12, 2024
8218775
Update README
WillNilges May 12, 2024
865b5b1
Use example values files
WillNilges May 12, 2024
e135256
Theoretically create k3s config
WillNilges May 14, 2024
8f13f77
Comment out (what ought to be) dead code
WillNilges May 14, 2024
d7e813f
uhhhhhhhhhhhhhh
WillNilges May 15, 2024
50ed8fe
holy shit it fucking works
WillNilges May 15, 2024
3f66d07
delete dead code
WillNilges May 15, 2024
1f662b8
Get kubeconfig
WillNilges May 15, 2024
42875bb
First attempt at locally rendering
WillNilges May 15, 2024
879d389
Duct tape the package installations
WillNilges May 16, 2024
4b1b412
Theoretically try to install packages for two min
WillNilges May 16, 2024
13f3e1c
Update some stuff
WillNilges May 17, 2024
00338c8
Terraform can create our inventory
WillNilges May 18, 2024
8ccca6a
You can have a little jank, as a treat
WillNilges May 18, 2024
92d29d8
Remind me to add that later
WillNilges May 18, 2024
468fe33
Move cluster into helm chart
WillNilges May 18, 2024
d343010
oops
WillNilges May 18, 2024
dc797a3
installed with helm lol
WillNilges May 18, 2024
70b807c
fuck
WillNilges May 18, 2024
24b7e0e
Add ingress
WillNilges May 18, 2024
bb83ff6
updates
james-otten Jun 2, 2024
8781769
rm unused
james-otten Jun 2, 2024
49ce025
ansible
james-otten Jun 5, 2024
8b04736
updates
james-otten Jun 8, 2024
bda287d
updates
james-otten Jul 11, 2024
7039f0e
updates
james-otten Jul 11, 2024
25a75c2
make it work
james-otten Jul 15, 2024
c59657f
Merge remote-tracking branch 'origin/main' into james/in_fra_ception
james-otten Jul 16, 2024
a48de6d
updates
james-otten Jul 16, 2024
2fe8925
updates
james-otten Jul 16, 2024
d5ce5c1
make me a sandwitch
james-otten Jul 16, 2024
969b569
pin actions
james-otten Jul 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/checkov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: Checkov
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

permissions: read-all
Expand All @@ -24,14 +26,14 @@ jobs:
id: checkov
uses: bridgecrewio/checkov-action@0549dc60bddd4c55cb85c6c3a07072e3cf2ca48e
with:
skip_check: CKV_DOCKER_2,CKV_DOCKER_3
skip_check: CKV_DOCKER_2,CKV_DOCKER_3,CKV_SECRET_6
quiet: true
output_format: cli,sarif
output_file_path: console,results.sarif
download_external_modules: true

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
uses: github/codeql-action/upload-sarif@d39d31e687223d841ef683f52467bd88e9b21c14 # v3
if: success() || failure()
with:
sarif_file: results.sarif
47 changes: 47 additions & 0 deletions .github/workflows/helm_lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Lint and Test Chart

on: pull_request

permissions: read-all

jobs:
lint-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set up Helm
uses: azure/setup-helm@20d2b4f98d41febe2bbca46408499dbb535b6258 # v3
with:
version: v3.14.0

- uses: actions/setup-python@v4
with:
python-version: '3.12'
check-latest: true

- name: Set up chart-testing
uses: helm/chart-testing-action@e6669bcd63d7cb57cb4380c33043eebe5d111992 # v2.6.1

- name: Run chart-testing (list-changed)
id: list-changed
run: |
changed=$(ct list-changed --target-branch ${{ github.event.repository.default_branch }})
if [[ -n "$changed" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

- name: Run chart-testing (lint)
if: steps.list-changed.outputs.changed == 'true'
run: ct lint --target-branch ${{ github.event.repository.default_branch }}

- name: Create kind cluster
if: steps.list-changed.outputs.changed == 'true'
uses: helm/[email protected]

- name: Run chart-testing (install)
if: steps.list-changed.outputs.changed == 'true'
run: ct install --target-branch ${{ github.event.repository.default_branch }}
16 changes: 16 additions & 0 deletions .github/workflows/publish-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,19 @@ jobs:
if_key_exists: fail # replace / ignore / fail; optional (defaults to fail)
- name: Pull new Docker image
run: ssh ${{ secrets.GRANDSVC_SSH_TARGET }} "cd ${{ secrets.GRANDSVC_PROJECT_PATH }} && git pull && docker compose pull && docker compose up -d"

deploy_to_dev0:
name: Deploy to dev0
needs: push_to_registry
runs-on: ubuntu-latest
steps:
- name: Install SSH key
uses: shimataro/ssh-key-action@d4fffb50872869abe2d9a9098a6d9c5aa7d16be4 # v2
with:
key: ${{ secrets.DEV0_KEY }}
name: id_ed25519 # optional
known_hosts: ${{ secrets.DEV0_KNOWN_HOSTS }}
#config: ${{ secrets.CONFIG }} # ssh_config; optional
if_key_exists: fail # replace / ignore / fail; optional (defaults to fail)
- name: Pull new Docker image
run: ssh ${{ secrets.DEV0_SSH_TARGET }} "cd ${{ secrets.DEV0_PROJECT_PATH }} && git pull && cd infra/helm/meshdb && helm template . -f ../../../../values.yaml -f ../../../../secret.values.yaml | kubectl apply -f -"
36 changes: 36 additions & 0 deletions infra/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc

.terraform.lock.hcl
72 changes: 72 additions & 0 deletions infra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Meshdb Environment Setup

These instructions will set up a 4 node k3s cluster on proxmox.
- 1 "manager" node for control plane and to be used for deployments.
- 3 "agent" nodes to run services.

1. Clone this repository

2. Set up tfvars. See [proxmox provider](https://registry.terraform.io/providers/Telmate/proxmox/latest/docs). Create an API key in Proxmox, and disable Privilege Separation.
```
cd meshdb/infra/tf/
cp example.tfvars your_env.tfvars
# Modify your_env.tfvars to meet your needs
bash gen_ssh_key.sh dev0
```

3. Create the k3s cluster
```
terraform init -var-file=your_env.tfvars
terraform plan -var-file=your_env.tfvars
terraform apply -var-file=your_env.tfvars
```

4. Setup ansible, build the inventory, run the playbook using the keyfile generated in 2.
```
cd meshdb/infra/ansible
ansible-galaxy collection install cloud.terraform
ansible-playbook -i inventory.yaml install_packages.yaml -v --key-file ../tf/meshdbdev0
ansible-playbook -i inventory.yaml k8s_lb.yaml -v --key-file ../tf/meshdbdev0
```

<!-- 5. Install the `meshdb-cluster` chart.

```
cd meshdb/infra/helm/meshdb-cluster
# Modify values.yaml to meet your needs
helm template . -f values.yaml > meshdb-cluster.yaml
kubectl apply -f meshdb-cluster.yaml
``` -->

5. Create and update values + secrets in `values.yaml` and `secret.values.yaml`


```
cd meshdb/infra/helm/meshdb/
cp example.secret.values.yaml secret.values.yaml
cp example.values.yaml values.yaml
nano secret.values.yaml
nano values.yaml
```

6. Render the helm chart

<!--TODO: Use helm install for everything-->
<!-- helm install --kubeconfig='../../tf/k3s.yaml' -f values.yaml -f secret.values.yaml meshdb ./ -->

```
cd meshdb/infra/helm/meshdb
helm template . -f values.yaml -f secret.values.yaml > meshdb.yaml
```

<!--TODO: Have helm create NS and update instns to kubectl apply file-->

7. Deploy MeshDB!

```
cd meshdb/infra/meshdb
terraform init
terraform apply
```

8. If you need a superuser: `kubectl exec -it -n meshdbdev0 service/meshdb-meshweb bash` and `python manage.py createsuperuser`
5 changes: 5 additions & 0 deletions infra/ansible/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[defaults]
host_key_checking = False

[ssh_connection]
ssh_args = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o CheckHostIP=no'
3 changes: 3 additions & 0 deletions infra/ansible/create_inventory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- name: Create inventory
plugin: cloud.terraform.terraform_provider
project_path: ../tf
10 changes: 10 additions & 0 deletions infra/ansible/install_packages.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
- name: Install packages on each node
hosts: mgrs:workers
tasks:
- name: Install packages on each node
ansible.builtin.apt:
pkg:
- open-iscsi
- nfs-common
update_cache: true
become: true
4 changes: 4 additions & 0 deletions infra/ansible/inventory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
plugin: cloud.terraform.terraform_provider
project_path: "../tf"

104 changes: 104 additions & 0 deletions infra/ansible/k8s_lb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
- name: Setup k8s-lb
hosts: lb
tasks:
- name: Install deps
ansible.builtin.apt:
update_cache: true
pkg:
- iptables-persistent
become: true

- name: dummy0 interface
ansible.builtin.template:
src: ./lb_config/netplan_dummy0.yaml.j2
dest: /etc/netplan/dummy0.yaml
mode: "600"
become: true

- name: eth0 interface
ansible.builtin.template:
src: ./lb_config/netplan_50_cloud_init.yaml.j2
dest: /etc/netplan/50-cloud-init.yaml
mode: "600"
become: true

- name: Install frr
ansible.builtin.apt:
update_cache: true
pkg:
- frr
become: true
james-otten marked this conversation as resolved.
Show resolved Hide resolved

- name: Enable ospfd
ansible.builtin.lineinfile:
path: /etc/frr/daemons
search_string: ospfd=no
line: "ospfd=yes"
become: true

- name: Config template frr
ansible.builtin.template:
src: ./lb_config/frr.conf.j2
dest: /etc/frr/frr.conf
become: true

- name: Install haproxy
ansible.builtin.apt:
update_cache: true
pkg:
- haproxy
become: true

- name: Config template haproxy
ansible.builtin.template:
src: ./lb_config/haproxy.cfg
dest: /etc/haproxy/haproxy.cfg
become: true

- name: Iptables rules
ansible.builtin.template:
src: ./lb_config/iptables.j2
dest: /etc/iptables/rules.v4
become: true

- name: Restore iptables rules
ansible.builtin.command:
cmd: "bash -c '/sbin/iptables-restore < /etc/iptables/rules.v4 && touch /tmp/firewall_set'"
creates: /tmp/firewall_set
become: true

- name: Netplan apply
ansible.builtin.command:
cmd: "bash -c 'netplan apply && touch /tmp/netplan_applied'"
creates: /tmp/netplan_applied
become: true

- name: Restart and enable iptables service
ansible.builtin.service:
name: netfilter-persistent
state: restarted
enabled: true
become: true

- name: Restart and enable frr service
ansible.builtin.service:
name: frr
state: restarted
enabled: true
become: true

- name: Restart and enable haproxy service
ansible.builtin.service:
name: haproxy
state: restarted
enabled: true
become: true

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add comment explaining the reasoning behind the steps?

- name: net.ipv4.ip_forward
ansible.posix.sysctl:
name: net.ipv4.ip_forward
value: '1'
sysctl_set: true
state: present
reload: true
become: true
4 changes: 4 additions & 0 deletions infra/ansible/k8s_lb_config.yaml
james-otten marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
LB_HOSTNAME: k8s-lb
EXTERNAL_LISTEN_IP: "something"
INTERNAL_NETWORK_RANGE: 24
INTERNAL_NETWORK_MAC_ADDRESS: "something"
17 changes: 17 additions & 0 deletions infra/ansible/lb_config/frr.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
frr version 8.4.4
frr defaults traditional
hostname {{ LB_HOSTNAME }}
log syslog informational
no ip forwarding
no ipv6 forwarding
service integrated-vtysh-config
!
interface eth0
ip ospf cost 10
exit
!
router ospf
network {{ INTERNAL_NETWORK_BLOCK }} area 0
network {{ EXTERNAL_LISTEN_IP }}/32 area 0
exit
!
Loading
Loading