码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2018-11-27 12:22:26      阅读:752      评论:0      收藏:0      [点我收藏+]

标签:div   style   技术   code   touch   参考   data-   block   pps   

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

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

标签:div   style   技术   code   touch   参考   data-   block   pps   

原文地址:https://www.cnblogs.com/rongfengliang/p/10025375.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!