8、ConfigMap
抽取利用配置,并且能够自动更新
创立配置文件
[root@k8s-master-node1 ~/yaml/test]# vim configmap.yaml
[root@k8s-master-node1 ~/yaml/test]# cat configmap.yaml
apiVersion: v1
data:
redis.conf: |
appendonly yes
kind: ConfigMap
metadata:
name: redis-conf
namespace: default
[root@k8s-master-node1 ~/yaml/test]#
[root@k8s-master-node1 ~/yaml/test]# kubectl apply -f configmap.yaml
configmap/redis-conf created
[root@k8s-master-node1 ~/yaml/test]#
查看配置
[root@k8s-master-node1 ~/yaml/test]# kubectl get configmaps
NAME DATA AGE
kube-root-ca.crt 1 110m
redis-conf 1 18s
[root@k8s-master-node1 ~/yaml/test]#
9、DaemonSet
DaemonSet 确保全副(或者某些)节点上运行一个 Pod 的正本。当有节点退出集群时,也会为他们新增一个 Pod。当有节点从集群移除时,这些 Pod 也会被回收。删除 DaemonSet 将会删除它创立的所有 Pod。
DaemonSet 的一些典型用法:
在每个节点上运行集群存守护过程在每个节点上运行日志收集守护过程在每个节点上运行监控守护过程一种简略的用法是为每种类型的守护过程在所有的节点上都启动一个 DaemonSet。一个略微简单的用法是为同一种守护过程部署多个 DaemonSet;每个具备不同的标记,并且对不同硬件类型具备不同的内存、CPU 要求。
创立
[root@k8s-master-node1 ~/yaml/test]# vim daemonset.yaml
[root@k8s-master-node1 ~/yaml/test]#
[root@k8s-master-node1 ~/yaml/test]#
[root@k8s-master-node1 ~/yaml/test]# cat daemonset.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: redis-app
labels:
k8s-app: redis-app
spec:
selector:
matchLabels:
name: fluentd-redis
template:
metadata:
labels:
name: fluentd-redis
spec:
tolerations:
# this toleration is to have the daemonset runnable on master nodes
# remove it if your masters can't run pods
- key: node-role.kubernetes.io/master
effect: NoSchedule
containers:
- name: fluentd-redis
image: redis
command:
- redis-server
- "/redis-master/redis.conf" #指的是 redis 容器外部的地位
ports:
- containerPort: 6379
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: data
mountPath: /data
- name: config
mountPath: /redis-master
readOnly: true
terminationGracePeriodSeconds: 30
volumes:
- name: data
emptyDir: {}
- name: config
configMap:
name: redis-conf
items:
- key: redis.conf
path: redis.conf
[root@k8s-master-node1 ~/yaml/test]#
[root@k8s-master-node1 ~/yaml/test]#
[root@k8s-master-node1 ~/yaml/test]# kubectl apply -f daemonset.yaml
daemonset.apps/redis-app created
[root@k8s-master-node1 ~/yaml/test]#
[root@k8s-master-node1 ~/yaml/test]#
查看
[root@k8s-master-node1 ~/yaml/test]#
[root@k8s-master-node1 ~/yaml/test]# kubectl get pod
NAME READY STATUS RESTARTS AGE
ingress-demo-app-694bf5d965-8rh7f 1/1 Running 0 130m
ingress-demo-app-694bf5d965-swkpb 1/1 Running 0 130m
nfs-client-provisioner-dc5789f74-5bznq 1/1 Running 0 114m
redis-app-86g4q 1/1 Running 0 28s
redis-app-rt92n 1/1 Running 0 28s
redis-app-vkzft 1/1 Running 0 28s
web-0 1/1 Running 0 64m
web-1 1/1 Running 0 63m
web-2 1/1 Running 0 63m
[root@k8s-master-node1 ~/yaml/test]# kubectl get daemonsets.apps
NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
redis-app 3 3 3 3 3 <none> 38s
[root@k8s-master-node1 ~/yaml/test]#
Linux 运维交换社区
Linux 运维交换社区,互联网新闻以及技术交换。
62 篇原创内容
公众号
https://blog.csdn.net/qq_3392…
https://my.oschina.net/u/3981543
https://www.zhihu.com/people/…
https://segmentfault.com/u/hp…
https://juejin.cn/user/331578…
https://space.bilibili.com/35…
https://cloud.tencent.com/dev…
知乎、CSDN、开源中国、思否、掘金、哔哩哔哩、腾讯云
本文应用 文章同步助手 同步