Skip to content

Instantly share code, notes, and snippets.

@wallyqs
Last active September 10, 2020 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wallyqs/28e5d945378d1c89ed5e750683d12a6d to your computer and use it in GitHub Desktop.
Save wallyqs/28e5d945378d1c89ed5e750683d12a6d to your computer and use it in GitHub Desktop.
STAN + Block Device
---
apiVersion: v1
kind: ConfigMap
metadata:
name: stan-config
data:
stan.conf: |
port: 4222
http: 8222
streaming {
ns: "nats://my-nats:4222"
id: stan
store: file
dir: /mnt/azure/store
cluster {
node_id: $POD_NAME
log_path: /mnt/azure/log
# Explicit names of resulting peers
peers: ["stan-0", "stan-1", "stan-2"]
}
}
---
apiVersion: v1
kind: Service
metadata:
name: stan
labels:
app: stan
spec:
selector:
app: stan
clusterIP: None
ports:
- name: metrics
port: 7777
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: stan
labels:
app: stan
spec:
selector:
matchLabels:
app: stan
serviceName: stan
replicas: 3
volumeClaimTemplates:
- metadata:
name: stan-sts-vol
spec:
accessModes:
- ReadWriteOnce
volumeMode: "Block"
storageClassName: managed-premium
resources:
requests:
storage: 1Gi
template:
metadata:
labels:
app: stan
spec:
# Prevent NATS Streaming pods running in same host.
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- topologyKey: "kubernetes.io/hostname"
labelSelector:
matchExpressions:
- key: app
operator: In
values:
- stan
# STAN Server
containers:
- name: stan
image: nats-streaming:alpine
ports:
- containerPort: 8222
name: monitor
- containerPort: 7777
name: metrics
args:
- "-sc"
- "/etc/stan-config/stan.conf"
# Required to be able to define an environment variable
# that refers to other environment variables. This env var
# is later used as part of the configuration file.
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- name: config-volume
mountPath: /etc/stan-config
# - name: stan-sts-vol
# mountPath: /data/stan
volumeDevices:
- name: stan-sts-vol
devicePath: /mnt/azure
# Disable CPU limits.
resources:
requests:
cpu: 0
livenessProbe:
httpGet:
path: /
port: 8222
initialDelaySeconds: 10
timeoutSeconds: 5
volumes:
- name: config-volume
configMap:
name: stan-config
@wallyqs
Copy link
Author

wallyqs commented Sep 10, 2020

 kubectl logs stan-0 -c stan
[1] 2020/09/10 17:14:26.499873 [INF] STREAM: Starting nats-streaming-server[stan] version 0.18.0
[1] 2020/09/10 17:14:26.499932 [INF] STREAM: ServerID: vvKc5j3E1kSPljicMumRQY
[1] 2020/09/10 17:14:26.499937 [INF] STREAM: Go version: go1.14.4
[1] 2020/09/10 17:14:26.499941 [INF] STREAM: Git commit: [026e3a6]
[1] 2020/09/10 17:14:26.500011 [INF] STREAM: Shutting down.
[1] 2020/09/10 17:14:26.500021 [FTL] STREAM: Failed to start: unable to create the root directory [/dev/xvda]: mkdir /dev/xvda: not a directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment