Kubernetes core practice (VI) — configmap

Time:2022-5-7

8、ConfigMap

Extract the application configuration and update it automatically

create profile
[[email protected]node1 ~/yaml/test]# vim configmap.yaml
[[email protected] ~/yaml/test]# cat configmap.yaml 
apiVersion: v1
data:   
  redis.conf: |
    appendonly yes
kind: ConfigMap
metadata:
  name: redis-conf
  namespace: default
[[email protected] ~/yaml/test]# 
[[email protected] ~/yaml/test]# kubectl apply -f configmap.yaml 
configmap/redis-conf created
[[email protected] ~/yaml/test]#
View configuration
[[email protected] ~/yaml/test]# kubectl  get configmaps 
NAME               DATA   AGE
kube-root-ca.crt   1      110m
redis-conf         1      18s
[[email protected] ~/yaml/test]#

9、DaemonSet

The daemon set ensures that a copy of the pod is running on all (or some) nodes. When a node joins the cluster, it will also add a pod for them. When a node is removed from the cluster, these pods will also be recycled. Deleting a daemonset will delete all pods it creates.

Some typical usage of daemonset:

Run the cluster storage daemon on each node, run the log collection daemon on each node, and run the monitoring daemon on each node. A simple usage is to start a daemonset on all nodes for each type of daemon. A slightly more complex usage is to deploy multiple daemonsets for the same daemon; Each has different flags, and has different memory and CPU requirements for different hardware types.

Kubernetes core practice (VI) -- configmap

establish
[[email protected] ~/yaml/test]# vim daemonset.yaml
[[email protected] ~/yaml/test]# 
[[email protected] ~/yaml/test]# 
[[email protected] ~/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" # refers to the location inside the redis container
        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
[[email protected] ~/yaml/test]# 
[[email protected] ~/yaml/test]# 
[[email protected] ~/yaml/test]# kubectl  apply -f daemonset.yaml 
daemonset.apps/redis-app created
[[email protected] ~/yaml/test]# 
[[email protected] ~/yaml/test]#
see
[[email protected] ~/yaml/test]# 
[[email protected] ~/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
[[email protected] ~/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
[[email protected] ~/yaml/test]#

Kubernetes core practice (VI) -- configmap

Linux operation and maintenance Communication Community

Linux operation and maintenance exchange community, Internet news and technology exchange.

62 original content

official account

Kubernetes core practice (VI) -- configmap

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…

Zhihu, CSDN, open source China, Sifu, Nuggets, BiliBili, Tencent cloud

This article usesArticle synchronization assistantsynchronization