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 all 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@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # 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 }}
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: '3.11'
- name: "Upgrade pip"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/no_forgoten_migrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: '3.11'
- name: "Upgrade pip"
Expand Down
31 changes: 30 additions & 1 deletion .github/workflows/publish-and-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ name: Publish and Deploy

on:
push:
branches: [ main ]
branches: [ main, james/in_fra_ception ]

permissions: read-all

jobs:
push_to_registry:
name: Push Docker Image to Docker Hub
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Check out the repo
uses: actions/checkout@v4
Expand Down Expand Up @@ -40,6 +41,7 @@ jobs:
name: Deploy to grandsvc
needs: push_to_registry
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Install SSH key
uses: shimataro/ssh-key-action@d4fffb50872869abe2d9a9098a6d9c5aa7d16be4 # v2
Expand All @@ -61,3 +63,30 @@ jobs:

- name: Pull new Docker image
run: ssh ${{ secrets.GRANDSVC_SSH_USER }}@${{ secrets.GRANDSVC_TARGET_IP }} "cd ${{ secrets.GRANDSVC_PROJECT_PATH }} && git pull && docker compose pull && docker compose up -d"

deploy_to_dev0:
name: Deploy to dev3
#needs: push_to_registry
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/james/in_fra_ception'
steps:
- name: Install SSH key
uses: shimataro/ssh-key-action@d4fffb50872869abe2d9a9098a6d9c5aa7d16be4 # v2
with:
key: ${{ secrets.DEV3_KEY }}
name: id_ed25519 # optional
known_hosts: ${{ secrets.DEV3_KNOWN_HOSTS }}
#config: ${{ secrets.CONFIG }} # ssh_config; optional
if_key_exists: fail # replace / ignore / fail; optional (defaults to fail)

- name: Setup WireGuard
run: |
sudo apt install wireguard
echo "${{ secrets.WIREGUARD_PRIVATE_KEY }}" > privatekey
sudo ip link add dev wg1 type wireguard
sudo ip address add dev wg1 ${{ secrets.WIREGUARD_OVERLAY_NETWORK_IP }} peer ${{ secrets.DEV3_TARGET_IP }}
sudo wg set wg1 listen-port 48123 private-key privatekey peer ${{ secrets.WIREGUARD_PEER_PUBLIC_KEY }} allowed-ips 0.0.0.0/0 endpoint ${{ secrets.WIREGUARD_ENDPOINT }}
sudo ip link set up dev wg1

- name: Pull new Docker image
run: ssh ${{ secrets.DEV3_SSH_USER }}@${{ secrets.DEV3_TARGET_IP }} "sudo bash -c 'cd ${{ secrets.DEV3_PROJECT_PATH }} && git pull && cd infra/helm/meshdb && helm template . -f ../../../../values.yaml -f ../../../../secret.values.yaml | kubectl apply -f -'"
2 changes: 1 addition & 1 deletion .github/workflows/run_django_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@65d7f2d534ac1bc67fcd62888c5f4f3d2cb2b236 # v4
with:
python-version: '3.11'
- name: "Upgrade pip"
Expand Down
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
62 changes: 62 additions & 0 deletions infra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# 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, run the playbook.
```
cd meshdb/infra/ansible
ansible-galaxy collection install cloud.terraform
ansible-playbook -i inventory.yaml meshdb.yaml
```

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 --kubeconfig='../../tf/k3s.yaml' -f meshdb-cluster.yaml
# Watch everything come up
kubectl get all --kubeconfig='../../tf/k3s.yaml' --namespace longhorn-system
```

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. Install the `meshdb` chart.

```
cd meshdb/infra/helm/meshdb
helm template . -f secret.values.yaml -f values.yaml > meshdb.yaml
kubectl apply --kubeconfig='../../tf/k3s.yaml' -f meshdb.yaml
# Watch everything come up
kubectl get all --kubeconfig='../../tf/k3s.yaml' --namespace meshdbdev3
```

7. If you need a superuser: `kubectl exec -it -n meshdbdev3 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/inventory.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
plugin: cloud.terraform.terraform_provider
project_path: "../tf"
11 changes: 11 additions & 0 deletions infra/ansible/meshdb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- hosts: mgrs:workers
roles:
- role: meshdb-k8s-node

- hosts: mgrs
roles:
- role: meshdb-mgr

- hosts: lb
roles:
- role: k8s-lb
Loading
Loading