当前位置:网站首页>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
边栏推荐
- Docker deploy mysql5.7
- Is the waiting insurance record a waiting insurance evaluation? What is the relationship between the two?
- Postman assertion
- Bridging mode -- law firm
- An example illustrates restful API
- Web automation: web control interaction / multi window processing / Web page frame
- (to be optimized and modified) vivado DDR4 SDRAM (MIG) (2.2) IP core learning record
- database/sql
- Common data model (updating)
- I feel that I am bald again when I help my children with their homework. I feel pity for my parents all over the world
猜你喜欢

Combination mode -- stock speculation has been cut into leeks? Come and try this investment strategy!

Procedural life: a few things you should know when entering the workplace

JMeter basic learning records

Sequential stack traversal binary tree

虚拟化是什么意思?包含哪些技术?与私有云有什么区别?

Visitor model -- generation gap between young and middle-aged people

Leetcode(135)——分发糖果

Alibaba cloud schedules tasks and automatically releases them

Enjoy yuan mode -- a large number of flying dragons

Nifi fast authentication configuration
随机推荐
JMeter basic learning records
Smooth live broadcast | analysis of key technologies for live broadcast pain points
Jar package operation
Codeforces Round #720 (Div. 2)
The Google File System (GFS) learning notes
Variable setting in postman
Design of routing service for multi Activity Architecture Design
Basic database syntax learning
浅谈MySql update会锁定哪些范围的数据
Mr. Hu Bo, CIO of weiduomei, a scientific innovator: digitalization is a bloodless revolution, and the correct answer lies in the field of business
Realization of truth table assignment by discrete mathematical programming
Summary of idea practical skills: how to rename a project or module to completely solve all the problems you encounter that do not work. It is suggested that the five-star collection be your daughter
Basic properties and ergodicity of binary tree
Intermediary model -- collaboration among departments
After screwing the screws in the factory for two years, I earned more than 10000 yuan a month by "testing" and counterattacked
畅直播|针对直播痛点的关键技术解析
Tool composition in JMeter
Minimum cost and maximum flow (template question)
伯克利、MIT、劍橋、DeepMind等業內大佬線上講座:邁向安全可靠可控的AI
JUnit unit test