Search…
SDK and Frameworks
Kubernetes Setup
On this page you can find tutorial how to deploy DecisionRules into kubernetes

How to Deploy DecisionRules on Kubernetes

1. Create a namespace for DecisionRules

Template

namespace.yaml
1
apiVersion: v1
2
kind: Namespace
3
metadata:
4
name: decisionrules
5
labels:
6
name: decisionrules
Copied!

Activate

1
kubectl apply -f namespace.yaml
Copied!

2. Install Ingress to kubernetes

1
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.2.0/deploy/static/provider/cloud/deploy.yaml
Copied!

3. Install Cert-Manager

1
kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.8.0/cert-manager.yaml
Copied!

4. Configure Cert-Manager

Template

cert.yaml
1
apiVersion: cert-manager.io/v1
2
kind: ClusterIssuer
3
metadata:
4
name: letsencrypt-prod
5
namespace: decisionrules
6
spec:
7
acme:
8
server: https://acme-v02.api.letsencrypt.org/directory
10
privateKeySecretRef:
11
name: letsencrypt-prod
12
solvers:
13
- http01:
14
ingress:
15
class: nginx
Copied!

Activate

1
kubectl apply -f cert.yaml
Copied!

5. Create services and configure ingress

In this template, you must specify your custom hostname. Be sure to change the same hostname in the TLS hosts section.

Template

ingress.yaml
1
apiVersion: v1
2
kind: Service
3
metadata:
4
name: decisionrules-client-service
5
namespace: decisionrules
6
spec:
7
selector:
8
app: decisionrules-c.yamlient
9
ports:
10
- port: 80
11
---
12
apiVersion: v1
13
kind: Service
14
metadata:
15
name: decisionrules-server-service
16
namespace: decisionrules
17
spec:
18
selector:
19
app: decisionrules-server
20
ports:
21
- port: 8080
22
---
23
apiVersion: networking.k8s.io/v1
24
kind: Ingress
25
metadata:
26
name: decisionrules-ingress
27
namespace: decisionrules
28
annotations:
29
nginx.ingress.kubernetes.io/rewrite-target: "/"
30
cert-manager.io/cluster-issuer: "letsencrypt-prod"
31
kubernetes.io/ingress.class: "nginx"
32
spec:
33
ingressClassName: nginx
34
tls:
35
- hosts:
36
- yourdomain.local # must be changed
37
- api.yourdomain.local # must be changed
38
secretName: echo-tls
39
rules:
40
- host: yourdomain.local # must be changed
41
http:
42
paths:
43
- path: /
44
pathType: Prefix
45
backend:
46
service:
47
name: decisionrules-client-service
48
port:
49
number: 80
50
- host: api.yourdomain.local # must be changed
51
http:
52
paths:
53
- path: /
54
pathType: Prefix
55
backend:
56
service:
57
name: decisionrules-server-service
58
port:
59
number: 8080
Copied!

Activate

1
kubectl apply -f ingress.yaml
Copied!

6. Getting Ingress IP address for setting domain

Command

1
kubectl get ingress --namespace=decisionrules
Copied!

Example of Response

1
NAME CLASS HOSTS ADDRESS PORTS AGE
2
decisionrules-ingress nginx kubernetes.decisionrules.io,api.kubernetes.decisionrules.io 104.45.71.23 80, 443 3d23h
Copied!
In the response, you can find column ADDRESS where you can find the IP Address of Ingress. This IP Address you can use to specify your custom domain as A record of DNS.

7. Create deployment service

In this template, you must fill Environmental variables and change the URL to the Ingress hostname which you specify in the previous step. The place is markup with comments.

Template

deployment.yaml
1
apiVersion: apps/v1
2
kind: Deployment
3
metadata:
4
name: decisionrules-client
5
namespace: decisionrules
6
spec:
7
replicas: 2
8
selector:
9
matchLabels:
10
app: decisionrules-client
11
strategy:
12
type: RollingUpdate
13
rollingUpdate:
14
maxSurge: 2
15
maxUnavailable: 0
16
template:
17
metadata:
18
labels:
19
app: decisionrules-client
20
spec:
21
containers:
22
- name: decisionrules-client
23
image: decisionrules/client
24
resources:
25
requests:
26
cpu: 250m
27
memory: 128Mi
28
limits:
29
cpu: 500m
30
memory: 256Mi
31
ports:
32
- containerPort: 80
33
env:
34
- name: API_URL
35
value: "https://api.yourdomain.local" #must be changed
36
---
37
apiVersion: apps/v1
38
kind: Deployment
39
metadata:
40
name: decisionrules-server
41
namespace: decisionrules
42
spec:
43
replicas: 2
44
selector:
45
matchLabels:
46
app: decisionrules-server
47
strategy:
48
type: RollingUpdate
49
rollingUpdate:
50
maxSurge: 2
51
maxUnavailable: 0
52
template:
53
metadata:
54
labels:
55
app: decisionrules-server
56
spec:
57
containers:
58
- name: decisionrules-server
59
image: decisionrules/server
60
resources:
61
requests:
62
cpu: 1000m
63
memory: 300Mi
64
limits:
65
cpu: 2000m
66
memory: 600Mi
67
ports:
68
- containerPort: 8080
69
env:
70
- name: REDIS_URL
71
value: "" # must be filled
72
- name: MONGO_DB_URI
73
value: "" # must be filled
74
- name: CLIENT_URL
75
value: "https://yourdomain.local" # must be changed
76
- name: LICENSE_KEY
77
value: "" # must be filled.yaml
78
livenessProbe:
79
httpGet:
80
path: /health-check
81
port: 8080
82
initialDelaySeconds: 30
83
periodSeconds: 30
84
---
85
apiVersion: autoscaling/v1
86
kind: HorizontalPodAutoscaler
87
metadata:
88
name: decisionrules-server-autoscaling
89
namespace: decisionrules
90
spec:
91
scaleTargetRef:
92
apiVersion: apps/v1
93
kind: Deployment
94
name: decisionrules-server
95
minReplicas: 1
96
maxReplicas: 10
97
targetCPUUtilizationPercentage: 60
Copied!

Activate

1
kubectl apply -f deployment.yaml
Copied!