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
- 支持的命令