2022-01-19 创建k8s的statefulset
摘要:由于大量对于sts的稳定性测试和调研, 记录如何快速孵化sts.目的是作为demo调研使用.创建svc.yaml:apiVersion: v1kind: Servicemetadata:name: mypod-svclabels:name: mypodapp: mypodspec:ports:- port: 6379name: tcpclusterIP: Noneselector:app:
·
目录
摘要:
由于大量对于sts的稳定性测试和调研, 记录如何快速孵化sts.
目的是作为demo调研使用.
创建svc.yaml:
apiVersion: v1
kind: Service
metadata:
name: mypod-svc
labels:
name: mypod
app: mypod
spec:
ports:
- port: 6379
name: tcp
clusterIP: None
selector:
app: mypod
创建sts.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mypod
metadata:
name: mypod
spec:
serviceName: mypod-svc
replicas: 1
selector:
matchLabels:
app: mypod
template:
metadata:
labels:
app: mypod
exporter: "mypod-exporter"
spec:
containers:
- name: myfrontend
image: nginx
imagePullPolicy: IfNotPresent
args:
- /bin/sh
- -c
- tail -f /dev/null
volumeMounts:
- mountPath: "/data"
name: mypd
volumes:
- name: mypd
# emptyDir: {}
hostPath:
path: /tmp/mypod
type: DirectoryOrCreate
孵化命令:
kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f ./svc.yaml
kubectl --kubeconfig /etc/kubernetes/admin.conf apply -f ./sts.yaml
更多推荐
已为社区贡献9条内容
所有评论(0)