Commit b02ff5f765ae7d6d0cac99d525f3c7d741376c0c
Committed by
GitHub
Merge pull request #739 from volodymyr-babak/master-upstream
Added redis k8s
Showing
2 changed files
with
105 additions
and
0 deletions
docker/k8s/redis.yaml
0 → 100644
1 | +# | ||
2 | +# Copyright © 2016-2018 The Thingsboard Authors | ||
3 | +# | ||
4 | +# Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | +# you may not use this file except in compliance with the License. | ||
6 | +# You may obtain a copy of the License at | ||
7 | +# | ||
8 | +# http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | +# | ||
10 | +# Unless required by applicable law or agreed to in writing, software | ||
11 | +# distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | +# See the License for the specific language governing permissions and | ||
14 | +# limitations under the License. | ||
15 | +# | ||
16 | + | ||
17 | +--- | ||
18 | +apiVersion: v1 | ||
19 | +kind: Service | ||
20 | +metadata: | ||
21 | + labels: | ||
22 | + name: redis-service | ||
23 | + name: redis-service | ||
24 | +spec: | ||
25 | + ports: | ||
26 | + - name: redis-service | ||
27 | + protocol: TCP | ||
28 | + port: 6379 | ||
29 | + targetPort: 6379 | ||
30 | + selector: | ||
31 | + app: redis | ||
32 | +--- | ||
33 | +apiVersion: v1 | ||
34 | +kind: ConfigMap | ||
35 | +metadata: | ||
36 | + name: redis-conf | ||
37 | +data: | ||
38 | + redis.conf: | | ||
39 | + appendonly yes | ||
40 | + protected-mode no | ||
41 | + bind 0.0.0.0 | ||
42 | + port 6379 | ||
43 | + dir /var/lib/redis | ||
44 | +--- | ||
45 | +apiVersion: apps/v1beta1 | ||
46 | +kind: StatefulSet | ||
47 | +metadata: | ||
48 | + name: redis | ||
49 | +spec: | ||
50 | + serviceName: redis-service | ||
51 | + replicas: 1 | ||
52 | + template: | ||
53 | + metadata: | ||
54 | + labels: | ||
55 | + app: redis | ||
56 | + spec: | ||
57 | + terminationGracePeriodSeconds: 10 | ||
58 | + containers: | ||
59 | + - name: redis | ||
60 | + image: redis:4.0.9 | ||
61 | + command: | ||
62 | + - redis-server | ||
63 | + args: | ||
64 | + - /etc/redis/redis.conf | ||
65 | + resources: | ||
66 | + requests: | ||
67 | + cpu: 100m | ||
68 | + memory: 100Mi | ||
69 | + ports: | ||
70 | + - containerPort: 6379 | ||
71 | + name: redis | ||
72 | + volumeMounts: | ||
73 | + - name: redis-data | ||
74 | + mountPath: /var/lib/redis | ||
75 | + - name: redis-conf | ||
76 | + mountPath: /etc/redis | ||
77 | + volumes: | ||
78 | + - name: redis-conf | ||
79 | + configMap: | ||
80 | + name: redis-conf | ||
81 | + items: | ||
82 | + - key: redis.conf | ||
83 | + path: redis.conf | ||
84 | + volumeClaimTemplates: | ||
85 | + - metadata: | ||
86 | + name: redis-data | ||
87 | + annotations: | ||
88 | + volume.beta.kubernetes.io/storage-class: fast | ||
89 | + spec: | ||
90 | + accessModes: [ "ReadWriteOnce" ] | ||
91 | + resources: | ||
92 | + requests: | ||
93 | + storage: 1Gi |
@@ -54,6 +54,8 @@ data: | @@ -54,6 +54,8 @@ data: | ||
54 | cassandra.host: "cassandra-headless" | 54 | cassandra.host: "cassandra-headless" |
55 | cassandra.port: "9042" | 55 | cassandra.port: "9042" |
56 | database.type: "cassandra" | 56 | database.type: "cassandra" |
57 | + cache.type: "redis" | ||
58 | + redis.host: "redis-service" | ||
57 | --- | 59 | --- |
58 | apiVersion: apps/v1beta1 | 60 | apiVersion: apps/v1beta1 |
59 | kind: StatefulSet | 61 | kind: StatefulSet |
@@ -127,6 +129,16 @@ spec: | @@ -127,6 +129,16 @@ spec: | ||
127 | valueFrom: | 129 | valueFrom: |
128 | fieldRef: | 130 | fieldRef: |
129 | fieldPath: status.podIP | 131 | fieldPath: status.podIP |
132 | + - name: CACHE_TYPE | ||
133 | + valueFrom: | ||
134 | + configMapKeyRef: | ||
135 | + name: tb-config | ||
136 | + key: cache.type | ||
137 | + - name: REDIS_HOST | ||
138 | + valueFrom: | ||
139 | + configMapKeyRef: | ||
140 | + name: tb-config | ||
141 | + key: redis.host | ||
130 | command: | 142 | command: |
131 | - sh | 143 | - sh |
132 | - -c | 144 | - -c |