当前位置:网站首页>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
边栏推荐
- CCPC 2021威海 - G. Shinyruo and KFC(组合数,小技巧)
- [quick start of Digital IC Verification] 9. Finite state machine (FSM) necessary for Verilog RTL design
- A solution to PHP's inability to convert strings into JSON
- Schema和Model
- Scala基础【HelloWorld代码解析,变量和标识符】
- 19 mongoose modularization
- ROS2专题【01】:win10上安装ROS2
- Codeforces Round #804 (Div. 2) - A, B, C
- Guidelines for application of Shenzhen green and low carbon industry support plan in 2023
- Process file and directory names
猜你喜欢

Leetcode skimming: binary tree 12 (all paths of binary tree)
![[quick start of Digital IC Verification] 1. Talk about Digital IC Verification, understand the contents of the column, and clarify the learning objectives](/img/90/88a1f79a07016738d2688548e21949.png)
[quick start of Digital IC Verification] 1. Talk about Digital IC Verification, understand the contents of the column, and clarify the learning objectives

1、强化学习基础知识点

About the priority of Bram IP reset

鸿蒙系统控制LED的实现方法之经典

- Oui. Net Distributed Transaction and Landing Solution

【数字IC验证快速入门】8、数字IC中的典型电路及其对应的Verilog描述方法

实操演示:产研团队如何高效构建需求工作流?

【数字IC验证快速入门】1、浅谈数字IC验证,了解专栏内容,明确学习目标

死信队列入门(两个消费者,一个生产者)
随机推荐
mongodb基操的练习
Usaco3.4 "broken Gong rock" band raucous rockers - DP
Introduction to dead letter queue (two consumers, one producer)
2022北京眼睛健康用品展,护眼产品展,中国眼博会11月举办
鸿蒙系统控制LED的实现方法之经典
Leetcode skimming: binary tree 12 (all paths of binary tree)
资源道具化
Minimum commission for stock trading account opening, where to open an account with low commission? Is it safe to open an account on your mobile phone
[quick start to digital IC Verification] 8. Typical circuits in digital ICs and their corresponding Verilog description methods
How to choose a good external disk platform, safe and formal?
PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
CTF逆向基础
B站UP搭建世界首个纯红石神经网络、基于深度学习动作识别的色情检测、陈天奇《机器学编译MLC》课程进展、AI前沿论文 | ShowMeAI资讯日报 #07.05
Applet global configuration
零道云新UI设计中
CCPC 2021 Weihai - G. shinyruo and KFC (combination number, tips)
信息学奥赛一本通 1338:【例3-3】医院设置 | 洛谷 P1364 医院设置
小程序事件绑定
实操演示:产研团队如何高效构建需求工作流?
走入并行的世界