~repos /gromer

#golang#htmx#ssr

git clone https://pyrossh.dev/repos/gromer.git

gromer is a framework and cli to build multipage web apps in golang using htmx and alpinejs.


53b4bd21 Peter John

4 years ago
improve k8s
Dockerfile → example/Dockerfile RENAMED
File without changes
example/k8s/base/configmap.yaml DELETED
@@ -1,6 +0,0 @@
1
- apiVersion: v1
2
- kind: ConfigMap
3
- metadata:
4
- name: my-app
5
- data:
6
- ENV: OVERRIDDEN
example/k8s/base/deployment.yaml CHANGED
@@ -8,6 +8,9 @@ spec:
8
8
  spec:
9
9
  containers:
10
10
  - name: my-app
11
- image: example:develop
11
+ image: example:latest
12
12
  ports:
13
13
  - containerPort: 3000
14
+ envFrom:
15
+ - secretRef:
16
+ name: my-app
example/k8s/base/kubegres.yaml ADDED
@@ -0,0 +1,21 @@
1
+ apiVersion: kubegres.reactive-tech.io/v1
2
+ kind: Kubegres
3
+ metadata:
4
+ name: kubegres
5
+ spec:
6
+ replicas: 3
7
+ image: postgres:14.1
8
+ database:
9
+ size: 1Gi
10
+ env:
11
+ - name: POSTGRES_PASSWORD
12
+ valueFrom:
13
+ secretKeyRef:
14
+ name: my-app
15
+ key: POSTGRES_PASSWORD
16
+
17
+ - name: POSTGRES_REPLICATION_PASSWORD
18
+ valueFrom:
19
+ secretKeyRef:
20
+ name: my-app
21
+ key: POSTGRES_REPLICATION_PASSWORD
example/k8s/base/kustomization.yaml CHANGED
@@ -4,8 +4,12 @@ kind: Kustomization
4
4
  namespace: my-app
5
5
  commonLabels:
6
6
  app: my-app
7
+
7
8
  resources:
8
9
  - deployment.yaml
9
- - configmap.yaml
10
10
  - service.yaml
11
- - ingress.yaml
11
+ - ingress.yaml
12
+ - kubegres.yaml
13
+
14
+ configurations:
15
+ - nameReference.yaml
example/k8s/base/nameReference.yaml ADDED
@@ -0,0 +1,5 @@
1
+ nameReference:
2
+ - kind: Secret
3
+ fieldSpecs:
4
+ - kind: Kubegres
5
+ path: spec/env/valueFrom/secretKeyRef/name
example/k8s/development/configmap.yaml DELETED
@@ -1,7 +0,0 @@
1
- apiVersion: v1
2
- kind: ConfigMap
3
- metadata:
4
- name: my-app
5
- data:
6
- ENV: development
7
- DATABASE_URL: postgres://postgres:demo@127.0.0.1:5432/postgres?sslmode=disable
example/k8s/development/kustomization.yaml DELETED
@@ -1,16 +0,0 @@
1
- apiVersion: kustomize.config.k8s.io/v1beta1
2
- kind: Kustomization
3
-
4
- namePrefix: development-
5
- namespace: development-my-app
6
- commonLabels:
7
- environment: development
8
-
9
- bases:
10
- - ../base
11
-
12
- resources:
13
- - namespace.yaml
14
-
15
- patchesStrategicMerge:
16
- - configmap.yaml
example/k8s/integration/configmap.yaml DELETED
@@ -1,7 +0,0 @@
1
- apiVersion: v1
2
- kind: ConfigMap
3
- metadata:
4
- name: my-app
5
- data:
6
- ENV: integration
7
- POSTGRES_CONN_URL: hello
example/k8s/integration/kustomization.yaml DELETED
@@ -1,16 +0,0 @@
1
- apiVersion: kustomize.config.k8s.io/v1beta1
2
- kind: Kustomization
3
-
4
- namePrefix: integration-
5
- namespace: integration-my-app
6
- commonLabels:
7
- environment: integration
8
-
9
- bases:
10
- - ../base
11
-
12
- resources:
13
- - namespace.yaml
14
-
15
- patchesStrategicMerge:
16
- - configmap.yaml
example/k8s/integration/namespace.yaml DELETED
@@ -1,4 +0,0 @@
1
- apiVersion: v1
2
- kind: Namespace
3
- metadata:
4
- name: integration-my-app
example/k8s/overlays/development/kustomization.yaml ADDED
@@ -0,0 +1,27 @@
1
+ apiVersion: kustomize.config.k8s.io/v1beta1
2
+ kind: Kustomization
3
+
4
+ namePrefix: development-
5
+ namespace: development-my-app
6
+ commonLabels:
7
+ environment: development
8
+
9
+ bases:
10
+ - ../../base
11
+
12
+ resources:
13
+ - namespace.yaml
14
+
15
+ images:
16
+ - name: example
17
+ newName: example
18
+ newTag: latest
19
+
20
+ secretGenerator:
21
+ - name: my-app
22
+ namespace: development-my-app
23
+ literals:
24
+ - NAMESPACE=development
25
+ - POSTGRES_PASSWORD=password
26
+ - POSTGRES_REPLICATION_PASSWORD=password
27
+ - DATABASE_URL=postgres://postgres:password@development-kubegres:5432/postgres?sslmode=disable
example/k8s/{development → overlays/development}/namespace.yaml RENAMED
File without changes
example/k8s/production/configmap.yaml DELETED
@@ -1,7 +0,0 @@
1
- apiVersion: v1
2
- kind: ConfigMap
3
- metadata:
4
- name: my-app
5
- data:
6
- ENV: production
7
- POSTGRES_CONN_URL: hello
example/k8s/production/kustomization.yaml DELETED
@@ -1,16 +0,0 @@
1
- apiVersion: kustomize.config.k8s.io/v1beta1
2
- kind: Kustomization
3
-
4
- namePrefix: production-
5
- namespace: production-my-app
6
- commonLabels:
7
- environment: production
8
-
9
- bases:
10
- - ../base
11
-
12
- resources:
13
- - namespace.yaml
14
-
15
- patchesStrategicMerge:
16
- - configmap.yaml
example/k8s/production/namespace.yaml DELETED
@@ -1,4 +0,0 @@
1
- apiVersion: v1
2
- kind: Namespace
3
- metadata:
4
- name: production-my-app
example/makefile CHANGED
@@ -25,13 +25,16 @@ build: export GOARCH=amd64
25
25
  build:
26
26
  go build -o main
27
27
 
28
- build-image:
28
+ docker-build:
29
- cd .. && docker build -t example:develop .
29
+ docker build -f ../example/Dockerfile -t example:latest ../
30
30
 
31
- run-image: export DATABASE_URL=postgres://postgres:demo@docker.for.mac.host.internal:5432/postgres?sslmode=disable
31
+ docker-run: export DATABASE_URL=postgres://postgres:demo@docker.for.mac.host.internal:5432/postgres?sslmode=disable
32
- run-image:
32
+ docker-run:
33
- docker run -p 3000:3000 -e DATABASE_URL=$$DATABASE_URL example:develop
33
+ docker run -p 3000:3000 -e DATABASE_URL=$$DATABASE_URL example:latest
34
34
 
35
- k8s-local:
35
+ k8s-setup:
36
+ kubectl apply -f https://raw.githubusercontent.com/reactive-tech/kubegres/v1.13/kubegres.yaml
36
37
  kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.0.0/deploy/static/provider/cloud/deploy.yaml
38
+
39
+ k8s-run:
37
- kubectl apply -k k8s/development
40
+ kubectl apply -k k8s/overlays/development
example/terraform.tf DELETED
@@ -1,82 +0,0 @@
1
- terraform {
2
- required_providers {
3
- docker = {
4
- source = "kreuzwerker/docker"
5
- version = "2.15.0"
6
- }
7
- aws = {
8
- source = "hashicorp/aws"
9
- version = "3.37.0"
10
- }
11
- }
12
- }
13
-
14
- provider "aws" {
15
- region = "ap-south-1"
16
- }
17
-
18
- resource "docker_image" "example" {
19
- name = "example"
20
- build {
21
- path = "../"
22
- tag = ["example:develop"]
23
- }
24
- }
25
-
26
- resource "aws_vpc" "example" {
27
- cidr_block = "10.0.0.0/16"
28
- }
29
-
30
- resource "aws_subnet" "example1" {
31
- vpc_id = aws_vpc.example.id
32
- availability_zone = "ap-south-1a"
33
- cidr_block = "10.0.1.0/24"
34
- }
35
-
36
- resource "aws_subnet" "example2" {
37
- vpc_id = aws_vpc.example.id
38
- availability_zone = "ap-south-1b"
39
- cidr_block = "10.0.2.0/24"
40
- }
41
-
42
- resource "aws_db_subnet_group" "example" {
43
- name = "example"
44
- subnet_ids = [aws_subnet.example1.id, aws_subnet.example2.id]
45
- }
46
-
47
- resource "random_password" "example" {
48
- length = 24
49
- special = true
50
- override_special = "!#$%^*()-=+_?{}|"
51
- }
52
-
53
- # random_password.example.result
54
-
55
- # resource "aws_ssm_parameter" "example" {
56
- # name = "database-master-password"
57
- # type = "SecureString"
58
- # value = random_password.example.result
59
- # }
60
-
61
- resource "aws_rds_cluster" "example" {
62
- cluster_identifier = "example"
63
- engine = "aurora-postgresql"
64
- engine_mode = "serverless"
65
- database_name = "postgres"
66
- enable_http_endpoint = false
67
- master_username = "root"
68
- master_password = "chang333eme321"
69
- backup_retention_period = 1
70
- skip_final_snapshot = true
71
- db_subnet_group_name = aws_db_subnet_group.example.name
72
- # vpc_security_group_ids = [aws_security_group.rds.id]
73
- # parameter_group_name = aws_db_parameter_group.education.name
74
-
75
- scaling_configuration {
76
- auto_pause = true
77
- min_capacity = 2
78
- max_capacity = 4
79
- seconds_until_auto_pause = 300
80
- timeout_action = "ForceApplyCapacityChange"
81
- }
82
- }