当前位置:网站首页>Kubernetes resource object introduction and common commands (V) - (configmap)
Kubernetes resource object introduction and common commands (V) - (configmap)
2022-07-03 05:37:00 【Jiang Xiaonan】
One 、ConfitMap
config set , Extract application configuration .
ConfigMap Save in kubernetes Of etcd in .
ConfigMap Can be file Mount directly to Pod Inside , Different from the previous article PV&PVC mount Catalog .
establish ConfigMap
Command line mode
[[email protected] ~]# vi redis.conf
[[email protected] ~]# cat redis.conf
appendonly yes
[[email protected] ~]# kubectl create cm redis-conf --from-file=redis.conf
configmap/redis.conf created
[[email protected] ~]#
First of all, there is redis.conf file , Then make the document ConfigMap.
yaml The way ,redis-conf.yml
apiVersion: v1
data:
redis.conf: |
appendonly yes
kind: ConfigMap
metadata:
name: redis-conf
namespace: default
data Is all the real data ,key: The default is file name ,value: Content of profile
[[email protected] ~]# kubectl apply -f redis-conf.yml
configmap/redis-conf created
[[email protected] ~]#
see ConfigMap
[[email protected] ~]# kubectl get cm
NAME DATA AGE
kube-root-ca.crt 1 2d1h
redis-conf 1 53s
[[email protected] ~]#
Expand : see redis-conf Of yaml file
kubectl get cm redis-conf -oyaml
establish pod
redis.yml
apiVersion: v1
kind: Pod
metadata:
name: redis
spec:
containers:
- name: redis
image: redis
command:
- redis-server
- "/redis-master/redis.conf" # refer to redis Position inside the container
ports:
- containerPort: 6379
volumeMounts:
- mountPath: /data
name: data
- mountPath: /redis-master
name: config
volumes:
- name: data
emptyDir: {}
- name: config
configMap:
name: redis-conf
items:
- key: redis.conf
path: redis.conf
explain : One ConfigMap The file may have multiple configurations ,items Will traverse each configuration ,key Define which configuration to take here ,path Indicates which file in the container the content of the extracted configuration file is placed .
Refer to the diagram below :

[[email protected] ~]# kubectl apply -f redis.yml
pod/redis created
# Go inside the container to verify
[[email protected] ~]# kubectl exec -it redis -c redis -- /bin/bash
[email protected]:/data# cd /redis-master/
[email protected]:/redis-master# ls
redis.conf
[email protected]:/redis-master# cat redis.conf
appendonly yes
[email protected]:/redis-master#
modify ConfigMap
[[email protected] ~]# kubectl edit cm redis-conf
configmap/redis-conf edited
[[email protected] ~]#
Added a line of configuration requirepass 123456.
[[email protected] ~]# kubectl exec -it redis -c redis -- /bin/bash
[email protected]:/data# cd /redis-master/
[email protected]:/redis-master# ls
redis.conf
[email protected]:/redis-master# cat redis.conf
appendonly yes
requirepass 123456
[email protected]:/redis-master#
ConfigMap Automatically updated .
Key points : The automatic update here is just the file following inside the container ConfigMap To change , But it may not really take effect , It mainly depends on whether the application has hot deployment capability , Applications without hot deployment capability need to be restarted to take effect .
Delete ConfigMap
kubectl delete cm redis-conf
Two 、Secret
Secret Object types are used to hold sensitive information , For example, password 、OAuth Token and SSH secret key . Put this information in secret Put the middle ratio in Pod The definition of or Container mirror More secure and flexible in .
establish Secret
# Command format
kubectl create secret docker-registry regcred \
--docker-server=< Your mirror warehouse server > \
--docker-username=< Your username > \
--docker-password=< Your password > \
--docker-email=< Your email address >
see Secret
[[email protected] ~]# kubectl get secret
NAME TYPE DATA AGE
default-token-ssmvn kubernetes.io/service-account-token 3 2d2h
jiangnan kubernetes.io/dockerconfigjson 1 2m6s
[[email protected] ~]#
Delete Secret
[[email protected] ~]# kubectl delete secret jiangnan
secret "jiangnan" deleted
[[email protected] ~]#
边栏推荐
- Can altaro back up Microsoft teams?
- Mapbox tasting value cloud animation
- 2022.DAY592
- Redis 入门和数据类型讲解
- Xaml gradient issue in uwp for some devices
- Troubleshooting of 32GB Jetson Orin SOM failure to brush
- Analysis of the example of network subnet division in secondary vocational school
- Simpleitk learning notes
- Transferring images using flask
- 联想R7000显卡的拆卸与安装
猜你喜欢

Deploy crawl detection network using tensorrt (I)

Simpleitk learning notes

Linux登录MySQL出现ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)

Go practice -- design patterns in golang's singleton

Redis cannot connect remotely.

Today, many CTOs were killed because they didn't achieve business

Intégration profonde et alignement des séquences de protéines Google

Webrtc native M96 version opening trip -- a reading code download and compilation (Ninja GN depot_tools)

ES7 easy mistakes in index creation

(完美解决)matplotlib图例(legend)如何自由设置其位置
随机推荐
Today, many CTOs were killed because they didn't achieve business
Webrtc native M96 version opening trip -- a reading code download and compilation (Ninja GN depot_tools)
redis 遇到 NOAUTH Authentication required
Transferring images using flask
Explanation of several points needing attention in final (tested by the author)
期末复习DAY8
穀歌 | 蛋白序列的深度嵌入和比對
Detailed explanation of yolov5 training own data set
How to install and configure altaro VM backup for VMware vSphere
Troubleshooting of 32GB Jetson Orin SOM failure to brush
[set theory] relational closure (relational closure related theorem)
PHP笔记超详细!!!
DEX net 2.0 for crawl detection
【一起上水硕系列】Day 7 内容+Day8
Calculation method of AUC
Gan network thought
Common interview questions of microservice
Go practice -- gorilla/rpc (gorilla/rpc/json) used by gorilla web Toolkit
Go practice -- gorilla / websocket used by gorilla web Toolkit
ROS Compilation Principle