kustomize 模版自由的配置&&自定义kubernetes工具

kustomize 是一个可以方便我们基于模版配置,自定义kubernetes 的工具,类似kompose,但是个人觉得kompose
更灵活点,而且使用上更方便

安装

mac

brew install kustomize

基本使用

  • 创建kustomization.yaml 文件(类似docker-compose)
touch kustomization.yaml
内容如下:
   commonLabels:
     app: hello
   resources:
   - deployment.yaml
   - configMap.yaml
   - service.yaml

如下:

  • resource 定义
deploy:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: appdmeo
spec:
  selector:
    matchLabels:
      app: appdmeo
  template:
    metadata:
      labels:
        app: appdmeo
    spec:
      containers:
      - name: appdmeo
        image: nginx
        ports:
        - containerPort: 80
service:
kind: Service
apiVersion: v1
metadata:
  name: appdemo
spec:
  selector:
    app: appdmeo
  type: NodePort
  ports:
  - name: http
    port: 80
    targetPort: 80

configmap:
apiVersion: v1
kind: ConfigMap
metadata:
  name: myconfigmap
  labels:
    app: myapplication
data:
  username: dalongdemo
  • 构建
kustomize build

生成的内容

apiVersion: v1
data:
  username: dalongdemo
kind: ConfigMap
metadata:
  labels:
    app: hello
  name: myconfigmap
---
apiVersion: v1
kind: Service
metadata:
  labels:
    app: hello
  name: appdemo
spec:
  ports:
  - name: http
    port: 80
    targetPort: 80
  selector:
    app: hello
  type: NodePort
---
apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: hello
  name: appdmeo
spec:
  selector:
    matchLabels:
      app: hello
  template:
    metadata:
      labels:
        app: hello
    spec:
      containers:
      - image: nginx
        name: appdmeo
        ports:
        - containerPort: 80
  • 支持的命令

参考资料

https://kubernetes.io/blog/2018/05/29/introducing-kustomize-template-free-configuration-customization-for-kubernetes/
https://kustomize.io/
https://github.com/kubernetes-sigs/kustomize
https://www.jianshu.com/p/65490ab651e1?utm_campaign=hugo

posted on   荣锋亮  阅读(1051)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2017-11-27 cargo rust 包管理工具
2017-11-27 container-diff 谷歌开源镜像分析工具使用
2016-11-27 Disque
2015-11-27 node js 常用模块

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示