Comments (1)
Hi @damir-manapov,
You can do this using the simple-stan
example as a template. You can then update the yaml spec to include the storage class you require.
See: https://github.com/nats-io/k8s/blob/master/nats-streaming-server/simple-stan.yml#L51-L60
Clustering
For example:
volumeClaimTemplates:
- metadata:
name: stan-sts-vol
spec:
accessModes:
- ReadWriteOnce
volumeMode: "Filesystem"
resources:
requests:
storage: 1Gi
Would become:
volumeClaimTemplates:
- metadata:
name: stan-sts-vol
spec:
accessModes:
- ReadWriteOnce
volumeMode: "Filesystem"
storageClassName: YOUR_STORAGE_CLASS_NAME
resources:
requests:
storage: 1Gi
Fault Tolerance Mode
If you are running in fault tolerance mode, (by tweaking the config) you would need to remove the volumeClaimTemplate
and create a PVC that supports ReadWriteMany
by itself:
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: stan-sts-vol
spec:
storageClassName: YOUR_STORAGE_CLASS_NAME
accessModes:
- ReadWriteMany
volumeMode: "Filesystem"
resources:
requests:
storage: 1Gi
And then bind that in via volumes at https://github.com/nats-io/k8s/blob/master/nats-streaming-server/simple-stan.yml#L77-L122:
...
# STAN Server
containers:
- name: stan
image: nats-streaming:0.16.2
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
# Disable CPU limits.
resources:
requests:
cpu: 0
livenessProbe:
httpGet:
path: /
port: 8222
initialDelaySeconds: 10
timeoutSeconds: 5
volumes:
- name: config-volume
configMap:
name: stan-config
- name: stan-data-vol
persistentVolumeClaim:
claimName: stan-sts-vol
Fault Tolerance Spec all together:
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: stan-sts-vol
spec:
storageClassName: YOUR_STORAGE_CLASS_NAME
accessModes:
- ReadWriteMany
volumeMode: "Filesystem"
resources:
requests:
storage: 1Gi
---
apiVersion: v1
kind: ConfigMap
metadata:
name: stan-config
data:
stan.conf: |
port: 4222
http: 8222
streaming {
ns: "nats://nats:4222"
id: stan
store: file
dir: /data/stan/store
# Configure cluster to run in Fault Tolerance mode (no clustering).
ft_group: stan-ft
}
---
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
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:0.16.2
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
# Disable CPU limits.
resources:
requests:
cpu: 0
livenessProbe:
httpGet:
path: /
port: 8222
initialDelaySeconds: 10
timeoutSeconds: 5
volumes:
- name: config-volume
configMap:
name: stan-config
- name: stan-sts-vol
persistentVolumeClaim:
claimName: stan-sts-vol
Hope that helps!
from k8s.
Related Issues (20)
- nats chart does not propagate automountServiceAccountToken setting to ServiceAccount YAML HOT 3
- [nats helm 1.x] Remove TLS Secret CA options
- [nats helm 1.x] nats-server pid location changes based on configuration HOT 3
- NATS Helm Chart 1.x support for k8s Service Application Protocol
- [nats helm] Support config for `gateway.gateways` and `leafnodes.remotes`
- Add an option for priority Class HOT 1
- Is it possible to block anonymous access to nats cluster? HOT 5
- Deprecated apiVersions in dependencies HOT 1
- NATS helm setup example - error: nats: secure connection not available HOT 3
- How to configure auth via Secrets
- Allow annotation to be added to service via nats helm chart values.yaml HOT 1
- Prom-Exporter container failing : [ERR] Could not find server_id: invalid character 'C' looking for beginning of value HOT 5
- Nats installation on a fresh K8s cluster errors : no matches for kind "PodMonitor" HOT 1
- LB indefinitely stuck in Pending state , when using loadBalancerIP HOT 2
- helm charts v1.0.0 nukes image pull secrets HOT 6
- [nats helm] Global Image Pull Secrets
- Jetstream issue with fileStore disabled. HOT 4
- Re-add nodeSelector to helm chart HOT 1
- NATS Chart Probes not Using HTTPS when Monitor TLS is Enabled HOT 1
- No way to pass nodeSelector or Pod affinity to nats helm chart HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from k8s.