当前位置:网站首页>Use of kubernetes storage volumes
Use of kubernetes storage volumes
2022-06-24 21:13:00 【The smell of tobacco】
stay Kubernetes in , There are different ways to mount content , Simply record how they are configured .
ConfigMap
Configure the content
Content configuration
apiVersion: v1
kind: ConfigMap
metadata:
name: test-config
data:
# Add configured key-value Content
test-key: test-value
introduce
apiVersion: v1
kind: Pod
spec:
containers:
- name: test
image: nginx
env:
# scene 1: Can be used to configure environment variables
- name: ENV_NAME
valueFrom:
# Specify a configMap One of the key As value
configMapKeyRef:
name: test-config
key: test-key
# Define the data volume to be hung
volumeMounts:
- name: config-volume
mountPath: /etc/config
envFrom:
# scene 2: Import its entire as env
- configMapRef:
name: test-config
volumes:
- name: config-volume
# scene 3: take ConfigMap Import as data
# After import , key As the file name , value As the content of the document
configMap:
name: test-config
Secret
Store some encrypted information , Current encryption is base64…
Configure mount
Its use is basically the same as ConfigMap identical , Simply change the field name
Content configuration
apiVersion: v1
kind: Secret
metadata:
name: test-secret
type: Opaque
data:
# What's in store here is base64 Content of coding
password: cGFzc3dvcmQ=
introduce
apiVersion: v1
kind: Pod
spec:
containers:
- name: test
image: nginx
env:
# scene 1: Can be used to configure environment variables
- name: ENV_NAME
valueFrom:
# Specify a configMap One of the key As value
secretKeyRef:
name: test-secret
key: password
# Define the data volume to be hung
volumeMounts:
- name: config-volume
mountPath: /etc/config
envFrom:
# scene 2: Import its entire as env
- secretRef:
name: test-secret
volumes:
- name: config-volume
# scene 3: take Secret Import as data
# After import , key As the file name , value As the content of the document
secret:
secretName: test-secret
Image warehouse authentication
When the pulled image warehouse is a private warehouse , Authentication content needs to be added
Content configuration
apiVersion: v1
kind: Secret
metadata:
name: test-register-secret
type: kubernetes.io/dockerconfigjson
data:
# file ~/.docker/config.json Of base64 Code content
# Its content is json: {"auths":{"test.pull.com":{"username":"admin","password":"123456","email":"[email protected]","auth":"YWRtaW46MTIzNDU2"}}}
.dockerconfigjson: eyJhdXRocyI6eyJ0ZXN0LnB1bGwuY29tIjp7InVzZXJuYW1lIjoiYWRtaW4iLCJwYXNzd29yZCI6IjEyMzQ1NiIsImVtYWlsIjoiaHVqaW5nbmJAcXEuY29tIiwiYXV0aCI6IllXUnRhVzQ2TVRJek5EVTIifX19
This thing takes a little effort to generate through the configuration file , All can be generated directly from the command line :
kubectl create secret docker-registry test-register-secret \
--docker-server=< Your mirror warehouse server > \
--docker-username=< Your username > \
--docker-password=< Your password > \
--docker-email=< Your email address >
You can view existing through the command secret Authentication content :
kubectl get secret test-register-secret --output="jsonpath={.data.\.dockerconfigjson}" | base64 --decode
introduce
apiVersion: v1
kind: Pod
spec:
containers:
- name: test
image: nginx
# Specify the configuration information used to pull the image
imagePullSecrets:
- name: test-register-secret
Volume
To be frank , It is the mounting of the disk .
Take a simple example
apiVersion: v1
kind: Pod
spec:
containers:
- name: test
image: nginx
# Define the data volume to be hung
volumeMounts:
- name: config-volume
mountPath: /etc/config
volumes:
- name: config-volume
hostPath:
path: /usr/etc/nginx/config
The local directory /usr/etc/nginx/config Hanging from the container /etc/config On .
Pay attention to some of them hostPath Parameters , It can also be replaced by other , k8s Supports many types of mounted volumes , Here are no examples , The details can be obtained through kubectl explain pod.spec.volumes see . Briefly list some common feelings :
- emptyDir: stay Node Open an empty directory for sharing .
- hostPath: Designated mount Node The local path
边栏推荐
- Leetcode (455) - distribute cookies
- The Google File System (GFS) learning notes
- Basic concepts and definitions of Graphs
- Basic properties and ergodicity of binary tree
- JUnit unit test
- Read all text from stdin to a string
- 科创人·味多美CIO胡博:数字化是不流血的革命,正确答案藏在业务的田间地头
- Self signed certificate generation
- Enjoy yuan mode -- a large number of flying dragons
- Common self realization functions in C language development
猜你喜欢

Record a deletion bash_ Profile file

Interpreter mode -- formulas for dating

After screwing the screws in the factory for two years, I earned more than 10000 yuan a month by "testing" and counterattacked

Hongxiang Yunteng is compatible with dragon lizard operating system, and the product runs stably

Learn to use a new technology quickly

OSI notes sorting

Difference between map and object

Background of master data construction

在Dialog中使用透明的【X】叉叉按钮图片

伯克利、MIT、剑桥、DeepMind等业内大佬线上讲座:迈向安全可靠可控的AI
随机推荐
Record a deletion bash_ Profile file
Common data model (updating)
The Google File System (GFS) learning notes
伯克利、MIT、剑桥、DeepMind等业内大佬线上讲座:迈向安全可靠可控的AI
Codeforces Round #720 (Div. 2)
List set Introduction & common methods
After 5 months' test, it took 15K to come for an interview. When I asked, it was not worth even 5K. It was really
Physical layer introduction
[performance tuning basics] performance tuning strategy
Enjoy yuan mode -- a large number of flying dragons
Go coding specification
NPM download speed is slow
Common member methods of the calendar class
IDEA Dashboard
opds sql组件能不能将流程参数通过上下文传给下一个组件
Jar package operation
浅谈MySql update会锁定哪些范围的数据
data link layer
Introduction to interval DP
科创人·味多美CIO胡博:数字化是不流血的革命,正确答案藏在业务的田间地头