新增learn-kubernetes(https://github.com/yyong-brs/learn-kubernetes)相关文件
This commit is contained in:
@@ -0,0 +1,138 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: nats-config
|
||||
labels:
|
||||
kiamol: ch21
|
||||
data:
|
||||
nats.conf: |
|
||||
pid_file: "/var/run/nats/nats.pid"
|
||||
http: 8222
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: message-queue
|
||||
labels:
|
||||
app: nats
|
||||
kiamol: ch21
|
||||
spec:
|
||||
selector:
|
||||
app: nats
|
||||
clusterIP: None
|
||||
ports:
|
||||
- name: client
|
||||
port: 4222
|
||||
- name: cluster
|
||||
port: 6222
|
||||
- name: monitor
|
||||
port: 8222
|
||||
- name: metrics
|
||||
port: 7777
|
||||
- name: leafnodes
|
||||
port: 7422
|
||||
- name: gateways
|
||||
port: 7522
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: nats
|
||||
labels:
|
||||
app: nats
|
||||
kiamol: ch21
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: nats
|
||||
replicas: 1
|
||||
serviceName: "nats"
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: nats
|
||||
spec:
|
||||
# Common volumes for the containers
|
||||
volumes:
|
||||
- name: config-volume
|
||||
configMap:
|
||||
name: nats-config
|
||||
- name: pid
|
||||
emptyDir: {}
|
||||
|
||||
# Required to be able to HUP signal and apply config reload
|
||||
# to the server without restarting the pod.
|
||||
shareProcessNamespace: true
|
||||
|
||||
#################
|
||||
# #
|
||||
# NATS Server #
|
||||
# #
|
||||
#################
|
||||
terminationGracePeriodSeconds: 60
|
||||
containers:
|
||||
- name: nats
|
||||
image: nats:2.1.0-alpine3.10
|
||||
ports:
|
||||
- containerPort: 4222
|
||||
name: client
|
||||
hostPort: 4222
|
||||
- containerPort: 7422
|
||||
name: leafnodes
|
||||
hostPort: 7422
|
||||
- containerPort: 6222
|
||||
name: cluster
|
||||
- containerPort: 8222
|
||||
name: monitor
|
||||
- containerPort: 7777
|
||||
name: metrics
|
||||
command:
|
||||
- "nats-server"
|
||||
- "--config"
|
||||
- "/etc/nats-config/nats.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
|
||||
- name: CLUSTER_ADVERTISE
|
||||
value: $(POD_NAME).nats.$(POD_NAMESPACE).svc
|
||||
volumeMounts:
|
||||
- name: config-volume
|
||||
mountPath: /etc/nats-config
|
||||
- name: pid
|
||||
mountPath: /var/run/nats
|
||||
|
||||
# Liveness/Readiness probes against the monitoring
|
||||
#
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8222
|
||||
initialDelaySeconds: 10
|
||||
timeoutSeconds: 5
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: 8222
|
||||
initialDelaySeconds: 10
|
||||
timeoutSeconds: 5
|
||||
|
||||
# Gracefully stop NATS Server on pod deletion or image upgrade.
|
||||
#
|
||||
lifecycle:
|
||||
preStop:
|
||||
exec:
|
||||
# Using the alpine based NATS image, we add an extra sleep that is
|
||||
# the same amount as the terminationGracePeriodSeconds to allow
|
||||
# the NATS Server to gracefully terminate the client connections.
|
||||
#
|
||||
command: ["/bin/sh", "-c", "/nats-server -sl=ldm=/var/run/nats/nats.pid && /bin/sleep 60"]
|
||||
Reference in New Issue
Block a user