当前位置:网站首页>Kubernetes resource object introduction and common commands (V) - (configmap & Secret)
Kubernetes resource object introduction and common commands (V) - (configmap & Secret)
2022-07-05 20:29:00 【Silly [email protected]】
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
[[email protected] ~]#
# 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 Save in kubernetes Of etcd in .
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 It is more secure and flexible in the definition or container image .
establish Secret
# Command format
kubectl create secret docker-registry jiangnan \
--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] ~]#
This paper is written by mdnice Multi platform Publishing
版权声明
本文为[Silly [email protected][email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/186/202207052006358350.html
边栏推荐
- 1: Citation;
- Welcome to the game and win rich bonuses: Code Golf Challenge officially launched
- 微信小程序正则表达式提取链接
- [C language] merge sort
- Classic implementation method of Hongmeng system controlling LED
- ByteDance dev better technology salon was successfully held, and we joined hands with Huatai to share our experience in improving the efficiency of web research and development
- Leetcode: binary tree 15 (find the value in the lower left corner of the tree)
- 信息学奥赛一本通 1338:【例3-3】医院设置 | 洛谷 P1364 医院设置
- CTF reverse Foundation
- .Net分布式事务及落地解决方案
猜你喜欢
CTF逆向基础
- Oui. Net Distributed Transaction and Landing Solution
鸿蒙os第四次学习
[quick start to digital IC Verification] 8. Typical circuits in digital ICs and their corresponding Verilog description methods
港股将迎“最牛十元店“,名创优品能借IPO突围?
Classic implementation method of Hongmeng system controlling LED
解决Thinkphp框架应用目录下数据库配置信息修改后依然按默认方式连接
小程序页面导航
JS implementation prohibits web page zooming (ctrl+ mouse, +, - zooming effective pro test)
零道云新UI设计中
随机推荐
Mongodb basic exercises
Leetcode brush question: binary tree 13 (the same tree)
鸿蒙系统控制LED的实现方法之经典
小程序事件绑定
基金网上开户安全吗?去哪里开,可以拿到低佣金?
Informatics Orsay all in one 1339: [example 3-4] find the post order traversal | Valley p1827 [usaco3.4] American Heritage
Welcome to the game and win rich bonuses: Code Golf Challenge officially launched
[quick start of Digital IC Verification] 7. Basic knowledge of digital circuits necessary for verification positions (including common interview questions)
[record of question brushing] 1 Sum of two numbers
Reinforcement learning - learning notes 4 | actor critical
. Net distributed transaction and landing solution
Ros2 topic [01]: installing ros2 on win10
nprogress插件 进度条
[Yugong series] go teaching course in July 2022 004 go code Notes
mongodb/文档操作
【数字IC验证快速入门】8、数字IC中的典型电路及其对应的Verilog描述方法
【刷题记录】1. 两数之和
关于BRAM IP复位的优先级
B站UP搭建世界首个纯红石神经网络、基于深度学习动作识别的色情检测、陈天奇《机器学编译MLC》课程进展、AI前沿论文 | ShowMeAI资讯日报 #07.05
点云文件的.dat文件读取保存