Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

uniquejava/play-kustomize

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

2 Commits

Repository files navigation

001 - 演示 base 和 overlays

kustomize configMapGenerator与k create cm 对照表

  1. kubectl 命令
kubectl create configmap my-app-config \
 --from-file=app.conf \  # 普通文件,整个内容作为一个值
 --from-env-file=db.env \  # 环境文件,解析为多个键值对
 --from-literal=ENV=production \ # 直接定义键值对
 --dry-run=client -o yaml
  1. kustomization.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configMapGenerator:
- name: my-app-config
 # 对应 kubectl 的 --from-file
 files:
 - app.conf
 
 # 对应 kubectl 的 --from-env-file
 envs:
 - db.env
 
 # 对应 kubectl 的 --from-literal 
 literals:
 - ENV=production
  1. 生成的 ConfigMap
apiVersion: v1
kind: ConfigMap
metadata:
 name: my-app-config
data:
 # 来自 --from-file=app.conf(整个文件内容,键名为文件名)
 app.conf: |
 # 这是一个应用配置文件
 server.host=0.0.0.0
 server.port=8080
 log.level=INFO

 # 来自 --from-env-file=db.env(解析为独立的键值对)
 DB_HOST: mysql-primary
 DB_PORT: "3306"
 DATABASE: myapp
 
 # 来自 --from-literal
 ENV: production
  1. Comparison
方面 kubectl create configmap Kustomize configMapGenerator
名称 my-app-config my-app-config-8mt5fb7g9k(带哈希)
env 文件处理 --from-env-file=db.env envs: [db.env]
普通文件处理 --from-file=app.conf files: [app.conf]
直接键值对 --from-literal=ENV=production literals: [ENV=production]
管理方式 命令式(一次性) 声明式(可版本控制)
更新机制 手动重新执行命令 自动检测变化,生成新哈希

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /