TB-58: k8s feature improvements
This commit is contained in:
		
							parent
							
								
									73458484c2
								
							
						
					
					
						commit
						08e9e903f3
					
				
							
								
								
									
										5
									
								
								docker/cassandra/Dockerfile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								docker/cassandra/Dockerfile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,5 @@
 | 
				
			|||||||
 | 
					FROM cassandra:3.9
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					COPY ready-probe.sh /
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					CMD ["cassandra", "-f"]
 | 
				
			||||||
							
								
								
									
										13
									
								
								docker/cassandra/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								docker/cassandra/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					VERSION=k8stest
 | 
				
			||||||
 | 
					PROJECT=thingsboard
 | 
				
			||||||
 | 
					APP=cassandra
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					all: build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					build:
 | 
				
			||||||
 | 
						docker build --pull -t ${PROJECT}/${APP}:${VERSION} .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					push: build
 | 
				
			||||||
 | 
						docker push ${PROJECT}/${APP}:${VERSION}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: all build push
 | 
				
			||||||
@ -1,30 +1,23 @@
 | 
				
			|||||||
apiVersion: v1
 | 
					apiVersion: v1
 | 
				
			||||||
kind: Service
 | 
					kind: Service
 | 
				
			||||||
metadata:
 | 
					metadata:
 | 
				
			||||||
 | 
					  name: cassandra-headless
 | 
				
			||||||
  labels:
 | 
					  labels:
 | 
				
			||||||
    app: cassandra
 | 
					    app: cassandra-headless
 | 
				
			||||||
  name: cassandra
 | 
					 | 
				
			||||||
spec:
 | 
					spec:
 | 
				
			||||||
  clusterIP: None
 | 
					 | 
				
			||||||
  ports:
 | 
					  ports:
 | 
				
			||||||
    - port: 9042
 | 
					    - port: 9042
 | 
				
			||||||
 | 
					      name: cql
 | 
				
			||||||
 | 
					  clusterIP: None
 | 
				
			||||||
  selector:
 | 
					  selector:
 | 
				
			||||||
    app: cassandra
 | 
					    app: cassandra
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
apiVersion: storage.k8s.io/v1beta1
 | 
					 | 
				
			||||||
kind: StorageClass
 | 
					 | 
				
			||||||
metadata:
 | 
					 | 
				
			||||||
  name: regular
 | 
					 | 
				
			||||||
provisioner: kubernetes.io/gce-pd
 | 
					 | 
				
			||||||
parameters:
 | 
					 | 
				
			||||||
  type: pd-standard
 | 
					 | 
				
			||||||
---
 | 
					 | 
				
			||||||
apiVersion: "apps/v1beta1"
 | 
					apiVersion: "apps/v1beta1"
 | 
				
			||||||
kind: StatefulSet
 | 
					kind: StatefulSet
 | 
				
			||||||
metadata:
 | 
					metadata:
 | 
				
			||||||
  name: cassandra
 | 
					  name: cassandra
 | 
				
			||||||
spec:
 | 
					spec:
 | 
				
			||||||
  serviceName: cassandra
 | 
					  serviceName: cassandra-headless
 | 
				
			||||||
  replicas: 3
 | 
					  replicas: 3
 | 
				
			||||||
  template:
 | 
					  template:
 | 
				
			||||||
    metadata:
 | 
					    metadata:
 | 
				
			||||||
@ -39,11 +32,11 @@ spec:
 | 
				
			|||||||
                  - key: "app"
 | 
					                  - key: "app"
 | 
				
			||||||
                    operator: In
 | 
					                    operator: In
 | 
				
			||||||
                    values:
 | 
					                    values:
 | 
				
			||||||
                    - cassandra
 | 
					                    - cassandra-headless
 | 
				
			||||||
              topologyKey: "kubernetes.io/hostname"
 | 
					              topologyKey: "kubernetes.io/hostname"
 | 
				
			||||||
      containers:
 | 
					      containers:
 | 
				
			||||||
      - name: cassandra
 | 
					      - name: cassandra
 | 
				
			||||||
        image: gcr.io/google-samples/cassandra:v12
 | 
					        image: thingsboard/cassandra:k8stest
 | 
				
			||||||
        imagePullPolicy: Always
 | 
					        imagePullPolicy: Always
 | 
				
			||||||
        ports:
 | 
					        ports:
 | 
				
			||||||
        - containerPort: 7000
 | 
					        - containerPort: 7000
 | 
				
			||||||
@ -77,7 +70,7 @@ spec:
 | 
				
			|||||||
          - name: HEAP_NEWSIZE
 | 
					          - name: HEAP_NEWSIZE
 | 
				
			||||||
            value: 100M
 | 
					            value: 100M
 | 
				
			||||||
          - name: CASSANDRA_SEEDS
 | 
					          - name: CASSANDRA_SEEDS
 | 
				
			||||||
            value: "cassandra-0.cassandra.default.svc.cluster.local"
 | 
					            value: "cassandra-0.cassandra-headless.default.svc.cluster.local"
 | 
				
			||||||
          - name: CASSANDRA_CLUSTER_NAME
 | 
					          - name: CASSANDRA_CLUSTER_NAME
 | 
				
			||||||
            value: "K8Demo"
 | 
					            value: "K8Demo"
 | 
				
			||||||
          - name: CASSANDRA_DC
 | 
					          - name: CASSANDRA_DC
 | 
				
			||||||
@ -102,22 +95,16 @@ spec:
 | 
				
			|||||||
            - /ready-probe.sh
 | 
					            - /ready-probe.sh
 | 
				
			||||||
          initialDelaySeconds: 15
 | 
					          initialDelaySeconds: 15
 | 
				
			||||||
          timeoutSeconds: 5
 | 
					          timeoutSeconds: 5
 | 
				
			||||||
        # These volume mounts are persistent. They are like inline claims,
 | 
					 | 
				
			||||||
        # but not exactly because the names need to match exactly one of
 | 
					 | 
				
			||||||
        # the stateful pod volumes.
 | 
					 | 
				
			||||||
        volumeMounts:
 | 
					        volumeMounts:
 | 
				
			||||||
        - name: cassandra-data
 | 
					        - name: cassandra-data
 | 
				
			||||||
          mountPath: /cassandra_data
 | 
					          mountPath: /var/lib/cassandra/data
 | 
				
			||||||
        - name: cassandra-commitlog
 | 
					        - name: cassandra-commitlog
 | 
				
			||||||
          mountPath: /cassandra_commitlog
 | 
					          mountPath: /var/lib/cassandra/commitlog
 | 
				
			||||||
  # These are converted to volume claims by the controller
 | 
					 | 
				
			||||||
  # and mounted at the paths mentioned above.
 | 
					 | 
				
			||||||
  # do not use these in production until ssd GCEPersistentDisk or other ssd pd
 | 
					 | 
				
			||||||
  volumeClaimTemplates:
 | 
					  volumeClaimTemplates:
 | 
				
			||||||
  - metadata:
 | 
					  - metadata:
 | 
				
			||||||
      name: cassandra-data
 | 
					      name: cassandra-data
 | 
				
			||||||
      annotations:
 | 
					      annotations:
 | 
				
			||||||
        volume.beta.kubernetes.io/storage-class: regular
 | 
					        volume.beta.kubernetes.io/storage-class: slow
 | 
				
			||||||
    spec:
 | 
					    spec:
 | 
				
			||||||
      accessModes: [ "ReadWriteOnce" ]
 | 
					      accessModes: [ "ReadWriteOnce" ]
 | 
				
			||||||
      resources:
 | 
					      resources:
 | 
				
			||||||
@ -126,7 +113,7 @@ spec:
 | 
				
			|||||||
  - metadata:
 | 
					  - metadata:
 | 
				
			||||||
      name: cassandra-commitlog
 | 
					      name: cassandra-commitlog
 | 
				
			||||||
      annotations:
 | 
					      annotations:
 | 
				
			||||||
        volume.beta.kubernetes.io/storage-class: regular
 | 
					        volume.beta.kubernetes.io/storage-class: slow
 | 
				
			||||||
    spec:
 | 
					    spec:
 | 
				
			||||||
      accessModes: [ "ReadWriteOnce" ]
 | 
					      accessModes: [ "ReadWriteOnce" ]
 | 
				
			||||||
      resources:
 | 
					      resources:
 | 
				
			||||||
 | 
				
			|||||||
@ -1,6 +1,6 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					#!/bin/bash
 | 
				
			||||||
#
 | 
					
 | 
				
			||||||
# Copyright © 2016-2017 The Thingsboard Authors
 | 
					# Copyright 2016 The Kubernetes Authors.
 | 
				
			||||||
#
 | 
					#
 | 
				
			||||||
# Licensed under the Apache License, Version 2.0 (the "License");
 | 
					# Licensed under the Apache License, Version 2.0 (the "License");
 | 
				
			||||||
# you may not use this file except in compliance with the License.
 | 
					# you may not use this file except in compliance with the License.
 | 
				
			||||||
@ -13,16 +13,15 @@
 | 
				
			|||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
					# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
				
			||||||
# See the License for the specific language governing permissions and
 | 
					# See the License for the specific language governing permissions and
 | 
				
			||||||
# limitations under the License.
 | 
					# limitations under the License.
 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [[ $(nodetool status | grep $POD_IP) == *"UN"* ]]; then
 | 
				
			||||||
cp ../../application/target/thingsboard.deb thingsboard.deb
 | 
					  if [[ $DEBUG ]]; then
 | 
				
			||||||
 | 
					    echo "UN";
 | 
				
			||||||
docker build -t thingsboard/application:k8test .
 | 
					  fi
 | 
				
			||||||
 | 
					  exit 0;
 | 
				
			||||||
docker login
 | 
					else
 | 
				
			||||||
 | 
					  if [[ $DEBUG ]]; then
 | 
				
			||||||
docker push thingsboard/application:k8test
 | 
					    echo "Not Up";
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
# cleanup
 | 
					  exit 1;
 | 
				
			||||||
rm thingsboard.deb
 | 
					fi
 | 
				
			||||||
							
								
								
									
										9
									
								
								docker/common/common.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								docker/common/common.yaml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
				
			|||||||
 | 
					---
 | 
				
			||||||
 | 
					apiVersion: storage.k8s.io/v1beta1
 | 
				
			||||||
 | 
					kind: StorageClass
 | 
				
			||||||
 | 
					metadata:
 | 
				
			||||||
 | 
					  name: slow
 | 
				
			||||||
 | 
					provisioner: kubernetes.io/gce-pd
 | 
				
			||||||
 | 
					parameters:
 | 
				
			||||||
 | 
					  type: pd-standard
 | 
				
			||||||
 | 
					---
 | 
				
			||||||
@ -1,31 +0,0 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Copyright © 2016-2017 The Thingsboard Authors
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Licensed under the Apache License, Version 2.0 (the "License");
 | 
					 | 
				
			||||||
# you may not use this file except in compliance with the License.
 | 
					 | 
				
			||||||
# You may obtain a copy of the License at
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#     http://www.apache.org/licenses/LICENSE-2.0
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Unless required by applicable law or agreed to in writing, software
 | 
					 | 
				
			||||||
# distributed under the License is distributed on an "AS IS" BASIS,
 | 
					 | 
				
			||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
					 | 
				
			||||||
# See the License for the specific language governing permissions and
 | 
					 | 
				
			||||||
# limitations under the License.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
command='docker-compose -f docker-compose.yml -f docker-compose.random.yml'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo "stopping images.."
 | 
					 | 
				
			||||||
$command stop
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo "removing stopped images.."
 | 
					 | 
				
			||||||
$command rm -f
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo "building images.."
 | 
					 | 
				
			||||||
$command build
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo "starting images..."
 | 
					 | 
				
			||||||
$command up -d
 | 
					 | 
				
			||||||
@ -1,31 +0,0 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Copyright © 2016-2017 The Thingsboard Authors
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Licensed under the Apache License, Version 2.0 (the "License");
 | 
					 | 
				
			||||||
# you may not use this file except in compliance with the License.
 | 
					 | 
				
			||||||
# You may obtain a copy of the License at
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#     http://www.apache.org/licenses/LICENSE-2.0
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Unless required by applicable law or agreed to in writing, software
 | 
					 | 
				
			||||||
# distributed under the License is distributed on an "AS IS" BASIS,
 | 
					 | 
				
			||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
					 | 
				
			||||||
# See the License for the specific language governing permissions and
 | 
					 | 
				
			||||||
# limitations under the License.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
command='docker-compose -f docker-compose.yml -f docker-compose.static.yml'
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo "stopping images.."
 | 
					 | 
				
			||||||
$command stop
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo "removing stopped images.."
 | 
					 | 
				
			||||||
$command rm -f
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo "building images.."
 | 
					 | 
				
			||||||
$command build
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
echo "starting cassandra, zookeeper, thingsboard-db-schema images..."
 | 
					 | 
				
			||||||
$command up -d db zk thingsboard-db-schema
 | 
					 | 
				
			||||||
							
								
								
									
										13
									
								
								docker/thingsboard-db-schema/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								docker/thingsboard-db-schema/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					VERSION=k8stest
 | 
				
			||||||
 | 
					PROJECT=thingsboard
 | 
				
			||||||
 | 
					APP=thingsboard-db-schema
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					all: build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					build:
 | 
				
			||||||
 | 
						docker build --pull -t ${PROJECT}/${APP}:${VERSION} .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					push: build
 | 
				
			||||||
 | 
						docker push ${PROJECT}/${APP}:${VERSION}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: all build push
 | 
				
			||||||
@ -1,32 +0,0 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Copyright © 2016-2017 The Thingsboard Authors
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Licensed under the Apache License, Version 2.0 (the "License");
 | 
					 | 
				
			||||||
# you may not use this file except in compliance with the License.
 | 
					 | 
				
			||||||
# You may obtain a copy of the License at
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
#     http://www.apache.org/licenses/LICENSE-2.0
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
# Unless required by applicable law or agreed to in writing, software
 | 
					 | 
				
			||||||
# distributed under the License is distributed on an "AS IS" BASIS,
 | 
					 | 
				
			||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
					 | 
				
			||||||
# See the License for the specific language governing permissions and
 | 
					 | 
				
			||||||
# limitations under the License.
 | 
					 | 
				
			||||||
#
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cp ../../dao/src/main/resources/schema.cql schema.cql
 | 
					 | 
				
			||||||
cp ../../dao/src/main/resources/demo-data.cql demo-data.cql
 | 
					 | 
				
			||||||
cp ../../dao/src/main/resources/system-data.cql system-data.cql
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
docker build -t thingsboard/thingsboard-db-schema:k8test .
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
docker login
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
docker push thingsboard/thingsboard-db-schema:k8test
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# cleanup
 | 
					 | 
				
			||||||
rm schema.cql
 | 
					 | 
				
			||||||
rm demo-data.cql
 | 
					 | 
				
			||||||
rm system-data.cql
 | 
					 | 
				
			||||||
@ -6,7 +6,7 @@ spec:
 | 
				
			|||||||
  containers:
 | 
					  containers:
 | 
				
			||||||
  - name: tb-db-schema
 | 
					  - name: tb-db-schema
 | 
				
			||||||
    imagePullPolicy: Always
 | 
					    imagePullPolicy: Always
 | 
				
			||||||
    image: thingsboard/thingsboard-db-schema:k8test
 | 
					    image: thingsboard/thingsboard-db-schema:k8stest
 | 
				
			||||||
    env:
 | 
					    env:
 | 
				
			||||||
    - name: SKIP_SCHEMA_CREATION
 | 
					    - name: SKIP_SCHEMA_CREATION
 | 
				
			||||||
      value: "false"
 | 
					      value: "false"
 | 
				
			||||||
@ -15,7 +15,7 @@ spec:
 | 
				
			|||||||
    - name : SKIP_DEMO_DATA
 | 
					    - name : SKIP_DEMO_DATA
 | 
				
			||||||
      value: "false"
 | 
					      value: "false"
 | 
				
			||||||
    - name : CASSANDRA_URL
 | 
					    - name : CASSANDRA_URL
 | 
				
			||||||
      value: "cassandra"
 | 
					      value: "cassandra-headless"
 | 
				
			||||||
    command:
 | 
					    command:
 | 
				
			||||||
    - sh
 | 
					    - sh
 | 
				
			||||||
    - -c
 | 
					    - -c
 | 
				
			||||||
							
								
								
									
										13
									
								
								docker/thingsboard/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								docker/thingsboard/Makefile
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					VERSION=k8stest
 | 
				
			||||||
 | 
					PROJECT=thingsboard
 | 
				
			||||||
 | 
					APP=application
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					all: build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					build:
 | 
				
			||||||
 | 
						docker build --pull -t ${PROJECT}/${APP}:${VERSION} .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					push: build
 | 
				
			||||||
 | 
						docker push ${PROJECT}/${APP}:${VERSION}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					.PHONY: all build push
 | 
				
			||||||
@ -8,13 +8,11 @@ metadata:
 | 
				
			|||||||
spec:
 | 
					spec:
 | 
				
			||||||
  ports:
 | 
					  ports:
 | 
				
			||||||
  - port: 8080
 | 
					  - port: 8080
 | 
				
			||||||
    name: ui-port
 | 
					    name: ui
 | 
				
			||||||
  - port: 1883
 | 
					  - port: 1883
 | 
				
			||||||
    name: mqtt-port
 | 
					    name: mqtt
 | 
				
			||||||
  - port: 5683
 | 
					  - port: 5683
 | 
				
			||||||
    name: coap-port
 | 
					    name: coap
 | 
				
			||||||
  - port: 9001
 | 
					 | 
				
			||||||
    name: rpc-port
 | 
					 | 
				
			||||||
  selector:
 | 
					  selector:
 | 
				
			||||||
    app: tb
 | 
					    app: tb
 | 
				
			||||||
  type: LoadBalancer
 | 
					  type: LoadBalancer
 | 
				
			||||||
@ -27,14 +25,8 @@ metadata:
 | 
				
			|||||||
    app: tb-headless
 | 
					    app: tb-headless
 | 
				
			||||||
spec:
 | 
					spec:
 | 
				
			||||||
  ports:
 | 
					  ports:
 | 
				
			||||||
  - port: 8080
 | 
					 | 
				
			||||||
    name: ui-port
 | 
					 | 
				
			||||||
  - port: 1883
 | 
					 | 
				
			||||||
    name: mqtt-port
 | 
					 | 
				
			||||||
  - port: 5683
 | 
					 | 
				
			||||||
    name: coap-port
 | 
					 | 
				
			||||||
  - port: 9001
 | 
					  - port: 9001
 | 
				
			||||||
    name: rpc-port
 | 
					    name: rpc
 | 
				
			||||||
  selector:
 | 
					  selector:
 | 
				
			||||||
    app: tb
 | 
					    app: tb
 | 
				
			||||||
  clusterIP: None
 | 
					  clusterIP: None
 | 
				
			||||||
@ -56,7 +48,7 @@ metadata:
 | 
				
			|||||||
data:
 | 
					data:
 | 
				
			||||||
  zookeeper.enabled: "true"
 | 
					  zookeeper.enabled: "true"
 | 
				
			||||||
  zookeeper.url: "zk-headless"
 | 
					  zookeeper.url: "zk-headless"
 | 
				
			||||||
  cassandra.url: "cassandra:9042"
 | 
					  cassandra.url: "cassandra-headless:9042"
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
apiVersion: apps/v1beta1
 | 
					apiVersion: apps/v1beta1
 | 
				
			||||||
kind: StatefulSet
 | 
					kind: StatefulSet
 | 
				
			||||||
@ -84,16 +76,23 @@ spec:
 | 
				
			|||||||
      containers:
 | 
					      containers:
 | 
				
			||||||
      - name: tb
 | 
					      - name: tb
 | 
				
			||||||
        imagePullPolicy: Always
 | 
					        imagePullPolicy: Always
 | 
				
			||||||
        image: thingsboard/application:k8test
 | 
					        image: thingsboard/application:k8stest
 | 
				
			||||||
        ports:
 | 
					        ports:
 | 
				
			||||||
        - containerPort: 8080
 | 
					        - containerPort: 8080
 | 
				
			||||||
          name: ui-port
 | 
					          name: ui
 | 
				
			||||||
        - containerPort: 1883
 | 
					        - containerPort: 1883
 | 
				
			||||||
          name: mqtt-port
 | 
					          name: mqtt
 | 
				
			||||||
        - containerPort: 5683
 | 
					        - containerPort: 5683
 | 
				
			||||||
          name: coap-port
 | 
					          name: coap
 | 
				
			||||||
        - containerPort: 9001
 | 
					        - containerPort: 9001
 | 
				
			||||||
          name: rpc-port
 | 
					          name: rpc
 | 
				
			||||||
 | 
					        resources:
 | 
				
			||||||
 | 
					          limits:
 | 
				
			||||||
 | 
					            cpu: "250m"
 | 
				
			||||||
 | 
					            memory: "500Mi"
 | 
				
			||||||
 | 
					          requests:
 | 
				
			||||||
 | 
					           cpu: "250m"
 | 
				
			||||||
 | 
					           memory: "500Mi"
 | 
				
			||||||
        env:
 | 
					        env:
 | 
				
			||||||
        - name: ZOOKEEPER_ENABLED
 | 
					        - name: ZOOKEEPER_ENABLED
 | 
				
			||||||
          valueFrom:
 | 
					          valueFrom:
 | 
				
			||||||
 | 
				
			|||||||
@ -1,12 +1,13 @@
 | 
				
			|||||||
VERSION=k8test
 | 
					VERSION=k8stest
 | 
				
			||||||
PROJECT=thingsboard
 | 
					PROJECT=thingsboard
 | 
				
			||||||
 | 
					APP=zk
 | 
				
			||||||
 | 
					
 | 
				
			||||||
all: build
 | 
					all: build
 | 
				
			||||||
 | 
					
 | 
				
			||||||
build:
 | 
					build:
 | 
				
			||||||
	docker build --pull -t ${PROJECT}/k8szk:${VERSION} .
 | 
						docker build --pull -t ${PROJECT}/${APP}:${VERSION} .
 | 
				
			||||||
 | 
					
 | 
				
			||||||
push: build
 | 
					push: build
 | 
				
			||||||
	docker push ${PROJECT}/k8szk:${VERSION}
 | 
						docker push ${PROJECT}/${APP}:${VERSION}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.PHONY: all build push
 | 
					.PHONY: all build push
 | 
				
			||||||
 | 
				
			|||||||
@ -86,7 +86,7 @@ function validate_env() {
 | 
				
			|||||||
function create_config() {
 | 
					function create_config() {
 | 
				
			||||||
	rm -f $ZK_CONFIG_FILE
 | 
						rm -f $ZK_CONFIG_FILE
 | 
				
			||||||
    echo "Creating ZooKeeper configuration"
 | 
					    echo "Creating ZooKeeper configuration"
 | 
				
			||||||
    echo "#This file was autogenerated by k8szk DO NOT EDIT" >> $ZK_CONFIG_FILE
 | 
					    echo "#This file was autogenerated by zk DO NOT EDIT" >> $ZK_CONFIG_FILE
 | 
				
			||||||
	echo "clientPort=$ZK_CLIENT_PORT" >> $ZK_CONFIG_FILE
 | 
						echo "clientPort=$ZK_CLIENT_PORT" >> $ZK_CONFIG_FILE
 | 
				
			||||||
    echo "dataDir=$ZK_DATA_DIR" >> $ZK_CONFIG_FILE
 | 
					    echo "dataDir=$ZK_DATA_DIR" >> $ZK_CONFIG_FILE
 | 
				
			||||||
    echo "dataLogDir=$ZK_DATA_LOG_DIR" >> $ZK_CONFIG_FILE
 | 
					    echo "dataLogDir=$ZK_DATA_LOG_DIR" >> $ZK_CONFIG_FILE
 | 
				
			||||||
 | 
				
			|||||||
@ -20,6 +20,7 @@ metadata:
 | 
				
			|||||||
  name: zk-config
 | 
					  name: zk-config
 | 
				
			||||||
data:
 | 
					data:
 | 
				
			||||||
  ensemble: "zk-0;zk-1;zk-2"
 | 
					  ensemble: "zk-0;zk-1;zk-2"
 | 
				
			||||||
 | 
					  replicas: "3"
 | 
				
			||||||
  jvm.heap: "500m"
 | 
					  jvm.heap: "500m"
 | 
				
			||||||
  tick: "2000"
 | 
					  tick: "2000"
 | 
				
			||||||
  init: "10"
 | 
					  init: "10"
 | 
				
			||||||
@ -27,6 +28,9 @@ data:
 | 
				
			|||||||
  client.cnxns: "60"
 | 
					  client.cnxns: "60"
 | 
				
			||||||
  snap.retain: "3"
 | 
					  snap.retain: "3"
 | 
				
			||||||
  purge.interval: "1"
 | 
					  purge.interval: "1"
 | 
				
			||||||
 | 
					  client.port: "2181"
 | 
				
			||||||
 | 
					  server.port: "2888"
 | 
				
			||||||
 | 
					  election.port: "3888"
 | 
				
			||||||
---
 | 
					---
 | 
				
			||||||
apiVersion: policy/v1beta1
 | 
					apiVersion: policy/v1beta1
 | 
				
			||||||
kind: PodDisruptionBudget
 | 
					kind: PodDisruptionBudget
 | 
				
			||||||
@ -63,9 +67,9 @@ spec:
 | 
				
			|||||||
                    - zk-headless
 | 
					                    - zk-headless
 | 
				
			||||||
              topologyKey: "kubernetes.io/hostname"
 | 
					              topologyKey: "kubernetes.io/hostname"
 | 
				
			||||||
      containers:
 | 
					      containers:
 | 
				
			||||||
      - name: k8szk
 | 
					      - name: zk
 | 
				
			||||||
        imagePullPolicy: Always
 | 
					        imagePullPolicy: Always
 | 
				
			||||||
        image: thingsboard/k8szk:k8test
 | 
					        image: thingsboard/zk:k8stest
 | 
				
			||||||
        resources:
 | 
					        resources:
 | 
				
			||||||
          requests:
 | 
					          requests:
 | 
				
			||||||
            memory: "500Mi"
 | 
					            memory: "500Mi"
 | 
				
			||||||
@ -84,48 +88,60 @@ spec:
 | 
				
			|||||||
              name: zk-config
 | 
					              name: zk-config
 | 
				
			||||||
              key: ensemble
 | 
					              key: ensemble
 | 
				
			||||||
        - name : ZK_REPLICAS
 | 
					        - name : ZK_REPLICAS
 | 
				
			||||||
          value: "3"
 | 
					          valueFrom:
 | 
				
			||||||
 | 
					            configMapKeyRef:
 | 
				
			||||||
 | 
					              name: zk-config
 | 
				
			||||||
 | 
					              key: replicas
 | 
				
			||||||
        - name : ZK_HEAP_SIZE
 | 
					        - name : ZK_HEAP_SIZE
 | 
				
			||||||
          valueFrom:
 | 
					          valueFrom:
 | 
				
			||||||
            configMapKeyRef:
 | 
					            configMapKeyRef:
 | 
				
			||||||
                name: zk-config
 | 
					              name: zk-config
 | 
				
			||||||
                key: jvm.heap
 | 
					              key: jvm.heap
 | 
				
			||||||
        - name : ZK_TICK_TIME
 | 
					        - name : ZK_TICK_TIME
 | 
				
			||||||
          valueFrom:
 | 
					          valueFrom:
 | 
				
			||||||
            configMapKeyRef:
 | 
					            configMapKeyRef:
 | 
				
			||||||
                name: zk-config
 | 
					              name: zk-config
 | 
				
			||||||
                key: tick
 | 
					              key: tick
 | 
				
			||||||
        - name : ZK_INIT_LIMIT
 | 
					        - name : ZK_INIT_LIMIT
 | 
				
			||||||
          valueFrom:
 | 
					          valueFrom:
 | 
				
			||||||
            configMapKeyRef:
 | 
					            configMapKeyRef:
 | 
				
			||||||
                name: zk-config
 | 
					              name: zk-config
 | 
				
			||||||
                key: init
 | 
					              key: init
 | 
				
			||||||
        - name : ZK_SYNC_LIMIT
 | 
					        - name : ZK_SYNC_LIMIT
 | 
				
			||||||
          valueFrom:
 | 
					          valueFrom:
 | 
				
			||||||
            configMapKeyRef:
 | 
					            configMapKeyRef:
 | 
				
			||||||
                name: zk-config
 | 
					              name: zk-config
 | 
				
			||||||
                key: tick
 | 
					              key: tick
 | 
				
			||||||
        - name : ZK_MAX_CLIENT_CNXNS
 | 
					        - name : ZK_MAX_CLIENT_CNXNS
 | 
				
			||||||
          valueFrom:
 | 
					          valueFrom:
 | 
				
			||||||
            configMapKeyRef:
 | 
					            configMapKeyRef:
 | 
				
			||||||
                name: zk-config
 | 
					              name: zk-config
 | 
				
			||||||
                key: client.cnxns
 | 
					              key: client.cnxns
 | 
				
			||||||
        - name: ZK_SNAP_RETAIN_COUNT
 | 
					        - name: ZK_SNAP_RETAIN_COUNT
 | 
				
			||||||
          valueFrom:
 | 
					          valueFrom:
 | 
				
			||||||
            configMapKeyRef:
 | 
					            configMapKeyRef:
 | 
				
			||||||
                name: zk-config
 | 
					              name: zk-config
 | 
				
			||||||
                key: snap.retain
 | 
					              key: snap.retain
 | 
				
			||||||
        - name: ZK_PURGE_INTERVAL
 | 
					        - name: ZK_PURGE_INTERVAL
 | 
				
			||||||
          valueFrom:
 | 
					          valueFrom:
 | 
				
			||||||
            configMapKeyRef:
 | 
					            configMapKeyRef:
 | 
				
			||||||
                name: zk-config
 | 
					              name: zk-config
 | 
				
			||||||
                key: purge.interval
 | 
					              key: purge.interval
 | 
				
			||||||
        - name: ZK_CLIENT_PORT
 | 
					        - name: ZK_CLIENT_PORT
 | 
				
			||||||
          value: "2181"
 | 
					          valueFrom:
 | 
				
			||||||
 | 
					            configMapKeyRef:
 | 
				
			||||||
 | 
					              name: zk-config
 | 
				
			||||||
 | 
					              key: client.port
 | 
				
			||||||
        - name: ZK_SERVER_PORT
 | 
					        - name: ZK_SERVER_PORT
 | 
				
			||||||
          value: "2888"
 | 
					          valueFrom:
 | 
				
			||||||
 | 
					            configMapKeyRef:
 | 
				
			||||||
 | 
					              name: zk-config
 | 
				
			||||||
 | 
					              key: server.port
 | 
				
			||||||
        - name: ZK_ELECTION_PORT
 | 
					        - name: ZK_ELECTION_PORT
 | 
				
			||||||
          value: "3888"
 | 
					          valueFrom:
 | 
				
			||||||
 | 
					            configMapKeyRef:
 | 
				
			||||||
 | 
					              name: zk-config
 | 
				
			||||||
 | 
					              key: election.port
 | 
				
			||||||
        command:
 | 
					        command:
 | 
				
			||||||
        - sh
 | 
					        - sh
 | 
				
			||||||
        - -c
 | 
					        - -c
 | 
				
			||||||
@ -143,16 +159,16 @@ spec:
 | 
				
			|||||||
          initialDelaySeconds: 15
 | 
					          initialDelaySeconds: 15
 | 
				
			||||||
          timeoutSeconds: 5
 | 
					          timeoutSeconds: 5
 | 
				
			||||||
        volumeMounts:
 | 
					        volumeMounts:
 | 
				
			||||||
        - name: datadir
 | 
					        - name: zkdatadir
 | 
				
			||||||
          mountPath: /var/lib/zookeeper
 | 
					          mountPath: /var/lib/zookeeper
 | 
				
			||||||
      securityContext:
 | 
					      securityContext:
 | 
				
			||||||
        runAsUser: 1000
 | 
					        runAsUser: 1000
 | 
				
			||||||
        fsGroup: 1000
 | 
					        fsGroup: 1000
 | 
				
			||||||
  volumeClaimTemplates:
 | 
					  volumeClaimTemplates:
 | 
				
			||||||
  - metadata:
 | 
					  - metadata:
 | 
				
			||||||
      name: datadir
 | 
					      name: zkdatadir
 | 
				
			||||||
      annotations:
 | 
					      annotations:
 | 
				
			||||||
        volume.alpha.kubernetes.io/storage-class: anything
 | 
					        volume.beta.kubernetes.io/storage-class: slow
 | 
				
			||||||
    spec:
 | 
					    spec:
 | 
				
			||||||
      accessModes: [ "ReadWriteOnce" ]
 | 
					      accessModes: [ "ReadWriteOnce" ]
 | 
				
			||||||
      resources:
 | 
					      resources:
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user