File tree Expand file tree Collapse file tree 6 files changed +108
-7
lines changed Expand file tree Collapse file tree 6 files changed +108
-7
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ this repo sets up three instances of netbox
6
6
7
7
# pre-req
8
8
```
9
- which terraform aws kubectl
9
+ which terraform aws kubectl helm
10
10
```
11
11
12
12
# how to use
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
- helm install nbc oci://ghcr.io/netbox-community/netbox-chart/netbox --namespace nbc --create-namespace
3
+ helm install netbox oci://ghcr.io/netbox-community/netbox-chart/netbox \
4
+ --namespace netbox \
5
+ --create-namespace \
6
+ --set persistence.enabled=false \
7
+ --set postgresql.enabled=false \
8
+ --set externalDatabase.host=$( terraform output -raw postgres_host) \
9
+ --set externalDatabase.password=$( terraform output -raw postgres_password) \
10
+ --set valkey.enabled=false \
11
+ --set tasksDatabase.host=$( terraform output -raw redis_host) \
12
+ --set cachingDatabase.host=$( terraform output -raw redis_host)
4
13
5
- # sleep 400
6
- # export POD_NAME=$(kubectl get pods --namespace "nbc" -l "app.kubernetes.io/name=netbox,app.kubernetes.io/instance=nbc" -o jsonpath="{.items[0].metadata.name}")
7
- # kubectl port-forward $POD_NAME 8080:8080 -n nbc
14
+ kubectl -n netbox create secret generic netbox-valkey \
15
+ --from-literal=cache_password=" " \
16
+ --from-literal=task_password=" "
17
+
18
+ # admin password
19
+ kubectl -n netbox get secrets netbox-superuser -o jsonpath=" {.data.password}" | base64 --decode
20
+
21
+ # port forward
22
+ # kubectl -n netbox port-forward svc/netbox 8080:80
8
23
9
24
# cleanup
10
- # helm -n nbc uninstall nbc
11
- # kubectl delete pvc -n nbc --all
25
+ # helm -n netbox uninstall netbox
Original file line number Diff line number Diff line change
1
+ resource "aws_db_subnet_group" "postgres" {
2
+ name = " postgres-subnet-group"
3
+ subnet_ids = module. vpc . private_subnets
4
+ }
5
+
6
+ resource "aws_security_group" "postgres" {
7
+ vpc_id = module. vpc . vpc_id
8
+ }
9
+
10
+ resource "aws_vpc_security_group_egress_rule" "postgres_allow_all_out" {
11
+ security_group_id = aws_security_group. postgres . id
12
+ cidr_ipv4 = " 0.0.0.0/0"
13
+ ip_protocol = " -1"
14
+ }
15
+
16
+ resource "aws_vpc_security_group_ingress_rule" "postgres_allow_psql_in" {
17
+ security_group_id = aws_security_group. postgres . id
18
+ cidr_ipv4 = " 0.0.0.0/0"
19
+ from_port = 5432
20
+ to_port = 5432
21
+ ip_protocol = " tcp"
22
+ }
23
+
24
+ resource "aws_db_instance" "postgres" {
25
+ identifier = " nb-pg-db"
26
+ engine = " postgres"
27
+ instance_class = " db.t3.medium"
28
+ username = " netbox"
29
+ password = var. postgres_password
30
+ db_name = " netbox"
31
+ allocated_storage = 20
32
+ db_subnet_group_name = aws_db_subnet_group. postgres . name
33
+ vpc_security_group_ids = [aws_security_group . postgres . id ]
34
+ skip_final_snapshot = true
35
+ }
36
+
37
+ output "postgres_host" {
38
+ value = aws_db_instance. postgres . address
39
+ }
40
+
41
+ output "postgres_password" {
42
+ value = var. postgres_password
43
+ sensitive = true
44
+ }
Original file line number Diff line number Diff line change
1
+ resource "aws_elasticache_subnet_group" "redis" {
2
+ name = " redis-subnet-group"
3
+ subnet_ids = module. vpc . private_subnets
4
+ }
5
+
6
+ resource "aws_security_group" "redis" {
7
+ name = " redis"
8
+ vpc_id = module. vpc . vpc_id
9
+ }
10
+
11
+ resource "aws_vpc_security_group_egress_rule" "redis_allow_all_out" {
12
+ security_group_id = aws_security_group. redis . id
13
+ cidr_ipv4 = " 0.0.0.0/0"
14
+ ip_protocol = " -1"
15
+ }
16
+
17
+ resource "aws_vpc_security_group_ingress_rule" "redis_allow_redis_in" {
18
+ security_group_id = aws_security_group. redis . id
19
+ cidr_ipv4 = " 0.0.0.0/0"
20
+ from_port = 6379
21
+ to_port = 6379
22
+ ip_protocol = " tcp"
23
+ }
24
+
25
+ resource "aws_elasticache_cluster" "redis" {
26
+ cluster_id = " nb-redis"
27
+ engine = " redis"
28
+ node_type = " cache.t3.micro"
29
+ num_cache_nodes = 1
30
+ parameter_group_name = " default.redis7"
31
+ subnet_group_name = aws_elasticache_subnet_group. redis . name
32
+ security_group_ids = [aws_security_group . redis . id ]
33
+ }
34
+
35
+ output "redis_host" {
36
+ value = aws_elasticache_cluster. redis . cache_nodes [0 ]. address
37
+ }
Original file line number Diff line number Diff line change 1
1
nbe_token = ""
2
2
nbe_console_password = "6chars"
3
3
nbe_admin_password = "12characters"
4
+ postgres_password = "yesql123"
Original file line number Diff line number Diff line change @@ -12,3 +12,8 @@ variable "nbe_admin_password" {
12
12
type = string
13
13
sensitive = true
14
14
}
15
+
16
+ variable "postgres_password" {
17
+ type = string
18
+ sensitive = true
19
+ }
You can’t perform that action at this time.
0 commit comments