k8s原生配置管理Kustomize利器生成资源
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
目录
一.kustmize生成资源方式
configMap和secret包含其他kubernetes对象(如Pod)所需要的配置或铭感数据来源往往是集群外部,例如某个".properties",".my.cnf"等文件或者SSH秘钥文件。
kustmize提供secretGenerator和configMapGenerator,可以基于文件或字面值来生成secret和configMap。
推荐阅读:
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/configmapgenerator/
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/secretgenerator/
二.configMapGenerator生成cm资源清单
1 基于属性文件来生成configMap资源清单
1.创建存放kustomize相关的目录信息
[root@master231 yinzhengjie]# mkdir -pv kustomize/cm
2.创建application.properties测试文件
[root@master231 yinzhengjie]# cat > kustomize/cm/application.properties <<EOF
HOST=10.0.0.250
USER=admin
PASSWORD="1"
EOF
3.创建kustomization.yaml文件
[root@master231 yinzhengjie]# cat > kustomize/cm/kustomization.yaml << EOF
configMapGenerator:
- name: yinzhengjie-cm-harbor
files:
- application.properties
EOF
4.生成configMap资源清单
[root@master231 yinzhengjie]# kubectl kustomize kustomize/cm/
apiVersion: v1
data:
application.properties: |
HOST=10.0.0.250
USER=admin
PASSWORD="1"
kind: ConfigMap
metadata:
name: yinzhengjie-cm-harbor-dmgd2c6dct
[root@master231 yinzhengjie]#
三.基于env文件生成configMap资源清单
1.创建存放kustomize相关的目录信息
[root@master231 yinzhengjie]# mkdir kustomize/cm/env
2.创建jdk.sh测试文件
[root@master231 yinzhengjie]# cat > kustomize/cm/env/jdk.sh <<'EOF'
JAVA_HOME=/yinzhengjie/softwares/jdk
PATH=$PATH:$JAVA_HOME/bin
EOF
3.创建kustomization.yaml文件
[root@master231 yinzhengjie]# cat > kustomize/cm/env/kustomization.yaml << EOF
configMapGenerator:
- name: yinzhengjie-cm-envs-jdk
envs:
- jdk.sh
EOF
4.生成configMap资源清单
[root@master231 yinzhengjie]# kubectl kustomize kustomize/cm/env
apiVersion: v1
data:
JAVA_HOME: /yinzhengjie/softwares/jdk
PATH: $PATH:$JAVA_HOME/bin
kind: ConfigMap
metadata:
name: yinzhengjie-cm-envs-jdk-k2fc6768cf
[root@master231 yinzhengjie]#
2 deploy引用cm资源实战
2.1 创建工作目录
[root@master231 yinzhengjie]# mkdir kustomize/deploy
2.2 创建用于生成cm的配置文件
[root@master231 yinzhengjie]# cat > kustomize/deploy/application.properties <<EOF
HOST=10.0.0.250
USER=admin
PASSWORD="1"
EOF
2.3 deploy引用cm资源
[root@master231 yinzhengjie]# cat > kustomize/deploy/deployments.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
volumes:
- name: data
configMap:
name: yinzhengjie-cm-harbor
containers:
- name: c1
image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
ports:
- containerPort: 80
volumeMounts:
- name: data
mountPath: /yinzhengjie/cm
EOF
2.4 创建kustomization.yaml文件,让"deployments.yaml"文件引用cm资源的名称
[root@master231 yinzhengjie]# cat > kustomize/deploy/kustomization.yaml << EOF
resources:
- deployments.yaml
configMapGenerator:
- name: yinzhengjie-cm-harbor
files:
- application.properties
EOF
2.5 生成deployment引用configMap资源清单
[root@master231 yinzhengjie]# kubectl kustomize kustomize/deploy/
apiVersion: v1
data:
application.properties: |
HOST=10.0.0.250
USER=admin
PASSWORD="1"
kind: ConfigMap
metadata:
name: yinzhengjie-cm-harbor-dmgd2c6dct
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
name: c1
ports:
- containerPort: 80
volumeMounts:
- mountPath: /yinzhengjie/cm
name: data
volumes:
- configMap:
name: yinzhengjie-cm-harbor-dmgd2c6dct
name: data
[root@master231 yinzhengjie]#
四.设置贯穿性字段方法
1 贯穿性字段使用场景说明
贯穿性字段的一些使用场景如下:
- 为对象添加相同的标签(Labels)集合;
- 为所有对象添加注解(annotations)集合;
- 为所有的资源设置相同的名称空间(namespace);
- 为所有对象添加相同的前缀或后缀;
推荐阅读:
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/commonannotations/
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/commonlabels/
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/namespace/
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/nameprefix/
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/namesuffix/
2 创建测试目录
[root@master231 yinzhengjie]# mkdir -pv kustomize/deploy/case-demo-2
3 编写deploy资源清单原模板
[root@master231 yinzhengjie]# cat > kustomize/deploy/case-demo-2/deployments.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
containers:
- name: c1
image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
ports:
- containerPort: 80
EOF
4 创建kustomization.yaml文件
[root@master231 yinzhengjie]# cat > kustomize/deploy/case-demo-2/kustomization.yaml << EOF
resources:
- deployments.yaml
namespace: kube-public
namePrefix: production-env-
nameSuffix: "-001"
commonLabels:
apps: xiuxian
commonAnnotations:
version: v1
EOF
温馨提示:
resources:
表示针对那个资源清单作为基础模板。
namespace:
添加名称空间字段。
namePrefix:
添加资源名称的前缀。
nameSuffix:
添加资源名称的后缀。
commonLabels:
添加标签,若模板有标签,则直接覆盖。
commonAnnotations
添加注解标签。
5 基于kustomize生成deploy模板
[root@master231 yinzhengjie]# kubectl kustomize kustomize/deploy/case-demo-2/
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
version: v1
labels:
apps: xiuxian
name: production-env-deploy-xiuxian-001
namespace: kube-public
spec:
replicas: 3
selector:
matchLabels:
apps: xiuxian
template:
metadata:
annotations:
version: v1
labels:
apps: xiuxian
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
name: c1
ports:
- containerPort: 80
[root@master231 yinzhengjie]#
五.组合资源
1 组合资源概述
kustomize提供基于不同文件来组织资源并向其应用补丁或者其他定制的能力。
kustomize支持组合不同的资源,kustomization.yaml文件中的resources字段定义配置要包含的资源列表。
2 组合案例
2.1 创建测试目录
[root@master231 yinzhengjie]# mkdir kustomize/deploy/case-demo-3
2.2 编写deploy资源清单
[root@master231 yinzhengjie]# cat > kustomize/deploy/case-demo-3/deployments.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
containers:
- name: c1
image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
ports:
- containerPort: 80
EOF
2.3 编写svc资源清单
[root@master231 yinzhengjie]# cat > kustomize/deploy/case-demo-3/service.yaml <EOF
apiVersion: v1
kind: Service
metadata:
name: svc-xiuxian
labels:
auther: yinzhengjie-svc
spec:
type: ClusterIP
ports:
- port: 80
selector:
apps: v1
EOF
2.4 创建kustomization.yaml文件组合deploy和svc资源
[root@master231 yinzhengjie]# cat > kustomize/deploy/case-demo-3/kustomization.yaml << 'EOF'
resources:
- deployments.yaml
- service.yaml
EOF
2.5 基于kustomize生成模板
[root@master231 yinzhengjie]# kubectl kustomize kustomize/deploy/case-demo-3/
apiVersion: v1
kind: Service
metadata:
labels:
auther: yinzhengjie-svc
name: svc-xiuxian
spec:
ports:
- port: 80
selector:
apps: v1
type: ClusterIP
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
name: c1
ports:
- containerPort: 80
[root@master231 yinzhengjie]#
六 全局补丁patchStrategicMerge
1 patchStrategicMerge概述
补丁文件(Patches)可以用来对资源执行不同的定制,kustomize通过patchStrategicMerge和patchesJson6902支持不同的打补丁机制。
patchStrategicMerge的内容是一个文件路径的列表,其中每个文件都可解析为策略性合并补丁(Strategic Merge Patch)。
补丁文件中的名称必须与已经加载资源的名称匹配。建议构造规模较小的,仅做一件事情的补丁。例如,构造一个补丁来增加Deployment的副本个数,构造另外一个补丁来设置内存机制。
推荐阅读:
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/patchesstrategicmerge/
2 编写deploy资源清单
[root@master231 yinzhengjie]# mkdir kustomize/deploy/patchStrategicMerge
[root@master231 yinzhengjie]#
[root@master231 yinzhengjie]# cat > kustomize/deploy/patchStrategicMerge/deployments.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
containers:
- name: c1
image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
ports:
- containerPort: 80
EOF
3 生成一个patch_replicas.yaml补丁文件
[root@master231 yinzhengjie]# cat > kustomize/deploy/patchStrategicMerge/patch_replicas.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 5
EOF
4 生成另一个补丁patch_resources.yaml补丁文件
[root@master231 yinzhengjie]# cat > kustomize/deploy/patchStrategicMerge/patch_resources.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
template:
spec:
containers:
- name: c1
resources:
limits:
cpu: 0.5
memoroy: 200Mi
EOF
5 创建kustomization.yaml文件进行打补丁
[root@master231 yinzhengjie]# cat > kustomize/deploy/patchStrategicMerge/kustomization.yaml << 'EOF'
resources:
- deployments.yaml
patchesStrategicMerge:
- patch_replicas.yaml
- patch_resources.yaml
EOF
6 基于kustomize生成模板
[root@master231 yinzhengjie]# ll kustomize/deploy/patchStrategicMerge
total 24
drwxr-xr-x 2 root root 4096 Dec 8 07:41 ./
drwxr-xr-x 5 root root 4096 Dec 8 07:32 ../
-rw-r--r-- 1 root root 353 Dec 8 07:32 deployments.yaml
-rw-r--r-- 1 root root 98 Dec 8 07:41 kustomization.yaml
-rw-r--r-- 1 root root 90 Dec 8 07:35 patch_replicas.yaml
-rw-r--r-- 1 root root 218 Dec 8 07:38 patch_resources.yaml
[root@master231 yinzhengjie]#
[root@master231 yinzhengjie]# kubectl kustomize kustomize/deploy/patchStrategicMerge
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 5
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
name: c1
ports:
- containerPort: 80
resources:
limits:
cpu: 0.5
memoroy: 200Mi
[root@master231 yinzhengjie]#
七 布局补丁patchesJson6902
1 patchesJson6902概述
并非所有资源或者字段都支持策略性合并补丁。为了支持对所有资源的任意字段进行修改,kustomize提供通过patchesJson6902来应用JSON补丁的能力。
为了给JSON补丁找到正确的资源,需要在kustomization.yaml文件中制定资源的组(group),版本(version),类别(kind)和名称(name)。
官网链接:
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/patchesjson6902/
2 编写deploy资源清单
[root@master231 yinzhengjie]# mkdir kustomize/deploy/patchesJson6902
[root@master231 yinzhengjie]#
[root@master231 yinzhengjie]# cat > kustomize/deploy/patchesJson6902/deployments.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
containers:
- name: c1
image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
ports:
- containerPort: 80
EOF
3 创建一个patch_json_replicas.yaml补丁文件
[root@master231 yinzhengjie]# cat > kustomize/deploy/patchesJson6902/patch_json_replicas.yaml <<EOF
- op: replace
path: /spec/replicas
value: 10
EOF
4 创建kustomization.yaml文件进行打补丁
[root@master231 yinzhengjie]# cat > kustomize/deploy/patchesJson6902/kustomization.yaml << 'EOF'
resources:
- deployments.yaml
patchesJson6902:
- target:
group: apps
version: v1
kind: Deployment
name: deploy-xiuxian
# 使用path字段,基于文件的方式导入
path: patch_json_replicas.yaml
# 也可以不导入文件的方式,而知将文件的内容直接写到patch字段中,如下所示。
#patch: |-
# - op: replace
# path: /spec/replicas
# value: 8
EOF
5 基于kustomize生成模板
[root@master231 yinzhengjie]# ll kustomize/deploy/patchesJson6902/
total 20
drwxr-xr-x 2 root root 4096 Dec 8 08:31 ./
drwxr-xr-x 6 root root 4096 Dec 8 07:49 ../
-rw-r--r-- 1 root root 353 Dec 8 07:49 deployments.yaml
-rw-r--r-- 1 root root 386 Dec 8 08:31 kustomization.yaml
-rw-r--r-- 1 root root 49 Dec 8 08:26 patch_json_replicas.yaml
[root@master231 yinzhengjie]#
[root@master231 yinzhengjie]# kubectl kustomize kustomize/deploy/patchesJson6902/
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 10
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
name: c1
ports:
- containerPort: 80
[root@master231 yinzhengjie]#
八.kustomization.yaml的images字段修改镜像
1 image概述
kustomize提供修改容器镜像的能力,支持修改镜像名称(name),版本号(tags)和摘要信息(digest),并且不需要创建补丁。
可以通过以下方式更改image:
name:
旧的镜像名称。
newName:
新的镜像名称。
newTag:
新的镜像的版本号(tags)或者摘要(digest)信息。
推荐阅读:
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/images/
2 编写deploy资源清单
[root@master231 yinzhengjie]# mkdir kustomize/deploy/images
[root@master231 yinzhengjie]#
[root@master231 yinzhengjie]# cat > kustomize/deploy/images/deployments.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
containers:
- name: c1
image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
ports:
- containerPort: 80
EOF
3 创建kustomization.yaml文件进行动态注入
[root@master231 yinzhengjie]# cat > kustomize/deploy/images/kustomization.yaml << 'EOF'
resources:
- deployments.yaml
images:
- name: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
newName: harbor.yinzhengjie.com/kubesphere/kubekey
newTag: v4.1
EOF
4 测试验证
[root@master231 yinzhengjie]# ll kustomize/deploy/images/
total 16
drwxr-xr-x 2 root root 4096 Dec 8 08:56 ./
drwxr-xr-x 7 root root 4096 Dec 8 08:55 ../
-rw-r--r-- 1 root root 353 Dec 8 08:55 deployments.yaml
-rw-r--r-- 1 root root 183 Dec 8 08:56 kustomization.yaml
[root@master231 yinzhengjie]#
[root@master231 yinzhengjie]# kubectl kustomize kustomize/deploy/images/
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
containers:
- image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v2
name: c1
ports:
- containerPort: 80
[root@master231 yinzhengjie]#
八 kustomization.yaml的replicas字段修改副本数
1 replicas概述
kustomize官方提供了更改资源的副本数量。
推荐阅读:
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/replicas/
2 编写deploy资源清单
[root@master231 yinzhengjie]# mkdir kustomize/deploy/replicas
[root@master231 yinzhengjie]#
[root@master231 yinzhengjie]# cat > kustomize/deploy/replicas/deployments.yaml << EOF
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-xiuxian
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: v1
spec:
containers:
- name: c1
image: registry.cn-hangzhou.aliyuncs.com/yinzhengjie-k8s/apps:v1
ports:
- containerPort: 80
EOF
3 创建kustomization.yaml文件进行动态注入
[root@master231 yinzhengjie]# cat > kustomize/deploy/replicas/kustomization.yaml << 'EOF'
resources:
- deployments.yaml
replicas:
- name: deploy-xiuxian
count: 5
EOF
九 基于变量注入字段替换名称引用
1 变量注入字段概述
Pod中运行的应用可能需要使用来自其他对象的配置值,例如部署wordpress需要连接MySQL数据库的场景,在使用deployment部署wordpress时,就得在wordpress写上MySQL的svc名称,而svc的名称如果使用了namePrefix或者nameSuffix时svc的名称变化是随机的。
对于上述场景,kustomize可以通过vars将svc名称注入到容器中。
推荐阅读:
https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/vars/
2 编写MySQL相关的资源清单
1.创建资源清单目录
[root@master231 yinzhengjie]# mkdir -pv kustomize/case-demo/wordpress
[root@master231 yinzhengjie]#
2.基于rc部署MySQL服务
[root@master231 yinzhengjie]# cat > kustomize/case-demo/wordpress/replicationcontrollers.yaml <<EOF
apiVersion: v1
kind: ReplicationController
metadata:
name: rc-db
spec:
replicas: 1
selector:
apps: db
template:
spec:
containers:
- name: c1
image: harbor.yinzhengjie.com/yinzhengjie-db/mysql:8.0.36-oracle
env:
- name: MYSQL_ALLOW_EMPTY_PASSWORD
value: "yes"
- name: MYSQL_USER
value: JieGeJiangYunWei
- name: MYSQL_PASSWORD
value: yinzhengjie
- name: MYSQL_DATABASE
value: wordpress
metadata:
labels:
apps: db
EOF
3.基于svc暴露MySQL
[root@master231 yinzhengjie]# cat > kustomize/case-demo/wordpress/svc-db.yaml <<EOF
apiVersion: v1
kind: Service
metadata:
name: svc-db
spec:
type: ClusterIP
selector:
apps: db
ports:
- port: 3306
targetPort: 3306
EOF
3 编写wordpress相关的资源清单
1.基于deploy部署WordPress(注意变量引用)
[root@master231 yinzhengjie]# cat > kustomize/case-demo/wordpress/deployments.yaml << 'EOF'
apiVersion: apps/v1
kind: Deployment
metadata:
name: deploy-wp
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
spec:
containers:
- name: c1
image: harbor.yinzhengjie.com/yinzhengjie-wp/wordpress:latest
env:
- name: WORDPRESS_DB_HOST
# 注意,此处是我引用的svc变量名称
value: "$(YINZHENGJIE_SVC_WORDPRESS_DB_HOST)"
- name: WORDPRESS_DB_USER
value: JieGeJiangYunWei
- name: WORDPRESS_DB_PASSWORD
value: yinzhengjie
- name: WORDPRESS_DB_NAME
value: wordpress
metadata:
labels:
apps: wp
EOF
2.基于svc暴露WordPress服务
[root@master231 yinzhengjie]# cat > kustomize/case-demo/wordpress/svc-wp.yaml <<EOF
apiVersion: v1
kind: Service
metadata:
name: svc-wp
spec:
type: NodePort
selector:
apps: wp
ports:
- port: 80
targetPort: 80
nodePort: 30090
EOF
4 创建kustomization.yaml文件编写
[root@master231 yinzhengjie]# cat > kustomize/case-demo/wordpress/kustomization.yaml << 'EOF'
namePrefix: test-
nameSuffix: "-001"
resources:
- deployments.yaml
- replicationcontrollers.yaml
- svc-db.yaml
- svc-wp.yaml
vars:
- name: YINZHENGJIE_SVC_WORDPRESS_DB_HOST
objref:
apiVersion: v1
kind: Service
name: svc-db
EOF
5 测试验证
[root@master231 yinzhengjie]# kubectl kustomize kustomize/case-demo/wordpress/
apiVersion: v1
kind: Service
metadata:
name: test-svc-db-001
spec:
ports:
- port: 3306
targetPort: 3306
selector:
apps: db
type: ClusterIP
---
apiVersion: v1
kind: Service
metadata:
name: test-svc-wp-001
spec:
ports:
- nodePort: 30090
port: 80
targetPort: 80
selector:
apps: wp
type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-deploy-wp-001
spec:
replicas: 3
selector:
matchLabels:
apps: v1
template:
metadata:
labels:
apps: wp
spec:
containers:
- env:
- name: WORDPRESS_DB_HOST
value: test-svc-db-001
- name: WORDPRESS_DB_USER
value: JieGeJiangYunWei
- name: WORDPRESS_DB_PASSWORD
value: yinzhengjie
- name: WORDPRESS_DB_NAME
value: wordpress
image: harbor.yinzhengjie.com/yinzhengjie-wp/wordpress:latest
name: c1
---
apiVersion: v1
kind: ReplicationController
metadata:
name: test-rc-db-001
spec:
replicas: 1
selector:
apps: db
template:
metadata:
labels:
apps: db
spec:
containers:
- env:
- name: MYSQL_ALLOW_EMPTY_PASSWORD
value: "yes"
- name: MYSQL_USER
value: JieGeJiangYunWei
- name: MYSQL_PASSWORD
value: yinzhengjie
- name: MYSQL_DATABASE
value: wordpress
image: harbor.yinzhengjie.com/yinzhengjie-db/mysql:8.0.36-oracle
name: c1
[root@master231 yinzhengjie]#
本文来自博客园,作者:尹正杰,转载请注明原文链接:https://www.cnblogs.com/yinzhengjie/p/18591577,个人微信: "JasonYin2020"(添加时请备注来源及意图备注,有偿付费)
当你的才华还撑不起你的野心的时候,你就应该静下心来学习。当你的能力还驾驭不了你的目标的时候,你就应该沉下心来历练。问问自己,想要怎样的人生。