k8s实践18:statefulset学习配置记录

1.
基础概念

statefulset,可以翻译成有状态的设定.

和deployment的对比

deployment部署创建的pod是无状态的,重新调度pod,pod名字hostname,启动pod顺序删除pod顺序都是随机的.deployment使用的是共享存储,所有pod共用一个存储卷.

statefulset部署创建的pod是有状态的,重新调度pod,pod名字hostname保持固定不变,启动pod顺序删除pod顺序都可以根据定义的顺序有序执行操作,有序的动态更新,statefulset使用的存储,不是共用一个存储卷,一个pod对应一个存储卷(pv).pod重新创建调度挂载的存储卷保持不变.

2.
statefulset实现用到的技术概念

headless service
headless service不需要配置clusterIP,对应的每一个pod都会有相应的dns域名.因此可以为每个pod生成可解析的dns记录.

statefulset
statefulset 用来部署管理pod资源

volumeClaimTemplates
实现每个pod对应一个pv存储卷

3.
测试环境准备

kubernets集群必须部署dns,能正常解析.
kubernetes集群必须配置storageclass,能够实现动态创建pv.
我这里用的是nfs存储环境.

4.
headless service和service解析对比

service

[[email protected] ~]# kubectl get svc
NAME? ? ? ?? TYPE? ? ? ? CLUSTER-IP? ? ? EXTERNAL-IP?? PORT(S)? ? ?? AGE
httpd-svc? ? NodePort? ? 10.254.33.250?? <none>? ? ? ? 80:8768/TCP?? 92d
kubernetes?? ClusterIP?? 10.254.0.1? ? ? <none>? ? ? ? 443/TCP? ? ?? 92d

注意下面解析用到dns的ip

[[email protected] ~]# kubectl get svc -n kube-system
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? TYPE? ? ? ? CLUSTER-IP? ? ?? EXTERNAL-IP?? PORT(S)? ? ? ? ? ? ? ? ?? AGE
kube-dns? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ClusterIP?? 10.254.0.2? ? ?? <none>? ? ? ? 53/UDP,53/TCP? ? ? ? ? ?? 92d
[[email protected] ~]# kubectl describe svc httpd-svc
Name:? ? ? ? ? ? ? ? ? ?? httpd-svc
Namespace:? ? ? ? ? ? ? ? default
Labels:? ? ? ? ? ? ? ? ?? <none>
Annotations:? ? ? ? ? ? ? kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"httpd-svc","namespace":"default"},"spec":{"ports":[{"port":80}],"selector":{"a...
Selector:? ? ? ? ? ? ? ?? app=httpd-app
Type:? ? ? ? ? ? ? ? ? ?? NodePort
IP:? ? ? ? ? ? ? ? ? ? ?? 10.254.33.250
Port:? ? ? ? ? ? ? ? ? ?? <unset>? 80/TCP
TargetPort:? ? ? ? ? ? ?? 80/TCP
NodePort:? ? ? ? ? ? ? ?? <unset>? 8768/TCP
Endpoints:? ? ? ? ? ? ? ? 172.30.37.7:80
Session Affinity:? ? ? ?? None
External Traffic Policy:? Cluster
Events:? ? ? ? ? ? ? ? ?? <none>
[[email protected] ~]#

随便进个namespace是default的pod用nslookup解析

[[email protected] ~]# kubectl exec -it nfs-client-provisioner-65bf6bd464-qdzcj nslookup httpd-svc.default.svc.cluster.local 10.254.0.2
Server:? ? 10.254.0.2
Address 1: 10.254.0.2 kube-dns.kube-system.svc.cluster.local

Name:? ? ? httpd-svc.default.svc.cluster.local
Address 1: 10.254.33.250 httpd-svc.default.svc.cluster.local
[[email protected] ~]#

headless service

[[email protected] test]# cat headless-svc-test.yaml
apiVersion: v1
kind: Service
metadata:
? name: headless-svc
? labels:
? ? app: headless-svc
spec:
? ports:
? - port: 80
? ? name: myweb
? selector:
? ? app: headless-pod
? clusterIP: None

---
apiVersion: apps/v1
kind: Deployment
metadata:
? name: headless-test
spec:
? replicas: 3
? selector:
? ? matchLabels:
? ? ? app: headless-pod
? template:
? ? metadata:
? ? ? labels:
? ? ? ? app: headless-pod
? ? spec:
? ? ? containers:
? ? ? - image: httpd
? ? ? ? name: myhttpd
? ? ? ? ports:
? ? ? ? - containerPort: 80
[[email protected] test]#
[[email protected] test]# kubectl describe svc headless-svc
Name:? ? ? ? ? ? ? headless-svc
Namespace:? ? ? ?? default
Labels:? ? ? ? ? ? app=headless-svc
Annotations:? ? ?? kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"headless-svc"},"name":"headless-svc","namespace":"default"},"spec":{"...
Selector:? ? ? ? ? app=headless-pod
Type:? ? ? ? ? ? ? ClusterIP
IP:? ? ? ? ? ? ? ? None
Port:? ? ? ? ? ? ? myweb? 80/TCP
TargetPort:? ? ? ? 80/TCP
Endpoints:? ? ? ?? 172.30.65.4:80,172.30.65.5:80,172.30.81.6:80
Session Affinity:? None
Events:? ? ? ? ? ? <none>
[[email protected] test]#

随便进个namespace是default的pod用nslookup解析

[[email protected] test]# kubectl exec -it nfs-client-provisioner-65bf6bd464-qdzcj nslookup headless-svc.default.svc.cluster.local 10.254.0.2
Server:? ? 10.254.0.2
Address 1: 10.254.0.2 kube-dns.kube-system.svc.cluster.local

Name:? ? ? headless-svc.default.svc.cluster.local
Address 1: 172.30.65.5 172-30-65-5.headless-svc.default.svc.cluster.local
Address 2: 172.30.65.4 172-30-65-4.headless-svc.default.svc.cluster.local
Address 3: 172.30.81.6 172-30-81-6.headless-svc.default.svc.cluster.local
[[email protected] test]#

对比可知:
配置headless service 和service的区别只是加一个clusterIP: None

dns解析的不同
service 解析返回svc的ip和dns域名
headless service 解析返回pod的ip和dns域名

headless service解析能够返回pod的hostname.
statefulset需要固定pod name,hostname,必须要能解析pod的hostname.因此使用headless service.

5.
statefulset配置测试

[[email protected] test]# cat statefulset-test.yaml
apiVersion: v1
kind: Service
metadata:
? name: headless-svc
? labels:
? ? app: headless-svc
spec:
? ports:
? - port: 80
? ? name: myweb
? selector:
? ? app: headless-pod
? clusterIP: None

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
? name: statefulset-test
spec:
? serviceName: headless-svc
? replicas: 3
? selector:
? ? matchLabels:
? ? ? app: headless-pod
? template:
? ? metadata:
? ? ? labels:
? ? ? ? app: headless-pod
? ? spec:
? ? ? containers:
? ? ? - image: httpd
? ? ? ? name: myhttpd
? ? ? ? ports:
? ? ? ? - containerPort: 80
? ? ? ? ? name: httpd
[[email protected] test]#
[[email protected] test]# kubectl describe svc headless-svc
Name:? ? ? ? ? ? ? headless-svc
Namespace:? ? ? ?? default
Labels:? ? ? ? ? ? app=headless-svc
Annotations:? ? ?? kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"labels":{"app":"headless-svc"},"name":"headless-svc","namespace":"default"},"spec":{"...
Selector:? ? ? ? ? app=headless-pod
Type:? ? ? ? ? ? ? ClusterIP
IP:? ? ? ? ? ? ? ? None
Port:? ? ? ? ? ? ? myweb? 80/TCP
TargetPort:? ? ? ? 80/TCP
Endpoints:? ? ? ?? 172.30.65.4:80,172.30.65.5:80,172.30.81.6:80
Session Affinity:? None
Events:? ? ? ? ? ? <none>
[[email protected] test]# kubectl get pod -o wide
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ?? STATUS? ? RESTARTS?? AGE? ? ?? IP? ? ? ? ? ? NODE
statefulset-test-0? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running?? 0? ? ? ? ? 4m? ? ? ? 172.30.65.4?? k8s-master3
statefulset-test-1? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running?? 0? ? ? ? ? 4m? ? ? ? 172.30.81.6?? k8s-master2
statefulset-test-2? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running?? 0? ? ? ? ? 4m? ? ? ? 172.30.65.5?? k8s-master3
hostname
[[email protected] test]# kubectl exec -it statefulset-test-0 hostname
statefulset-test-0
[[email protected] test]# kubectl exec -it statefulset-test-1 hostname
statefulset-test-1
[[email protected] test]# kubectl exec -it statefulset-test-2 hostname
statefulset-test-2

解析

[[email protected] test]# kubectl exec -it nfs-client-provisioner-65bf6bd464-qdzcj nslookup headless-svc.default.svc.cluster.local 10.254.0.2
Server:? ? 10.254.0.2
Address 1: 10.254.0.2 kube-dns.kube-system.svc.cluster.local

Name:? ? ? headless-svc.default.svc.cluster.local
Address 1: 172.30.65.5 statefulset-test-2.headless-svc.default.svc.cluster.local
Address 2: 172.30.65.4 statefulset-test-0.headless-svc.default.svc.cluster.local
Address 3: 172.30.81.6 statefulset-test-1.headless-svc.default.svc.cluster.local
[[email protected] test]#

statefulset部署和上面的head services使用deployment部署对比
pod名字是按照顺序生成,从0开始每次+1命名pod
创建pod,也是按照顺序一个一个创建,没有像deployment部署那样批量一次性全部创建.

测试

删除pod

[[email protected] test]# kubectl delete pod statefulset-test-0
pod "statefulset-test-0" deleted
[[email protected] test]# kubectl get pod
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ?? STATUS? ? ? ? RESTARTS?? AGE
statefulset-test-0? ? ? ? ? ? ? ? ? ? ? ? 0/1? ? ?? Terminating?? 0? ? ? ? ? 19m
statefulset-test-1? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running? ? ?? 0? ? ? ? ? 19m
statefulset-test-2? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running? ? ?? 0? ? ? ? ? 19m

重新自动创建pod

[[email protected] test]# kubectl get pod
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ?? STATUS? ? ? ? ? ? ? RESTARTS?? AGE
statefulset-test-0? ? ? ? ? ? ? ? ? ? ? ? 0/1? ? ?? ContainerCreating?? 0? ? ? ? ? 0s
statefulset-test-1? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running? ? ? ? ? ?? 0? ? ? ? ? 19m
statefulset-test-2? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running? ? ? ? ? ?? 0? ? ? ? ? 19m
[[email protected] test]# kubectl get pod
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ?? STATUS? ? RESTARTS?? AGE
statefulset-test-0? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running?? 0? ? ? ? ? 4s
statefulset-test-1? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running?? 0? ? ? ? ? 20m
statefulset-test-2? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running?? 0? ? ? ? ? 19m
[[email protected] test]# kubectl exec -it? statefulset-test-0 hostname
statefulset-test-0
[[email protected] test]#

可见重新创建pod,pod的名字和hostname没有改变.

把replicas改成1

[[email protected] test]# kubectl apply -f statefulset-test.yaml
service "headless-svc" unchanged
statefulset.apps "statefulset-test" configured
[[email protected] test]# kubectl get pod
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ?? STATUS? ? ? ? RESTARTS?? AGE
statefulset-test-0? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running? ? ?? 0? ? ? ? ? 4m
statefulset-test-1? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running? ? ?? 0? ? ? ? ? 24m
statefulset-test-2? ? ? ? ? ? ? ? ? ? ? ? 0/1? ? ?? Terminating?? 0? ? ? ? ? 24m
[[email protected] test]# kubectl get pod
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ?? STATUS? ? ? ? RESTARTS?? AGE
statefulset-test-0? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running? ? ?? 0? ? ? ? ? 4m
statefulset-test-1? ? ? ? ? ? ? ? ? ? ? ? 0/1? ? ?? Terminating?? 0? ? ? ? ? 24m
[[email protected] test]# kubectl get pod
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ?? STATUS? ? RESTARTS?? AGE
statefulset-test-0? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running?? 0? ? ? ? ? 5m

pod按照顺序一个一个删除

把replicas改回3

[[email protected] test]# kubectl apply -f statefulset-test.yaml
service "headless-svc" unchanged
statefulset.apps "statefulset-test" configured
[[email protected] test]# kubectl get pod
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ?? STATUS? ? ? ? ? ? ? RESTARTS?? AGE
statefulset-test-0? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running? ? ? ? ? ?? 0? ? ? ? ? 6m
statefulset-test-1? ? ? ? ? ? ? ? ? ? ? ? 0/1? ? ?? ContainerCreating?? 0? ? ? ? ? 4s
[[email protected] test]# kubectl get pod
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ?? STATUS? ? ? ? ? ? ? RESTARTS?? AGE
statefulset-test-0? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running? ? ? ? ? ?? 0? ? ? ? ? 6m
statefulset-test-1? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running? ? ? ? ? ?? 0? ? ? ? ? 8s
statefulset-test-2? ? ? ? ? ? ? ? ? ? ? ? 0/1? ? ?? ContainerCreating?? 0? ? ? ? ? 1s
[[email protected] test]# kubectl get pod
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ?? STATUS? ? RESTARTS?? AGE
statefulset-test-0? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running?? 0? ? ? ? ? 6m
statefulset-test-1? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running?? 0? ? ? ? ? 14s
statefulset-test-2? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ?? Running?? 0? ? ? ? ? 7s
[[email protected] test]#
[[email protected] test]# kubectl exec -it statefulset-test-2 hostname
statefulset-test-2
[[email protected] test]#

pod按照顺序顺序一个一个创建,并且pod名字和hostname没有改变

6.
statefulset结合volumeClaimTemplates测试

[[email protected] test]# cat statefulset-test.yaml
apiVersion: v1
kind: Service
metadata:
? name: headless-svc
? labels:
? ? app: headless-svc
spec:
? ports:
? - port: 80
? ? name: myweb
? selector:
? ? app: headless-pod
? clusterIP: None

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
? name: statefulset-test
spec:
? serviceName: headless-svc
? replicas: 3
? selector:
? ? matchLabels:
? ? ? app: headless-pod
? template:
? ? metadata:
? ? ? labels:
? ? ? ? app: headless-pod
? ? spec:
? ? ? containers:
? ? ? - image: httpd
? ? ? ? name: myhttpd
? ? ? ? ports:
? ? ? ? - containerPort: 80
? ? ? ? ? name: httpd
? ? ? ? volumeMounts:
? ? ? ? - mountPath: /mnt
? ? ? ? ? name: test
? volumeClaimTemplates:
? - metadata:
? ? ? name: test
? ? ? annotations:
? ? ? ? volume.beta.kubernetes.io/storage-class: managed-nfs-storage
? ? spec:
? ? ? accessModes: [ "ReadWriteOnce" ]
? ? ? resources:
? ? ? ? requests:
? ? ? ? ? storage: 100Mi

注意格式,多个空格少个空格都会失败.

annotations:
? ? ? ? volume.beta.kubernetes.io/storage-class: managed-nfs-storage

这是指定storageclass

[[email protected] test]# kubectl get pv,pvc
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CAPACITY? ACCESS MODES? RECLAIM POLICY? STATUS? ? CLAIM? ? ? ? ? ? ? ? ? ? ? ? ? ? STORAGECLASS? ? ? ? ? REASON? ? AGE
persistentvolume/pvc-a1c6928d-aebc-11e9-8580-000c291d7023? 100Mi? ? ? RWO? ? ? ? ? ? Delete? ? ? ? ? Bound? ? default/test-statefulset-test-0? managed-nfs-storage? ? ? ? ? ? 1m
persistentvolume/pvc-a94813df-aebc-11e9-8580-000c291d7023? 100Mi? ? ? RWO? ? ? ? ? ? Delete? ? ? ? ? Bound? ? default/test-statefulset-test-1? managed-nfs-storage? ? ? ? ? ? 1m
persistentvolume/pvc-b234f5a7-aebc-11e9-8580-000c291d7023? 100Mi? ? ? RWO? ? ? ? ? ? Delete? ? ? ? ? Bound? ? default/test-statefulset-test-2? managed-nfs-storage? ? ? ? ? ? 49s

NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? STATUS? ? VOLUME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? CAPACITY? ACCESS MODES? STORAGECLASS? ? ? ? ? AGE
persistentvolumeclaim/test-statefulset-test-0? Bound? ? pvc-a1c6928d-aebc-11e9-8580-000c291d7023? 100Mi? ? ? RWO? ? ? ? ? ? managed-nfs-storage? 1m
persistentvolumeclaim/test-statefulset-test-1? Bound? ? pvc-a94813df-aebc-11e9-8580-000c291d7023? 100Mi? ? ? RWO? ? ? ? ? ? managed-nfs-storage? 1m
persistentvolumeclaim/test-statefulset-test-2? Bound? ? pvc-b234f5a7-aebc-11e9-8580-000c291d7023? 100Mi? ? ? RWO? ? ? ? ? ? managed-nfs-storage? 1m
[[email protected] test]#

检索pod对应的pv卷,截取volumes部分对比

[[email protected] test]# kubectl describe pod statefulset-test-0
Name:? ? ? ? ? ? ? statefulset-test-0
Namespace:? ? ? ? ? default
Volumes:
? test:
? ? Type:? ? ? PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
? ? ClaimName:? test-statefulset-test-0
? ? ReadOnly:? false

[[email protected] test]# kubectl describe pod statefulset-test-1
Name:? ? ? ? ? ? ? statefulset-test-1
Namespace:? ? ? ? ? default
Volumes:
? test:
? ? Type:? ? ? PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
? ? ClaimName:? test-statefulset-test-1
? ? ReadOnly:? false

[[email protected] test]# kubectl describe pod statefulset-test-2
Name:? ? ? ? ? ? ? statefulset-test-2
Namespace:? ? ? ? ? default
Volumes:
? test:
? ? Type:? ? ? PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
? ? ClaimName:? test-statefulset-test-2
? ? ReadOnly:? false

可以看到一个pod对应使用了一个pv卷.

检索nfs server存取目录,可以看到新建的pvc目录

[[email protected] k8s]# ls
default-test-statefulset-test-0-pvc-a1c6928d-aebc-11e9-8580-000c291d7023
default-test-statefulset-test-1-pvc-a94813df-aebc-11e9-8580-000c291d7023
default-test-statefulset-test-2-pvc-b234f5a7-aebc-11e9-8580-000c291d7023
[[email protected] k8s]#

测试

删除pod,看看能重新对应原来的pvc卷吗?

[[email protected] test]# kubectl get pod
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? READY? ? STATUS? ? RESTARTS? AGE
statefulset-test-0? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ? Running? 0? ? ? ? ? 12m
statefulset-test-1? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ? Running? 0? ? ? ? ? 11m
statefulset-test-2? ? ? ? ? ? ? ? ? ? ? ? 1/1? ? ? Running? 0? ? ? ? ? 11m

在statefulset-test-1和statefulset-test-2? 新建个文件存储在pvc

[[email protected] test]# kubectl exec -it statefulset-test-1 touch /mnt/t1
[[email protected] test]# kubectl exec -it statefulset-test-2 touch /mnt/t2

检索pvc卷

[[email protected] k8s]# cd default-test-statefulset-test-1-pvc-a94813df-aebc-11e9-8580-000c291d7023/
[[email protected] default-test-statefulset-test-1-pvc-a94813df-aebc-11e9-8580-000c291d7023]# ls
t1
[[email protected] default-test-statefulset-test-1-pvc-a94813df-aebc-11e9-8580-000c291d7023]# cd ..
[[email protected] k8s]# cd default-test-statefulset-test-2-pvc-b234f5a7-aebc-11e9-8580-000c291d7023/
[[email protected] default-test-statefulset-test-2-pvc-b234f5a7-aebc-11e9-8580-000c291d7023]# ls
t2

删除这两个pod

[[email protected] test]# kubectl delete pod statefulset-test-1 statefulset-test-2
pod "statefulset-test-1" deleted
pod "statefulset-test-2" deleted

删除后,pod自动创建创建
再检索重新创建的pod

[[email protected] test]# kubectl describe pod statefulset-test-1
Name:? ? ? ? ? ? ? statefulset-test-1
Namespace:? ? ? ? ? default
Volumes:
? test:
? ? Type:? ? ? PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
? ? ClaimName:? test-statefulset-test-1
? ? ReadOnly:? false

[[email protected] test]# kubectl describe pod statefulset-test-2
Name:? ? ? ? ? ? ? statefulset-test-2
Namespace:? ? ? ? ? default
Volumes:
? test:
? ? Type:? ? ? PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
? ? ClaimName:? test-statefulset-test-2
? ? ReadOnly:? false

可以看到pod命令hostname和存储卷全部都和删除前保持一样.

[[email protected] test]# kubectl exec -it statefulset-test-1 ls /mnt
t1
[[email protected] test]# kubectl exec -it statefulset-test-2 ls /mnt
t2
[[email protected] test]#

前面创建的保存在存储卷的文件也保持不变.

7.
留下的一个疑问:
deployment部署,svc通过kube-proxy结合ipvs和iptables实现访问后端pod.
statefulset部署,svc是如何实现访问后端pod呢?规则是什么?

原文地址:https://blog.51cto.com/goome/2423602

时间: 2024-11-08 23:23:18

k8s实践18:statefulset学习配置记录的相关文章

k8s实践18:helm部署安装grafana配置测试

grafana部署配置测试 grafana官网地址 1.helm部署grafana 部署很简单,见下 [[email protected] prometheus-grafana]# helm install stable/grafana --generate-name NAME: grafana-1577432108 LAST DEPLOYED: Fri Dec 27 15:35:11 2019 NAMESPACE: default STATUS: deployed REVISION: 1 NO

OV Camera AE相关的寄存器学习配置记录

自动AEC相关的寄存器配置的原理如上图.主要设置如下: {0x3a0f, 0x40},    {0x3a10, 0x38},    {0x3a1b, 0x48},    {0x3a1e, 0x30},    {0x3a11, 0x90},    {0x3a1f, 0x10}, band_step60 = preview_sysclk * 100/preview_HTS * 100/120; OV5640_write_i2c(0x3a0a, (band_step60 >> 8)); OV5640

MySQL 5.7.18 压缩包版配置记录

1.解压到一个目录(建议根目录),比如:D:\mysql2.在系统Path中添加 D:\mysql\bin3.这个版本不带my-default.ini,需要自己写,放在D:\mysql\my.ini,相关参数可参考mysqld --verbose --help [client] port=3306 default-character-set=utf8 [mysqld] port=3306 character_set_server=utf8 basedir=D:\mysql datadir=D:\

K8S生产环境中实践高可靠的配置和技巧都有哪些?

K8S环境中实践高可靠的配置和技巧都有哪些? 磁盘类型及大小 磁盘类型: 推荐使用ssd 磁盘 对于worker节点,创建集群时推荐使用挂载数据盘.这个盘是专门给/var/lib/docker 存放本地镜像.可以避免后续因镜像太多而造成磁盘根目录容量不够的情况.在运行一段时间后,本地会存在很多无用的镜像.比较快捷的方式就是,先下线这台机器,重新构建这个磁盘,然后再上线. 磁盘大小: kubernetes节点需要的磁盘空间也不小,Docker镜像.系统日志.应用日志都保存在磁盘上.创建kubern

k8s实践(九):Helm and Kubeapps UI

环境说明: 主机名 操作系统版本 ip docker version kubelet version helm version 配置 备注 master Centos 7.6.1810 172.27.9.131 Docker 18.09.6 V1.14.2 v2.14.3 2C2G master主机 node01 Centos 7.6.1810 172.27.9.135 Docker 18.09.6 V1.14.2 v2.14.3 2C2G node节点 node02 Centos 7.6.18

k8s实践(四):Controller

环境说明: 主机名 操作系统版本 ip docker version kubelet version 配置 备注 master Centos 7.6.1810 172.27.9.131 Docker 18.09.6 V1.14.2 2C2G 备注 node01 Centos 7.6.1810 172.27.9.135 Docker 18.09.6 V1.14.2 2C2G 备注 node02 Centos 7.6.1810 172.27.9.136 Docker 18.09.6 V1.14.2

k8s实践(七):存储卷和数据持久化(Volumes and Persistent Storage)

环境说明: 主机名 操作系统版本 ip docker version kubelet version 配置 备注 master Centos 7.6.1810 172.27.9.131 Docker 18.09.6 V1.14.2 2C2G master主机 node01 Centos 7.6.1810 172.27.9.135 Docker 18.09.6 V1.14.2 2C2G node节点 node02 Centos 7.6.1810 172.27.9.136 Docker 18.09.

k8s实践(八):ConfigMap and Secret

环境说明: 主机名 操作系统版本 ip docker version kubelet version 配置 备注 master Centos 7.6.1810 172.27.9.131 Docker 18.09.6 V1.14.2 2C2G master主机 node01 Centos 7.6.1810 172.27.9.135 Docker 18.09.6 V1.14.2 2C2G node节点 node02 Centos 7.6.1810 172.27.9.136 Docker 18.09.

学习工作记录五

学习工作记录 这是第八周.第七周的合在这里一起写了,主要就是考试,改论文,看spring相关内容.改论文该得心态有点崩. 一 . 文献阅读 没有阅读,主要是调研. 二 . 项目进展 1.环境配置成功,学习如何搭环境以及配置spring. 三 .工作内容 1.这周任务完成情况 任务 完成情况 备注 论文两篇 未完成 调研了许多论文,没细看 掌握spring 未完成 怎么可能完成,我怎么定这么脑残的目标 数值分析自学完成"插值"一章 未完成 进入新篇章了,我该加快进度了 <Acade