网站首页 > 博客文章 正文
目录结构如下:
.
├── argo-cd-app
│ └── argo-cd-app.yaml
├── base
│ ├── backend
│ │ ├── kustomization.yaml
│ │ ├── patch_common_env.yaml
│ │ └── patch-remove-service.yaml
│ ├── common
│ │ ├── configmap.yaml
│ │ ├── deployment-template.yaml
│ │ ├── envname.properties
│ │ ├── imagetag.properties
│ │ ├── ingress-template.yaml
│ │ ├── kustomization.yaml
│ │ ├── replicas.properties
│ │ ├── rollout-bluegreen-template.yaml
│ │ ├── rollout-canary-template.yaml
│ │ ├── servicename.properties
│ │ └── service-template.yaml
│ └── frontend
│ ├── kustomization.yaml
│ └── patch_common_env.yaml
├── generate_yaml.py
├── kustomization_template.j2
└── overlays
├── dev
│ ├── backend
│ │ ├── backend-service
│ │ │ └── kustomization.yaml
│ │ ├── cesp-oauth-iam-steve
│ │ │ └── kustomization.yaml
│ │ ├── kustomization.yaml
│ │ └── rollouts
│ ├── frontend
│ │ ├── kustomization.yaml
│ │ └── rollouts
│ │ └── kustomization.yaml
│ └── kustomization.yaml
├── prod
│ ├── backend
│ ├── frontend
│ └── kustomization.yaml
└── test
├── backend
├── frontend
├── kustomization.yaml
└── rollouts
上面主要的目录注释如下:
- 修改 base/ 中的通用配置
- 在 overlays/ 特定环境中调整差异化配置
- 使用 generate_yaml.py 生成最终kustomize 对应服务名称的配置
- 通过 Argo CD 同步应用到集群
常见操作如下:
1.配置基本的资源应用使用resources案例如下:
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- deployment-template.yaml
- ingress-template.yaml
- rollout-bluegreen-template.yaml
- service-template.yaml
- rollout-canary-template.yaml
2.使用configMapGenerator 生成对应的configmap
通过configmap传入对应的参数 如版本号服务名称等
configMapGenerator:
- files:
- SERVICE_NAME=../common/servicename.properties
- IMAGE_TAG=../common/imagetag.properties
- ENV_NAME=../common/envname.properties
- REPLICAS=../common/replicas.properties
name: common-config
使用replaments进行替换
replacements:
- source:
fieldPath: data.SERVICE_NAME
kind: ConfigMap
name: common-config
targets:
- fieldPaths:
- spec.rules.0.host
- spec.rules.0.http.paths.0.backend.serviceName
- metadata.name
select:
kind: Ingress
- fieldPaths:
- spec.selector.matchLabels.efssc-service
- spec.template.metadata.labels.efssc-service
select:
kind: Deployment
3.使用一些简单的标签添加修改以及名称添加
generatorOptions:
disableNameSuffixHash: true #禁止使用随机码名称
namePrefix: backend- 名称添加前缀
nameSuffix: -wade #名称添加后缀
#使用patches修改对应资源的数值
patches:
- path: patch_common_env.yaml
target:
kind: Deployment
- patch: |-
- op: replace
path: /spec/template/spec/containers/0/image
value: harbor.assistfc.com/middleware/prod-backend:v1.0.0
- op: replace
path: /metadata/name
value: prod-backend-service
target:
kind: Deployment
- path: patch-remove-service.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: test-service
spec:
template:
spec:
containers:
- name: test-service
env:
- name: FOSUN_API_URL
value: "https://api.fosun.com"
- name: FOSUN_API_KEY
value: "your-api-key"
- name: FOSUN_API_SECRET
value: "your-api-secret"
相关命令的用法
kustomize build --load_restrictor=none . 这里跳过扩目录的安全监测进行执行即可更详细的使用见官网(
https://kubectl.docs.kubernetes.io/guides/config_management/apply/)
猜你喜欢
- 2025-05-25 SpringBoot注解终极宝典,这80+注解让你的开发效率飙升!
- 2025-05-25 用配置作为代码设置 Jenkins 实例(使用 Yaml 配置)
- 2025-05-25 Spring Cloud Alibaba Nacos Config 是如何读取配置的?
- 2025-05-25 Nacos 统一配置中心动态刷新机制真香
- 2025-05-25 Nacos:简单易用的配置管理和服务发现注册中心
你 发表评论:
欢迎- 380℃手把手教程「JavaWeb」优雅的SpringMvc+Mybatis整合之路
- 375℃用AI Agent治理微服务的复杂性问题|QCon
- 374℃IT全明星|IntelliJ IDEA学习笔记(四、idea中怎么创建maven项目)
- 366℃初次使用IntelliJ IDEA新建Maven项目
- 359℃Maven技术方案最全手册(mavena)
- 356℃安利Touch Bar 专属应用,让闲置的Touch Bar活跃起来!
- 354℃InfoQ 2024 年趋势报告:架构篇(infoq+2024+年趋势报告:架构篇分析)
- 353℃IntelliJ IDEA 2018版本和2022版本创建 Maven 项目对比
- 最近发表
- 标签列表
-
- powershellfor (55)
- messagesource (56)
- aspose.pdf破解版 (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- vue数组concat (56)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)