当前位置:网站首页>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
边栏推荐
- Self signed certificate generation
- Format method and parse method of dateformat class
- Background operation retry gave up; KeeperErrorCode = ConnectionLoss
- Network layer
- 红象云腾完成与龙蜥操作系统兼容适配,产品运行稳定
- Packaging_ Conversion between basic type and string type
- Leetcode (135) - distribute candy
- Poj1061 frog dating (extended Euclid)
- Does the developer want to change to software testing?
- Appium desktop introduction
猜你喜欢
![Use the transparent [x] cross button image in the dialog](/img/0c/2be7bc7f20b581a2cc745d9cabe9ff.jpg)
Use the transparent [x] cross button image in the dialog

Vant component used in wechat applet

Berkeley, MIT, Cambridge, deepmind et d'autres grandes conférences en ligne: vers une IA sûre, fiable et contrôlable

Sequence stack version 1.0

Memo mode - game archiving

The JS method parameter passed a number beginning with 0. A magical problem occurred and bothered me for a long time

Enjoy yuan mode -- a large number of flying dragons

Rip/ospf protocol notes sorting

JMeter response assertion

JMeter basic learning records
随机推荐
Background operation retry gave up; KeeperErrorCode = ConnectionLoss
Create a multithreaded thread class
Axi DMA IP core operation process
Does the developer want to change to software testing?
Go coding specification
PIXIV Gizmo
Common self realization functions in C language development
Variable setting in postman
Design of routing service for multi Activity Architecture Design
浅谈MySql update会锁定哪些范围的数据
JMeter basic learning records
Basic database syntax learning
A/B测试助力游戏业务增长
Visitor model -- generation gap between young and middle-aged people
Minimum cost and maximum flow (template question)
Common member methods of the calendar class
Agency mode -- Jiangnan leather shoes factory
NPM download speed is slow
Batch capitalization of MySQL table names
Summary of message protocol problems