Skip to content

Commit 82facc2

Browse files
committed
[docker] Adding HTTPS & affinity working in replica set & standalone case
1 parent a771f1f commit 82facc2

8 files changed

+84
-34
lines changed

bin/docker/k8s/countly-api-service.yaml

-12
This file was deleted.

bin/docker/k8s/countly-api.yaml

+24-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: countly-api
5+
spec:
6+
ports:
7+
- port: 3001
8+
protocol: TCP
9+
targetPort: 3001
10+
selector:
11+
app: countly-api
12+
type: NodePort
13+
---
114
apiVersion: apps/v1
215
kind: Deployment
316
metadata:
@@ -16,10 +29,18 @@ spec:
1629
podAntiAffinity:
1730
requiredDuringSchedulingIgnoredDuringExecution:
1831
- labelSelector:
32+
matchExpressions:
33+
- key: app
34+
operator: In
35+
values:
36+
- countly-api
37+
- mongo # in case you don't use replica set, give your mongodb pod label app=mongo to ensure it's not on the same node with API
1938
topologyKey: "kubernetes.io/hostname"
2039
containers:
2140
- name: countly-api
2241
image: countly/api:19.08.1
42+
# image: gcr.io/countly-01/api:19.08.1 # Enterprise Edition
43+
imagePullPolicy: Always
2344
ports:
2445
- containerPort: 3001
2546
readinessProbe:
@@ -32,9 +53,10 @@ spec:
3253
env:
3354
- name: COUNTLY_PLUGINS
3455
value: "mobile,web,desktop,plugins,density,locale,browser,sources,views,enterpriseinfo,logger,systemlogs,errorlogs,populator,reports,crashes,push,star-rating,slipping-away-users,compare,server-stats,dbviewer,assistant,plugin-upload,times-of-day,compliance-hub,video-intelligence-monetization,alerts,onboarding"
56+
# Enterprise Edition: value: "mobile,web,desktop,plugins,density,locale,browser,sources,views,drill,funnels,concurrent_users,retention_segments,revenue,logger,systemlogs,errorlogs,populator,reports,crashes,push,block,restrict,users,geo,star-rating,slipping-away-users,compare,server-stats,dashboards,assistant,flows,dbviewer,cohorts,crash_symbolication,crashes-jira,groups,white-labeling,plugin-upload,alerts,times-of-day,compliance-hub,onboarding,remote-config,formulas,ab-testing"
3557
- name: COUNTLY_CONFIG_API_FILESTORAGE
3658
value: "gridfs"
3759
- name: COUNTLY_CONFIG_API_MONGODB
38-
value: "mongodb://db-mongodb-replicaset-0.db-mongodb-replicaset:27017,db-mongodb-replicaset-1.db-mongodb-replicaset:27017,db-mongodb-replicaset-2.db-mongodb-replicaset:27017/countly?replicaSet=rs0"
60+
value: "mongodb://mongo-mongodb-replicaset-0.mongo-mongodb-replicaset:27017,mongo-mongodb-replicaset-1.mongo-mongodb-replicaset:27017,mongo-mongodb-replicaset-2.mongo-mongodb-replicaset:27017/countly?replicaSet=rs0"
3961
- name: COUNTLY_CONFIG_FRONTEND_MONGODB
40-
value: "mongodb://db-mongodb-replicaset-0.db-mongodb-replicaset:27017,db-mongodb-replicaset-1.db-mongodb-replicaset:27017,db-mongodb-replicaset-2.db-mongodb-replicaset:27017/countly?replicaSet=rs0"
62+
value: "mongodb://mongo-mongodb-replicaset-0.mongo-mongodb-replicaset:27017,mongo-mongodb-replicaset-1.mongo-mongodb-replicaset:27017,mongo-mongodb-replicaset-2.mongo-mongodb-replicaset:27017/countly?replicaSet=rs0"

bin/docker/k8s/countly-frontend-service.yaml

-12
This file was deleted.

bin/docker/k8s/countly-frontend.yaml

+30-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: countly-frontend
5+
spec:
6+
ports:
7+
- port: 6001
8+
protocol: TCP
9+
targetPort: 6001
10+
selector:
11+
app: countly-frontend
12+
type: NodePort
13+
---
114
apiVersion: apps/v1
215
kind: Deployment
316
metadata:
@@ -12,9 +25,22 @@ spec:
1225
labels:
1326
app: countly-frontend
1427
spec:
28+
affinity:
29+
podAffinity:
30+
requiredDuringSchedulingIgnoredDuringExecution:
31+
- labelSelector:
32+
matchExpressions:
33+
- key: app
34+
operator: In
35+
values:
36+
- mongo
37+
- mongodb-replicaset
38+
topologyKey: "kubernetes.io/hostname"
1539
containers:
1640
- name: countly-frontend
17-
image: countly/frontend:19.08.1
41+
image: countly/api:19.08.1
42+
# image: gcr.io/countly-01/frontend:19.08.1 # Enterprise Edition
43+
imagePullPolicy: Always
1844
ports:
1945
- containerPort: 6001
2046
readinessProbe:
@@ -26,9 +52,10 @@ spec:
2652
env:
2753
- name: COUNTLY_PLUGINS
2854
value: "mobile,web,desktop,plugins,density,locale,browser,sources,views,enterpriseinfo,logger,systemlogs,errorlogs,populator,reports,crashes,push,star-rating,slipping-away-users,compare,server-stats,dbviewer,assistant,plugin-upload,times-of-day,compliance-hub,video-intelligence-monetization,alerts,onboarding"
55+
# Enterprise Edition: value: "mobile,web,desktop,plugins,density,locale,browser,sources,views,drill,funnels,concurrent_users,retention_segments,revenue,logger,systemlogs,errorlogs,populator,reports,crashes,push,block,restrict,users,geo,star-rating,slipping-away-users,compare,server-stats,dashboards,assistant,flows,dbviewer,cohorts,crash_symbolication,crashes-jira,groups,white-labeling,plugin-upload,alerts,times-of-day,compliance-hub,onboarding,remote-config,formulas,ab-testing"
2956
- name: COUNTLY_CONFIG_API_FILESTORAGE
3057
value: "gridfs"
3158
- name: COUNTLY_CONFIG_API_MONGODB
32-
value: "mongodb://db-mongodb-replicaset-0.db-mongodb-replicaset:27017,db-mongodb-replicaset-1.db-mongodb-replicaset:27017,db-mongodb-replicaset-2.db-mongodb-replicaset:27017/countly?replicaSet=rs0"
59+
value: "mongodb://mongo-mongodb-replicaset-0.mongo-mongodb-replicaset:27017,mongo-mongodb-replicaset-1.mongo-mongodb-replicaset:27017,mongo-mongodb-replicaset-2.mongo-mongodb-replicaset:27017/countly?replicaSet=rs0"
3360
- name: COUNTLY_CONFIG_FRONTEND_MONGODB
34-
value: "mongodb://db-mongodb-replicaset-0.db-mongodb-replicaset:27017,db-mongodb-replicaset-1.db-mongodb-replicaset:27017,db-mongodb-replicaset-2.db-mongodb-replicaset:27017/countly?replicaSet=rs0"
61+
value: "mongodb://mongo-mongodb-replicaset-0.mongo-mongodb-replicaset:27017,mongo-mongodb-replicaset-1.mongo-mongodb-replicaset:27017,mongo-mongodb-replicaset-2.mongo-mongodb-replicaset:27017/countly?replicaSet=rs0"

bin/docker/k8s/countly-ingress-gce.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: countly-tls
5+
data:
6+
tls.crt: YOUR_SSL_CERT_IN_BASE64 # cat cert.crt | base64
7+
tls.key: YOUR_SSL_KEY_IN_BASE64 # cat cert.key | base64
8+
type: kubernetes.io/tls
9+
---
110
apiVersion: extensions/v1beta1
211
kind: Ingress
312
metadata:
@@ -6,6 +15,10 @@ metadata:
615
nginx.ingress.kubernetes.io/rewrite-target: /
716
kubernetes.io/ingress.global-static-ip-name: "countly-static-ip"
817
spec:
18+
tls:
19+
- hosts:
20+
- YOUR_HOSTNAME # countly.example.com
21+
secretName: countly-tls
922
rules:
1023
- http:
1124
paths:

bin/docker/k8s/countly-ingress.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: countly-tls
5+
data:
6+
tls.crt: YOUR_SSL_CERT_IN_BASE64 # cat cert.crt | base64
7+
tls.key: YOUR_SSL_KEY_IN_BASE64 # cat cert.key | base64
8+
type: kubernetes.io/tls
9+
---
110
apiVersion: extensions/v1beta1
211
kind: Ingress
312
metadata:
413
name: countly-ingress
514
annotations:
615
nginx.ingress.kubernetes.io/rewrite-target: /
716
spec:
17+
tls:
18+
- hosts:
19+
- YOUR_HOSTNAME # countly.example.com
20+
secretName: countly-tls
821
rules:
922
- http:
1023
paths:

bin/docker/k8s/gce-cluster-init.sh

100644100755
+1-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22

3-
43
# ---------------------------------------------------------------------------------------------------
54
# -------------------------- IGNORE IF YOU HAVE ALREADY SET UP KUBECTL ------------------------------
65
# ---------------------------------------------------------------------------------------------------
@@ -41,17 +40,15 @@ kubectl config set-context --current --namespace=countly
4140

4241
# Install MongoDB
4342
kubectl apply -f mongo/storage-class.yaml
44-
helm install --name db -f mongo/values.yaml stable/mongodb-replicaset
43+
helm install --name mongo -f mongo/values.yaml stable/mongodb-replicaset
4544

4645
## Wait ~ 3 minutes until all 3 replica set pods spin up
4746
kubectl get po
4847

4948

5049
# Install Countly deployments & services
5150
kubectl apply -f countly-frontend.yaml
52-
kubectl apply -f countly-frontend-service.yaml
5351
kubectl apply -f countly-api.yaml
54-
kubectl apply -f countly-api-service.yaml
5552

5653
# Install Countly ingress
5754
gcloud compute addresses create countly-static-ip --global

docker-compose.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ services:
2020

2121
countly-api:
2222
image: 'countly/api:19.08.1'
23+
# Enterprise Edition: image: 'gcr.io/countly-01/api:19.08.1'
2324
environment:
2425
- COUNTLY_CONFIG_API_MONGODB_HOST=mongodb
2526
- COUNTLY_CONFIG_API_MONGODB_USERNAME=${MONGODB_USERNAME}
@@ -42,6 +43,7 @@ services:
4243

4344
countly-frontend:
4445
image: 'countly/frontend:19.08.1'
46+
# Enterprise Edition: image: 'gcr.io/countly-01/api:19.08.1'
4547
environment:
4648
- COUNTLY_CONFIG_API_MONGODB_HOST=mongodb
4749
- COUNTLY_CONFIG_API_MONGODB_USERNAME=${MONGODB_USERNAME}
@@ -69,7 +71,7 @@ services:
6971
nginx:
7072
image: 'bitnami/nginx'
7173
ports:
72-
- '8080:8080'
74+
- '80:8080'
7375
volumes:
7476
- './bin/docker/nginx.server.conf:/opt/bitnami/nginx/conf/server_blocks/countly.conf:ro'
7577
networks:

0 commit comments

Comments
 (0)