initial commit
This commit is contained in:
1
dev/crate/alter_table
Executable file
1
dev/crate/alter_table
Executable file
@@ -0,0 +1 @@
|
||||
ALTER TABLE iss SET ("blocks.read_only_allow_delete" = FALSE)
|
||||
10
dev/crate/catalog-info.yaml
Normal file
10
dev/crate/catalog-info.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: backstage.io/v1alpha1
|
||||
kind: Component
|
||||
metadata:
|
||||
name: dev-crate
|
||||
title: Crate (dev)
|
||||
spec:
|
||||
type: service
|
||||
lifecycle: production
|
||||
owner: allarddcs
|
||||
subcomponentOf: component:default/DEV-cluster
|
||||
97
dev/crate/controler.yaml
Executable file
97
dev/crate/controler.yaml
Executable file
@@ -0,0 +1,97 @@
|
||||
kind: StatefulSet
|
||||
apiVersion: "apps/v1"
|
||||
metadata:
|
||||
# This is the name used as a prefix for all pods in the set.
|
||||
name: crate
|
||||
spec:
|
||||
serviceName: "crate-set"
|
||||
# Our cluster has three nodes.
|
||||
replicas: 3
|
||||
selector:
|
||||
matchLabels:
|
||||
# The pods in this cluster have the `app:crate` app label.
|
||||
app: crate
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: crate
|
||||
spec:
|
||||
# InitContainers run before the main containers of a pod are
|
||||
# started, and they must terminate before the primary containers
|
||||
# are initialized. Here, we use one to set the correct memory
|
||||
# map limit.
|
||||
initContainers:
|
||||
- name: init-sysctl
|
||||
image: busybox
|
||||
imagePullPolicy: IfNotPresent
|
||||
command: ["sysctl", "-w", "vm.max_map_count=262144"]
|
||||
securityContext:
|
||||
privileged: true
|
||||
# This final section is the core of the StatefulSet configuration.
|
||||
# It defines the container to run in each pod.
|
||||
containers:
|
||||
- name: crate
|
||||
# Use the CrateDB 5.1.1 Docker image.
|
||||
image: crate:5.1.1
|
||||
# Pass in configuration to CrateDB via command-line options.
|
||||
# We are setting the name of the node's explicitly, which is
|
||||
# needed to determine the initial master nodes. These are set to
|
||||
# the name of the pod.
|
||||
# We are using the SRV records provided by Kubernetes to discover
|
||||
# nodes within the cluster.
|
||||
args:
|
||||
- -Cnode.name=${POD_NAME}
|
||||
- -Ccluster.name=${CLUSTER_NAME}
|
||||
- -Ccluster.initial_master_nodes=crate-0,crate-1,crate-2
|
||||
- -Cdiscovery.seed_providers=srv
|
||||
- -Cdiscovery.srv.query=_crate-internal._tcp.crate-internal-service.${NAMESPACE}.svc.cluster.local
|
||||
- -Cgateway.recover_after_data_nodes=2
|
||||
- -Cgateway.expected_data_nodes=${EXPECTED_NODES}
|
||||
- -Cpath.data=/data
|
||||
volumeMounts:
|
||||
# Mount the `/data` directory as a volume named `data`.
|
||||
- mountPath: /data
|
||||
name: data
|
||||
resources:
|
||||
limits:
|
||||
# How much memory each pod gets.
|
||||
memory: 512Mi
|
||||
ports:
|
||||
# Port 4300 for inter-node communication.
|
||||
- containerPort: 4300
|
||||
name: crate-internal
|
||||
# Port 4200 for HTTP clients.
|
||||
- containerPort: 4200
|
||||
name: crate-web
|
||||
# Port 5432 for PostgreSQL wire protocol clients.
|
||||
- containerPort: 5432
|
||||
name: postgres
|
||||
# Environment variables passed through to the container.
|
||||
env:
|
||||
# This is variable is detected by CrateDB.
|
||||
- name: CRATE_HEAP_SIZE
|
||||
value: "256m"
|
||||
# The rest of these variables are used in the command-line
|
||||
# options.
|
||||
- name: EXPECTED_NODES
|
||||
value: "3"
|
||||
- name: CLUSTER_NAME
|
||||
value: "my-crate"
|
||||
- name: POD_NAME
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.name
|
||||
- name: NAMESPACE
|
||||
valueFrom:
|
||||
fieldRef:
|
||||
fieldPath: metadata.namespace
|
||||
volumeClaimTemplates:
|
||||
# Use persistent storage.
|
||||
- metadata:
|
||||
name: data
|
||||
spec:
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
98
dev/crate/crate-storage.yaml
Executable file
98
dev/crate/crate-storage.yaml
Executable file
@@ -0,0 +1,98 @@
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: crate-pv-0
|
||||
spec:
|
||||
storageClassName: ""
|
||||
capacity:
|
||||
storage: 1Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
mountOptions:
|
||||
- hard
|
||||
- nfsvers=4.1
|
||||
nfs:
|
||||
server: 192.168.40.100
|
||||
path: /mnt/nfs_share/crate/crate-0
|
||||
readOnly: false
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: crate-pv-1
|
||||
spec:
|
||||
storageClassName: ""
|
||||
capacity:
|
||||
storage: 1Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
mountOptions:
|
||||
- hard
|
||||
- nfsvers=4.1
|
||||
nfs:
|
||||
server: 192.168.40.100
|
||||
path: /mnt/nfs_share/crate/crate-1
|
||||
readOnly: false
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolume
|
||||
metadata:
|
||||
name: crate-pv-2
|
||||
spec:
|
||||
storageClassName: ""
|
||||
capacity:
|
||||
storage: 1Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
persistentVolumeReclaimPolicy: Retain
|
||||
mountOptions:
|
||||
- hard
|
||||
- nfsvers=4.1
|
||||
nfs:
|
||||
server: 192.168.40.100
|
||||
path: /mnt/nfs_share/crate/crate-2
|
||||
readOnly: false
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: data-crate-0
|
||||
spec:
|
||||
storageClassName: ""
|
||||
volumeName: crate-pv-0
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
volumeMode: Filesystem
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: data-crate-1
|
||||
spec:
|
||||
storageClassName: ""
|
||||
volumeName: crate-pv-1
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
volumeMode: Filesystem
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: PersistentVolumeClaim
|
||||
metadata:
|
||||
name: data-crate-2
|
||||
spec:
|
||||
storageClassName: ""
|
||||
volumeName: crate-pv-2
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
volumeMode: Filesystem
|
||||
resources:
|
||||
requests:
|
||||
storage: 1Gi
|
||||
4
dev/crate/create-table
Executable file
4
dev/crate/create-table
Executable file
@@ -0,0 +1,4 @@
|
||||
CREATE TABLE iss (
|
||||
timestamp TIMESTAMP GENERATED ALWAYS AS CURRENT_TIMESTAMP,
|
||||
position GEO_POINT
|
||||
);
|
||||
19
dev/crate/external-service.yaml
Executable file
19
dev/crate/external-service.yaml
Executable file
@@ -0,0 +1,19 @@
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: crate-external-service
|
||||
labels:
|
||||
app: crate
|
||||
spec:
|
||||
# Create an externally reachable load balancer.
|
||||
type: LoadBalancer
|
||||
ports:
|
||||
# Port 4200 for HTTP clients.
|
||||
- port: 4200
|
||||
name: crate-web
|
||||
# Port 5432 for PostgreSQL wire protocol clients.
|
||||
- port: 5432
|
||||
name: postgres
|
||||
selector:
|
||||
# Apply this to all nodes with the `app:crate` label.
|
||||
app: crate
|
||||
15
dev/crate/ingressroute-tls.yaml
Executable file
15
dev/crate/ingressroute-tls.yaml
Executable file
@@ -0,0 +1,15 @@
|
||||
apiVersion: traefik.containo.us/v1alpha1
|
||||
kind: IngressRoute
|
||||
metadata:
|
||||
name: cratedb-tls
|
||||
spec:
|
||||
entryPoints:
|
||||
- websecure
|
||||
routes:
|
||||
- match: Host(`cratedb.alldcs.nl`)
|
||||
kind: Rule
|
||||
services:
|
||||
- name: crate-ui
|
||||
port: 4200
|
||||
tls:
|
||||
certResolver: letsencrypt
|
||||
36
dev/crate/internal-service.yaml
Executable file
36
dev/crate/internal-service.yaml
Executable file
@@ -0,0 +1,36 @@
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: crate-internal-service
|
||||
labels:
|
||||
app: crate
|
||||
spec:
|
||||
# A static IP address is assigned to this service. This IP address is
|
||||
# only reachable from within the Kubernetes cluster.
|
||||
type: ClusterIP
|
||||
ports:
|
||||
# Port 4300 for inter-node communication.
|
||||
- port: 4300
|
||||
name: crate-internal
|
||||
selector:
|
||||
# Apply this to all nodes with the `app:crate` label.
|
||||
app: crate
|
||||
---
|
||||
kind: Service
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: crate-ui
|
||||
labels:
|
||||
app: crate
|
||||
spec:
|
||||
# A static IP address is assigned to this service. This IP address is
|
||||
# only reachable from within the Kubernetes cluster.
|
||||
type: ClusterIP
|
||||
ports:
|
||||
# Port 4300 for inter-node communication.
|
||||
- port: 4200
|
||||
name: crate-web
|
||||
selector:
|
||||
# Apply this to all nodes with the `app:crate` label.
|
||||
app: crate
|
||||
|
||||
20
dev/crate/iss.sh
Executable file
20
dev/crate/iss.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
# Exit immediately if a pipeline returns a non-zero status
|
||||
set -e
|
||||
|
||||
position () {
|
||||
curl -s http://api.open-notify.org/iss-now.json |
|
||||
jq -r '[.iss_position.longitude, .iss_position.latitude] | @tsv';
|
||||
}
|
||||
|
||||
wkt_position () {
|
||||
echo "POINT ($(position | expand -t 1))";
|
||||
}
|
||||
|
||||
while true; do
|
||||
crash --hosts 192.168.40.81:4200 \
|
||||
--command "INSERT INTO iss (position) VALUES ('$(wkt_position)')"
|
||||
echo 'Sleeping for 1 seconds...'
|
||||
sleep 10
|
||||
done
|
||||
|
||||
|
||||
1
dev/crate/select
Executable file
1
dev/crate/select
Executable file
@@ -0,0 +1 @@
|
||||
SELECT "timestamp", "position" FROM "doc"."iss" LIMIT 1000;
|
||||
Reference in New Issue
Block a user