-
Notifications
You must be signed in to change notification settings - Fork 24
IaC #362
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
Closed
Closed
IaC #362
Changes from 28 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
aa797a2
add janky tf
james-otten a4a5c3b
helm
james-otten c998325
actions
james-otten ec254ae
actions
james-otten 9826412
Merge branch 'main' into james/infra
james-otten f4a5b00
suppress
james-otten 8f86d67
cleanup
james-otten f99ac88
bug fix
james-otten c3cf969
testing infra updates
james-otten 2b80d6d
updates
james-otten c86ed7c
fix cd
james-otten bfde716
pin action
james-otten fbfbc71
helm docs
james-otten 76bab63
Merge branch 'main' into james/infra
james-otten c76b0d8
pin action
james-otten ad3df4a
Merge branch 'main' into james/infra
james-otten 19f464a
Merge branch 'main' into james/infra
james-otten b614f9f
wording
james-otten e31bcc0
explain
james-otten 0b3ad3f
leanr tooo speil
james-otten b0082a6
typo
james-otten ea7155d
rm extra file
james-otten 5ef1be1
rm debug stuff
james-otten 09b8c4d
typo
james-otten b5e9faf
Merge branch 'main' into james/infra
james-otten a42d0ac
docs
james-otten a57c398
Update infra/README.md
james-otten ae0e447
Update infra/tf/main.tf
james-otten e0b480d
simplify step 1
james-otten 194d2c2
updates
james-otten a1df39f
janky stage2 provisioner
james-otten bdf542d
docs
james-otten 0dc3af4
local provisioner for ssh key
james-otten ef3120a
Update infra/tf/gen_ssh_key.sh
james-otten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# 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. Configure a user for the [proxmox provider](https://registry.terraform.io/providers/Telmate/proxmox/latest/docs) and set up env vars. Create an API key in Proxmox, and disable Privilege Separation. | ||
2. Setup tfvars + ssh keys | ||
``` | ||
cd meshdb/infra/tf/ | ||
WillNilges marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cp example.tfvars your_env.tfvars | ||
# Modify your_env.tfvars to meet your needs | ||
ENV_NAME="garfield" # Matching meshdb_env_name | ||
ssh-keygen -t ed25519 -f ./meshdb$ENV_NAME | ||
``` | ||
3. Create the VMs that will host k3s | ||
``` | ||
terraform init | ||
terraform plan --var-file=your_env.tfvars | ||
terraform apply --var-file=your_env.tfvars | ||
``` | ||
WillNilges marked this conversation as resolved.
Show resolved
Hide resolved
|
||
4. Login via serial and figure out the IPs that were received from DHCP | ||
5. One time provisioning for the manager node | ||
|
||
``` | ||
target_host="<MGR IP>" | ||
scp infra/mgr_provision.sh ubuntu@$target_host:/home/ubuntu/mgr_provision.sh | ||
ssh -t ubuntu@$target_host "sudo bash /home/ubuntu/mgr_provision.sh" | ||
james-otten marked this conversation as resolved.
Show resolved
Hide resolved
|
||
``` | ||
|
||
6. Set the IP range for metallb, such as `10.70.90.80/29`, in `/opt/meshdb_mgmt/meshdb/infra/cluster/metallb_extra.yaml` and then deploy metallb and longhorn from the manager | ||
``` | ||
cd /opt/meshdb_mgmt/meshdb/infra/cluster/ | ||
terraform init | ||
terraform plan | ||
terraform apply | ||
# update address block in /opt/meshdb_mgmt/meshdb/infra/cluster/metallb_extra.yaml | ||
kubectl apply -f /opt/meshdb_mgmt/meshdb/infra/cluster/metallb_extra.yaml | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some instructions on how to get the kubeconfig might be good. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
``` | ||
|
||
7. Setup each node (from the manager) | ||
|
||
``` | ||
cd /opt/meshdb_mgmt/meshdb/infra/ | ||
declare -a target_nodes=("10.70.90.XX" "10.70.90.YY" "10.70.90.ZZ") | ||
|
||
for n in "${target_nodes[@]}" | ||
do | ||
bash setup_node.sh $n | ||
done | ||
``` | ||
james-otten marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
8. Update values + secrets in `/opt/meshdb_mgmt/values.yaml` and `/opt/meshdb_mgmt/secret.values.yaml` | ||
|
||
9. Deploy helm chart. Create the namespace you indicated in `/opt/meshdb_mgmt/values.yaml` | ||
|
||
``` | ||
your_ns="meshdbdev0" | ||
cd /opt/meshdb_mgmt/meshdb/infra/helm/meshdb/ | ||
kubectl create namespace $your_ns | ||
helm template . -f ../../../../values.yaml -f ../../../../secret.values.yaml | kubectl apply -f - | ||
kubectl get all -n $your_ns | ||
``` | ||
|
||
10. If you need a superuser: `kubectl exec -it -n meshdbdev0 service/meshdb-meshweb bash` and `python manage.py createsuperuser` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: helm.cattle.io/v1 | ||
kind: HelmChart | ||
metadata: | ||
name: longhorn | ||
namespace: longhorn-system | ||
spec: | ||
repo: https://charts.longhorn.io | ||
chart: longhorn | ||
targetNamespace: longhorn-system |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
provider "kubernetes" { | ||
config_path = "/etc/rancher/k3s/k3s.yaml" | ||
} | ||
|
||
# Create metallb-system | ||
resource "kubernetes_namespace" "metallb-system-ns" { | ||
metadata { | ||
name = "metallb-system" | ||
} | ||
} | ||
|
||
# Create metallb with the manifest | ||
resource "kubernetes_manifest" "metallb" { | ||
manifest = yamldecode(file("./metallb.yaml")) | ||
depends_on = [ | ||
kubernetes_namespace.metallb-system-ns | ||
] | ||
} | ||
|
||
# Create longhorn-system | ||
resource "kubernetes_namespace" "longhorn-system-ns" { | ||
metadata { | ||
name = "longhorn-system" | ||
} | ||
} | ||
|
||
# Create longhorn with the manifest | ||
resource "kubernetes_manifest" "longhorn" { | ||
manifest = yamldecode(file("./longhorn.yaml")) | ||
depends_on = [ | ||
kubernetes_namespace.longhorn-system-ns | ||
] | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
apiVersion: helm.cattle.io/v1 | ||
kind: HelmChart | ||
metadata: | ||
name: metallb | ||
namespace: metallb-system | ||
spec: | ||
repo: https://metallb.github.io/metallb | ||
chart: metallb | ||
targetNamespace: metallb-system |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
apiVersion: metallb.io/v1beta1 | ||
kind: IPAddressPool | ||
metadata: | ||
name: pool-1 | ||
namespace: metallb-system | ||
spec: | ||
addresses: | ||
- "10.70.90.80/29" | ||
--- | ||
apiVersion: metallb.io/v1beta1 | ||
kind: L2Advertisement | ||
metadata: | ||
name: k3s-l2 | ||
namespace: metallb-system | ||
spec: | ||
ipAddressPools: | ||
- pool-1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
apiVersion: v2 | ||
name: meshdb | ||
description: A Helm chart for Kubernetes | ||
|
||
# A chart can be either an 'application' or a 'library' chart. | ||
# | ||
# Application charts are a collection of templates that can be packaged into versioned archives | ||
# to be deployed. | ||
# | ||
# Library charts provide useful utilities or functions for the chart developer. They're included as | ||
# a dependency of application charts to inject those utilities and functions into the rendering | ||
# pipeline. Library charts do not define any templates and therefore cannot be deployed. | ||
type: application | ||
|
||
# This is the chart version. This version number should be incremented each time you make changes | ||
# to the chart and its templates, including the app version. | ||
# Versions are expected to follow Semantic Versioning (https://semver.org/) | ||
version: 0.1.0 | ||
|
||
# This is the version number of the application being deployed. This version number should be | ||
# incremented each time you make changes to the application. Versions are not expected to | ||
# follow Semantic Versioning. They should reflect the version the application is using. | ||
# It is recommended to use it with quotes. | ||
appVersion: "1.16.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
# meshdb | ||
|
||
A Helm chart for Kubernetes | ||
|
||
## Values | ||
|
||
| Key | Type | Default | Description | | ||
|-----|------|---------|-------------| | ||
| autoscaling.enabled | bool | `false` | | | ||
| autoscaling.maxReplicas | int | `100` | | | ||
| autoscaling.minReplicas | int | `1` | | | ||
| autoscaling.targetCPUUtilizationPercentage | int | `80` | | | ||
| aws.access_key_id | string | `"the_real_value"` | AWS access key id for S3 | | ||
| aws.secret_access_key | string | `"the_real_value"` | AWS secret access key for S3 | | ||
| fullnameOverride | string | `"meshdb"` | App name | | ||
| image.pullPolicy | string | `"Always"` | pullPolicy for all images, should be `Always` | | ||
| map.base_url | string | `"http://admin-map.grandsvc.mesh.nycmesh.net"` | Map url | | ||
| meshdb_app_namespace | string | `"meshdbdev0"` | K8s namespace used for all resources | | ||
| meshweb.affinity | object | `{}` | | | ||
| meshweb.backup_s3_base_folder | string | `"meshdb-backups/development/"` | Base folder for django postgres backups | | ||
| meshweb.backup_s3_bucket_name | string | `"meshdb-data-backups"` | Bucket used for django postgres backups | | ||
| meshweb.disable_pano_edits | string | `"True"` | Feature flag for disabling panorama edits | | ||
| meshweb.disable_profiling | string | `"True"` | Disable profiling in meshweb | | ||
| meshweb.django_secret_key | string | `"the_real_value"` | Django secret key | | ||
| meshweb.enable_debug | string | `"False"` | Enable `DEBUG` in meshweb | | ||
| meshweb.image.repository | string | `"willnilges/meshdb"` | Docker image repo for meshweb | | ||
| meshweb.image.tag | string | `"main"` | Docker image tag for meshweb | | ||
| meshweb.liveness_probe | string | `"true"` | Enable liveness probe with `true` all other values will disable it | | ||
| meshweb.nn_assign_psk | string | `"the_real_value"` | Legacy NN assign form password | | ||
| meshweb.nodeSelector | object | `{}` | | | ||
| meshweb.pano_github_token | string | `"the_real_value"` | Github token for downloading panorama | | ||
| meshweb.podSecurityContext | object | `{}` | | | ||
| meshweb.port | int | `8081` | Port used by meshweb (internally) | | ||
| meshweb.query_psk | string | `"the_real_value"` | Legacy query form password | | ||
| meshweb.resources | object | `{}` | | | ||
| meshweb.securityContext | object | `{}` | | | ||
| meshweb.static_pvc_name | string | `"meshdb-static-pvc"` | Name of the PVC for static content | | ||
| meshweb.static_pvc_size | string | `"1Gi"` | Size of the PVC for static content | | ||
| meshweb.tolerations | list | `[]` | | | ||
| nameOverride | string | `""` | | | ||
| nginx.affinity | object | `{}` | | | ||
| nginx.nodeSelector | object | `{}` | | | ||
| nginx.podSecurityContext | object | `{}` | | | ||
| nginx.port | int | `80` | Nginx port | | ||
| nginx.resources | object | `{}` | | | ||
| nginx.securityContext | object | `{}` | | | ||
| nginx.server_name | string | `"db.nycmesh.net"` | `server_name` used by nginx | | ||
| nginx.tolerations | list | `[]` | | | ||
| pelias.affinity | object | `{}` | | | ||
| pelias.nodeSelector | object | `{}` | | | ||
| pelias.podSecurityContext | object | `{}` | | | ||
| pelias.port | int | `6800` | Pelias port (internal) | | ||
| pelias.resources | object | `{}` | | | ||
| pelias.securityContext | object | `{}` | | | ||
| pelias.tolerations | list | `[]` | | | ||
| pg.affinity | object | `{}` | | | ||
| pg.dbname | string | `"meshdb"` | Postgres database name | | ||
| pg.liveness_probe | string | `"true"` | Enable liveness probe with `true` all other values will disable it | | ||
| pg.nodeSelector | object | `{}` | | | ||
| pg.password | string | `"the_real_value"` | Password for postgres | | ||
| pg.podSecurityContext | object | `{}` | | | ||
| pg.port | string | `"5432"` | Postgres port (internal) | | ||
| pg.pvc_name | string | `"meshdb-postgres-pvc"` | Name of the PVC for postgres | | ||
| pg.pvc_size | string | `"20Gi"` | Size of the PVC for postgres | | ||
| pg.resources | object | `{}` | | | ||
| pg.securityContext | object | `{}` | | | ||
| pg.tolerations | list | `[]` | | | ||
| pg.user | string | `"meshdb"` | Postgres user | | ||
| podAnnotations | object | `{}` | | | ||
| podLabels | object | `{}` | | | ||
| redis.affinity | object | `{}` | | | ||
| redis.liveness_probe | string | `"true"` | Enable liveness probe with `true` all other values will disable it | | ||
| redis.nodeSelector | object | `{}` | | | ||
| redis.podSecurityContext | object | `{}` | | | ||
| redis.port | int | `6379` | Redis port (internal) | | ||
| redis.resources | object | `{}` | | | ||
| redis.securityContext | object | `{}` | | | ||
| redis.tolerations | list | `[]` | | | ||
| uisp.psk | string | `"the_real_value"` | Password for UISP | | ||
| uisp.url | string | `"https://uisp.mesh.nycmesh.net/nms"` | UISP url | | ||
| uisp.user | string | `"nycmesh_readonly"` | Username for UISP | | ||
|
||
---------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
pg: | ||
password: the_real_value | ||
|
||
github-advanced-security[bot] marked this conversation as resolved.
Fixed
Show resolved
Hide resolved
|
||
aws: | ||
access_key_id: the_real_value | ||
secret_access_key: the_real_value | ||
|
||
meshweb: | ||
django_secret_key: the_real_value | ||
nn_assign_psk: the_real_value | ||
query_psk: the_real_value | ||
pano_github_token: the_real_value | ||
|
||
uisp: | ||
psk: the_real_value |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.