Skip to content

Commit d23f7b2

Browse files
committed
Adds rancher deploy
Signed-off-by: Arthur Diniz <arthurbdiniz@gmail.com>
1 parent 5962548 commit d23f7b2

7 files changed

Lines changed: 348 additions & 18 deletions

File tree

deploy/production/postgres.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: postgres-production-svc
6+
namespace: sigs-production
7+
labels:
8+
app: postgres
9+
spec:
10+
ports:
11+
- port: 5432
12+
selector:
13+
app: postgres
14+
tier: database
15+
---
16+
apiVersion: apps/v1beta2
17+
kind: Deployment
18+
metadata:
19+
name: postgres-sigs-production
20+
namespace: sigs-production
21+
labels:
22+
app: postgres
23+
spec:
24+
replicas: 1
25+
selector:
26+
matchLabels:
27+
app: postgres
28+
tier: database
29+
template:
30+
metadata:
31+
name: postgres
32+
labels:
33+
app: postgres
34+
tier: database
35+
spec:
36+
volumes:
37+
- name: postgres-pv
38+
persistentVolumeClaim:
39+
claimName: postgres-production-pvc
40+
containers:
41+
- name: postgres
42+
image: postgres:11.2
43+
env:
44+
- name: POSTGRES_USER
45+
valueFrom:
46+
secretKeyRef:
47+
name: "sigs-production-secrets"
48+
key: "db-user"
49+
- name: POSTGRES_PASSWORD
50+
valueFrom:
51+
secretKeyRef:
52+
name: "sigs-production-secrets"
53+
key: "db-user-pass"
54+
- name: POSTGRES_PORT
55+
value: "5432"
56+
- name: POSTGRES_DB
57+
value: "SIGS_production"
58+
ports:
59+
- containerPort: 5432
60+
---
61+
kind: PersistentVolumeClaim
62+
apiVersion: v1
63+
metadata:
64+
name: postgres-production-pvc
65+
namespace: sigs-production
66+
spec:
67+
accessModes:
68+
- ReadWriteOnce
69+
resources:
70+
requests:
71+
storage: 8Gi

deploy/production/sigs.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
kind: Ingress
3+
apiVersion: extensions/v1beta1
4+
metadata:
5+
name: sigs-ingress
6+
namespace: sigs-production
7+
labels:
8+
app: sigs-production
9+
annotations:
10+
nginx.ingress.kubernetes.io/ssl-redirect: "true"
11+
certmanager.k8s.io/cluster-issuer: letsencrypt-prod
12+
spec:
13+
rules:
14+
- host: sigs.lappis.rocks
15+
http:
16+
paths:
17+
- backend:
18+
serviceName: sigs-production-svc
19+
servicePort: 80
20+
tls:
21+
- hosts:
22+
- sigs.lappis.rocks
23+
secretName: sigs-production-letsencrypt-prod-crt
24+
---
25+
apiVersion: v1
26+
kind: Service
27+
metadata:
28+
name: sigs-production-svc
29+
namespace: sigs-production
30+
labels:
31+
app: sigs-production
32+
spec:
33+
ports:
34+
- port: 80
35+
targetPort: 3000
36+
protocol: TCP
37+
name: http
38+
selector:
39+
app: sigs-production
40+
---
41+
kind: Deployment
42+
apiVersion: apps/v1
43+
metadata:
44+
name: sigs-deployment
45+
namespace: sigs-production
46+
labels:
47+
app: sigs-production
48+
spec:
49+
selector:
50+
matchLabels:
51+
app: sigs-production
52+
replicas: 1
53+
template:
54+
metadata:
55+
labels:
56+
app: sigs-production
57+
spec:
58+
containers:
59+
- name: sigs-production
60+
image: projetosigs/sigs-gces:stable
61+
imagePullPolicy: Always
62+
ports:
63+
- containerPort: 3000
64+
protocol: TCP
65+
env:
66+
- name: SECRET_KEY_BASE
67+
valueFrom:
68+
secretKeyRef:
69+
name: "sigs-production-secrets"
70+
key: "app-secret-key"
71+
- name: POSTGRES_USER
72+
valueFrom:
73+
secretKeyRef:
74+
name: "sigs-production-secrets"
75+
key: "db-user"
76+
- name: POSTGRES_PASSWORD
77+
valueFrom:
78+
secretKeyRef:
79+
name: "sigs-production-secrets"
80+
key: "db-user-pass"
81+
- name: POSTGRES_PORT
82+
value: "5432"
83+
- name: POSTGRES_DB
84+
value: "SIGS_production"
85+
- name: POSTGRES_HOST
86+
value: postgres-production-svc
87+
- name: SIGS_DOMAIN
88+
value: sigs.lappis.rocks

deploy/staging-deploy.sh

100755100644
File mode changed.

deploy/staging/postgres.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: postgres-staging-svc
6+
namespace: sigs-staging
7+
labels:
8+
app: postgres
9+
spec:
10+
ports:
11+
- port: 5432
12+
selector:
13+
app: postgres
14+
tier: database
15+
---
16+
apiVersion: apps/v1beta2
17+
kind: Deployment
18+
metadata:
19+
name: postgres-sigs-staging
20+
namespace: sigs-staging
21+
labels:
22+
app: postgres
23+
spec:
24+
replicas: 1
25+
selector:
26+
matchLabels:
27+
app: postgres
28+
tier: database
29+
template:
30+
metadata:
31+
name: postgres
32+
labels:
33+
app: postgres
34+
tier: database
35+
spec:
36+
volumes:
37+
- name: postgres-pv
38+
persistentVolumeClaim:
39+
claimName: postgres-staging-pvc
40+
containers:
41+
- name: postgres
42+
image: postgres:11.2
43+
env:
44+
- name: POSTGRES_USER
45+
valueFrom:
46+
secretKeyRef:
47+
name: "sigs-staging-secrets"
48+
key: "db-user"
49+
- name: POSTGRES_PASSWORD
50+
valueFrom:
51+
secretKeyRef:
52+
name: "sigs-staging-secrets"
53+
key: "db-user-pass"
54+
- name: POSTGRES_PORT
55+
value: "5432"
56+
- name: POSTGRES_DB
57+
value: "SIGS_production"
58+
ports:
59+
- containerPort: 5432
60+
---
61+
kind: PersistentVolumeClaim
62+
apiVersion: v1
63+
metadata:
64+
name: postgres-staging-pvc
65+
namespace: sigs-staging
66+
spec:
67+
accessModes:
68+
- ReadWriteOnce
69+
resources:
70+
requests:
71+
storage: 8Gi

deploy/staging/sigs.yaml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
---
2+
kind: Ingress
3+
apiVersion: extensions/v1beta1
4+
metadata:
5+
name: sigs-ingress
6+
namespace: sigs-staging
7+
labels:
8+
app: sigs-staging
9+
annotations:
10+
nginx.ingress.kubernetes.io/ssl-redirect: "true"
11+
certmanager.k8s.io/cluster-issuer: letsencrypt-prod
12+
spec:
13+
rules:
14+
- host: sigs.dev.lappis.rocks
15+
http:
16+
paths:
17+
- backend:
18+
serviceName: sigs-staging-svc
19+
servicePort: 80
20+
tls:
21+
- hosts:
22+
- sigs.dev.lappis.rocks
23+
secretName: sigs-staging-letsencrypt-prod-crt
24+
---
25+
apiVersion: v1
26+
kind: Service
27+
metadata:
28+
name: sigs-staging-svc
29+
namespace: sigs-staging
30+
labels:
31+
app: sigs-staging
32+
spec:
33+
ports:
34+
- port: 80
35+
targetPort: 3000
36+
protocol: TCP
37+
name: http
38+
selector:
39+
app: sigs-staging
40+
---
41+
kind: Deployment
42+
apiVersion: apps/v1
43+
metadata:
44+
name: sigs-deployment
45+
namespace: sigs-staging
46+
labels:
47+
app: sigs-staging
48+
spec:
49+
selector:
50+
matchLabels:
51+
app: sigs-staging
52+
replicas: 1
53+
template:
54+
metadata:
55+
labels:
56+
app: sigs-staging
57+
spec:
58+
containers:
59+
- name: sigs-staging
60+
image: projetosigs/sigs-gces:latest
61+
imagePullPolicy: Always
62+
ports:
63+
- containerPort: 3000
64+
protocol: TCP
65+
env:
66+
- name: SECRET_KEY_BASE
67+
valueFrom:
68+
secretKeyRef:
69+
name: "sigs-staging-secrets"
70+
key: "app-secret-key"
71+
- name: POSTGRES_USER
72+
valueFrom:
73+
secretKeyRef:
74+
name: "sigs-staging-secrets"
75+
key: "db-user"
76+
- name: POSTGRES_PASSWORD
77+
valueFrom:
78+
secretKeyRef:
79+
name: "sigs-staging-secrets"
80+
key: "db-user-pass"
81+
- name: POSTGRES_PORT
82+
value: "5432"
83+
- name: POSTGRES_DB
84+
value: "SIGS_production"
85+
- name: POSTGRES_HOST
86+
value: postgres-staging-svc
87+
- name: SIGS_DOMAIN
88+
value: sigs.lappis.rocks

docker/dev/entrypoint.sh

100755100644
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
function_postgres_ready() {
44
ruby << END
5-
require 'pg'
6-
begin
7-
PG.connect(dbname: "$POSTGRES_DB", user: "$POSTGRES_USER", password: "$POSTGRES_PASSWORD", host: "postgres")
8-
rescue
9-
exit -1
10-
else
11-
exit 0
12-
end
5+
require 'pg'
6+
puts 'Version of libpg: ' + PG.library_version.to_s
7+
begin
8+
con = PG.connect( dbname: "$POSTGRES_DB",
9+
user: "$POSTGRES_USER",
10+
host: "$POSTGRES_HOST",
11+
password: "$POSTGRES_PASSWORD")
12+
rescue PG::Error => e
13+
puts e.message
14+
exit -1
15+
ensure
16+
con.close if con
17+
exit 0
18+
end
1319
END
1420
}
1521

docker/prod/entrypoint.sh

100755100644
Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22

33
function_postgres_ready() {
44
ruby << END
5-
require 'pg'
6-
begin
7-
PG.connect(dbname: "$POSTGRES_DB", user: "$POSTGRES_USER", password: "$POSTGRES_PASSWORD", host: "postgres")
8-
rescue
9-
exit -1
10-
else
11-
exit 0
12-
end
5+
require 'pg'
6+
puts 'Version of libpg: ' + PG.library_version.to_s
7+
begin
8+
con = PG.connect( dbname: "$POSTGRES_DB",
9+
user: "$POSTGRES_USER",
10+
host: "$POSTGRES_HOST",
11+
password: "$POSTGRES_PASSWORD")
12+
rescue PG::Error => e
13+
puts e.message
14+
exit -1
15+
ensure
16+
con.close if con
17+
exit 0
18+
end
1319
END
1420
}
1521

@@ -32,5 +38,5 @@ if [ -f $pidfile ]; then
3238
rm $pidfile
3339
fi
3440

35-
#bundle exec rails s -p 3000 -b 0.0.0.0 -e production
36-
bundle exec puma -C config/puma.rb
41+
bundle exec rails s -p 3000 -b 0.0.0.0 -e production
42+
#bundle exec puma -C config/puma.rb

0 commit comments

Comments
 (0)