写在最后
在结束之际,我想重申的是,学习并非如攀登险峻高峰,而是如滴水穿石般的持久累积。尤其当我们步入工作岗位之后,持之以恒的学习变得愈发不易,如同在茫茫大海中独自划舟,稍有松懈便可能被巨浪吞噬。然而,对于我们程序员而言,学习是生存之本,是我们在激烈市场竞争中立于不败之地的关键。一旦停止学习,我们便如同逆水行舟,不进则退,终将被时代的洪流所淘汰。因此,不断汲取新知识,不仅是对自己的提升,更是对自己的一份珍贵投资。让我们不断磨砺自己,与时代共同进步,书写属于我们的辉煌篇章。
需要完整版PDF学习资源私我
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
# 创建本地目录
mkdir configmap
# 将示例文件下载到 `configmap` 目录
wget https://kubernetes.io/examples/configmap/game.properties -O configmap/game.properties
wget https://kubernetes.io/examples/configmap/ui.properties -O configmap/ui.properties
# 创建 configmap
kubectl create configmap -n killer game-config --from-file=configmap/
结果
查看一下下载的文件的内容
查看下configmap
命令
kubectl get configmap -n killer
结果
apiVersion: v1
items:
- apiVersion: v1
data:
game.properties: |-
enemies=aliens
lives=3
enemies.cheat=true
enemies.cheat.level=noGoodRotten
secret.code.passphrase=UUDDLRLRBABAS
secret.code.allowed=true
secret.code.lives=30
ui.properties: |
color.good=purple
color.bad=yellow
allow.textmode=true
how.nice.to.look=fairlyNice
kind: ConfigMap
metadata:
creationTimestamp: "2022-07-10T18:02:16Z"
name: game-config
namespace: killer
resourceVersion: "330866"
selfLink: /api/v1/namespaces/killer/configmaps/game-config
uid: a9551dbc-f42b-47c0-b44d-5b80256b7ff1
kind: List
metadata:
resourceVersion: ""
selfLink: ""
基于文件
命令
kubectl create configmap -n killer ui-config --from-file=configmap/ui.properties
结果
创建环境变量
game-env-file.properties内容如下:
enemies=aliens
lives=3
allowed=“true”
命令
kubectl create configmap game-config-env-file -n killer --from-env-file=configmap/game-env-file.properties
结果
从 Kubernetes 1.23 版本开始,kubectl 支持多次指定 --from-env-file 参数来从多个数据源创建 ConfigMap。
kubectl create configmap config-multi-env-files \
--from-env-file=configure-pod-container/configmap/game-env-file.properties \
--from-env-file=configure-pod-container/configmap/ui-env-file.properties
还有通过生成器和字面值创建configmap,由于一般配置比较多,还是使用目录或文件更方便,这里就不展示了。
使用
环境变量
使用 envFrom 将所有 ConfigMap 的数据定义为容器环境变量,ConfigMap 中的键成为 Pod 中的环境变量名称。
命令
env-test.yaml文件内容如下:
apiVersion: v1
kind: Pod
metadata:
name: env-test-pod
spec:
containers:
- name: env-test-pod
image: busybox
imagePullPolicy: IfNotPresent
command: [ "/bin/sh", "-c", "env" ]
envFrom:
- configMapRef:
name: game-config-env-file
restartPolicy: Never
结果
可以看到刚才的文件中的键值对确实成为了Pod中的环境变量。
挂载
覆盖
注意:这种挂载方式会覆盖目录
busybox的/usr下有sbin目录
命令
volume-test.yaml文件内容如下:
apiVersion: v1
kind: Pod
metadata:
name: volume-test-pod
spec:
containers:
- name: test-container
image: busybox
imagePullPolicy: IfNotPresent
command: [ "/bin/sh","-c","cd /usr && ls && cat /usr/keys" ]
volumeMounts:
- name: config-volume
mountPath: /usr
volumes:
- name: config-volume
configMap:
name: game-config
items:
- key: game.properties
path: keys
restartPolicy: Never
kubectl create -f volume-test.yaml -n killer
结果
可以看到,只有keys文件,没有sbin目录了。
subPath
如果你想挂载的目录下有其他的目录或文件,可以使用这种方式。
命令
subpath-test.yaml
apiVersion: v1
kind: Pod
metadata:
name: subpath-test-pod
spec:
containers:
- name: test-container
image: busybox
imagePullPolicy: IfNotPresent
command: [ "/bin/sh","-c","cd /usr && ls && cat /usr/keys" ]
volumeMounts:
- name: config-volume
mountPath: /usr/keys
subPath: usr/keys
volumes:
- name: config-volume
configMap:
name: game-config
items:
- key: game.properties
path: usr/keys
restartPolicy: Never
注意:前面不要加**/**
kubectl create -f subpath-test.yaml -n killer
结果
先自我介绍一下,小编浙江大学毕业,去过华为、字节跳动等大厂,目前阿里P7
深知大多数程序员,想要提升技能,往往是自己摸索成长,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年最新网络安全全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上网络安全知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新
img-wY5pJiKt-1715105263494)]
[外链图片转存中…(img-kvVICiBj-1715105263495)]
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上网络安全知识点,真正体系化!
由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新