$ kubectl create configmap game-config-3 \ --from-file=/runfile/configmap/game.properties \ #文件1 --from-file=/runfile/configmap/ui.properties #文件2 1. 2. 3. 4. 6、创建ConfigMap - 从 literal 之前的方式都需要新建配置文件,然后从文件创建ConfigMap。kubernetes还提供使用实际配置值创建的方式,通...
= 1\n"kind:ConfigMapmetadata:annotations:kubectl.kubernetes.io/last-applied-configuration:|{"apiVersion":"v1","data":{"my.cnf":"[mysqld]\nserver-id=1\ncharacter-set-server=utf8mb4 \nlower_case_table_names = 1\n"},"kind":"ConfigMap","metadata":{"annotations":{},"name":"mysql-co...
kubectl get cm my-config -o go-template='{{printf"apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: %s\nnamespace: %s\ndata:\n".metadata.name .metadata.namespace}}{{range$key, $value:= .data}}{{printf" %s: |-\n %s\n"$key $value}}{{end}}' > mysql-config.yaml 这段命令...
kubectl get cm my-config-ogo-template='{{printf "apiVersion: v1\nkind: ConfigMap\nmetadata:\n name: %s\nnamespace: %s\ndata:\n" .metadata.name .metadata.namespace}}{{range $key, $value := .data}}{{printf " %s: |-\n %s\n" $key $value}}{{end}}'>mysql-config.yaml 这段...
kubectl create -f xxx.yaml 2.1.2、适合没有部署快速生成 yaml 资源编排文件 kubectl create <resource_type> <Pod_name> --image=<image_name> -o yaml --dry-run > <fileName>.yaml 2.1.3、创建ConfigMap kubectl create configmap <cm_name> --from-file=<fileName>.properties ...
kubectl create configmap xxx --from-literal=t1=123 --from-literal=t2=qwe kubectl get cm #创建secret,保存mysql的密码 ubectl create secret generic mysql-root-pw --from-literal=passwd=123456 #直接生成yaml的配置清单文件,不用写了 kubectl create ns xxx --dry-run -o yaml ...
首先,创建一个 ConfigMap: 代码语言:txt 复制 kubectl create configmap my-config --from-literal=VAR_NAME=value 然后在部署时引用这个 ConfigMap: 代码语言:txt 复制 apiVersion: apps/v1 kind: Deployment metadata: name: my-deployment spec: replicas: 1 selector: matchLabels: app: my-app template: me...
kubectl create configmap --from-file 命令允许用户从本地文件系统上的文件或目录创建 Kubernetes ConfigMap。ConfigMap 是一种 Kubernetes 资源,用于将配置数据以键值对的形式存储,以便在 Pod 中使用。 如何使用 --from-file 选项: 指定文件:使用 --from-file=[fileName] 形式,可以将单个文件的内容创建为一个 Con...
create Create a resourcefroma file orfromstdin. expose Take a replication controller, service, deployment or pod and expose itasanewKubernetes Service run Run a particular image on the clustersetSet specific features on objects Basic Commands (Intermediate): ...
ConfigMap 使用ConfigMap 可以将配置工件与映像内容分离,以保持容器化应用程序的可移植性。 此YAML 示例通过指向 ConfigMap 文件来创建 ConfigMap: YAML - task:Kubernetes@1displayName:kubectlapplyinputs:configMapName:myconfiguseConfigMapFile:trueconfigMapFile:src/configmap ...