当前位置:网站首页>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] ~]#
边栏推荐
- Azure file synchronization of altaro: the end of traditional file servers?
- Communication - how to be a good listener?
- 【无标题】
- ES 2022 正式发布!有哪些新特性?
- Introduction to deep learning (II) -- univariate linear regression
- DEX net 2.0 for crawl detection
- redis 无法远程连接问题。
- @Autowired 导致空指针报错 解决方式
- Transferring images using flask
- 配置xml文件的dtd
猜你喜欢

Classification and discussion of plane grab detection methods based on learning

Latest version of source insight

Altaro set grandfather parent child (GFS) archiving

Altaro virtual machine replication failed: "unsupported file type vmgs"

6.23星期四库作业

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

Disassembly and installation of Lenovo r7000 graphics card

How to install and configure altaro VM backup for VMware vSphere

(subplots用法)matplotlib如何绘制多个子图(轴域)

中职网络子网划分例题解析
随机推荐
kubernetes资源对象介绍及常用命令(五)-(ConfigMap)
Altaro o365 total backup subscription plan
Explanation of variables, code blocks, constructors, static variables and initialization execution sequence of static code blocks of Ali interview questions
6.23星期四库作业
Calculation method of AUC
Win10 install pytullet and test
Can altaro back up Microsoft teams?
XML Configuration File
【无标题】
Get and monitor remote server logs
谷歌 | 蛋白序列的深度嵌入和比对
ROS Compilation Principle
Source insight License Activation
Introduction to webrtc protocol -- an article to understand dtls, SRTP, srtcp
@Solutions to null pointer error caused by Autowired
Webrtc M96 release notes (SDP abolishes Plan B and supports opus red redundant coding)
Go practice -- closures in golang (anonymous functions, closures)
Introduction to redis using Lua script
Explanation of several points needing attention in final (tested by the author)
Altaro requirements for starting from backup on Hyper-V