69、K8S-Helm-template导出独立的yaml文件

1、将helm项目导出为独立yaml文件-实践

1.1、需求

有时候,我们需要导出yaml分析yaml编写情况,而不是直接部署到k8s,这个时候,就需要使用template来实现了

1.2、开始操作

1.2.1、创建存放yaml文件的目录

helm_prometheus]# cd /opt/helm_prometheus/ && mkdir prometheus-tpl
helm_prometheus]# ll

drwxr-xr-x 5 root root 202 Apr 16 00:04 prometheus # 这个是项目目录
drwxr-xr-x 2 root root   6 Apr 16 00:24 prometheus-tpl # 这个是渲染出来的,存放yaml的目录

1.2.2、开始渲染

# 注意:一定要在项目目录的上一级目录执行。
helm_prometheus]# helm template prometheus --output-dir prometheus-tpl/ wrote prometheus-tpl//prometheus/charts/alertmanager/templates/serviceaccount.yaml wrote prometheus-tpl//prometheus/charts/kube-state-metrics/templates/serviceaccount.yaml wrote prometheus-tpl//prometheus/charts/prometheus-node-exporter/templates/serviceaccount.yaml wrote prometheus-tpl//prometheus/charts/prometheus-pushgateway/templates/serviceaccount.yaml wrote prometheus-tpl//prometheus/templates/serviceaccount.yaml wrote prometheus-tpl//prometheus/charts/alertmanager/templates/configmap.yaml wrote prometheus-tpl//prometheus/templates/cm.yaml wrote prometheus-tpl//prometheus/templates/pvc.yaml wrote prometheus-tpl//prometheus/charts/kube-state-metrics/templates/role.yaml wrote prometheus-tpl//prometheus/templates/clusterrole.yaml wrote prometheus-tpl//prometheus/charts/kube-state-metrics/templates/clusterrolebinding.yaml wrote prometheus-tpl//prometheus/templates/clusterrolebinding.yaml wrote prometheus-tpl//prometheus/charts/alertmanager/templates/services.yaml wrote prometheus-tpl//prometheus/charts/alertmanager/templates/services.yaml wrote prometheus-tpl//prometheus/charts/kube-state-metrics/templates/service.yaml wrote prometheus-tpl//prometheus/charts/prometheus-node-exporter/templates/service.yaml wrote prometheus-tpl//prometheus/charts/prometheus-pushgateway/templates/service.yaml wrote prometheus-tpl//prometheus/templates/service.yaml wrote prometheus-tpl//prometheus/charts/prometheus-node-exporter/templates/daemonset.yaml wrote prometheus-tpl//prometheus/charts/kube-state-metrics/templates/deployment.yaml wrote prometheus-tpl//prometheus/charts/prometheus-pushgateway/templates/deployment.yaml wrote prometheus-tpl//prometheus/templates/deploy.yaml wrote prometheus-tpl//prometheus/charts/alertmanager/templates/statefulset.yaml wrote prometheus-tpl//prometheus/charts/alertmanager/templates/ingress.yaml wrote prometheus-tpl//prometheus/templates/ingress.yaml wrote prometheus-tpl//prometheus/charts/alertmanager/templates/tests/test-connection.yaml

1.2.3、查询渲染后的目录

helm_prometheus]# tree prometheus-tpl/
prometheus-tpl/
└── prometheus
    ├── charts
    │   ├── alertmanager
    │   │   └── templates
    │   │       ├── configmap.yaml
    │   │       ├── ingress.yaml
    │   │       ├── serviceaccount.yaml
    │   │       ├── services.yaml
    │   │       ├── statefulset.yaml
    │   │       └── tests
    │   │           └── test-connection.yaml
    │   ├── kube-state-metrics
    │   │   └── templates
    │   │       ├── clusterrolebinding.yaml
    │   │       ├── deployment.yaml
    │   │       ├── role.yaml
    │   │       ├── serviceaccount.yaml
    │   │       └── service.yaml
    │   ├── prometheus-node-exporter
    │   │   └── templates
    │   │       ├── daemonset.yaml
    │   │       ├── serviceaccount.yaml
    │   │       └── service.yaml
    │   └── prometheus-pushgateway
    │       └── templates
    │           ├── deployment.yaml
    │           ├── serviceaccount.yaml
    │           └── service.yaml
    └── templates
        ├── clusterrolebinding.yaml
        ├── clusterrole.yaml
        ├── cm.yaml
        ├── deploy.yaml
        ├── ingress.yaml
        ├── pvc.yaml
        ├── serviceaccount.yaml
        └── service.yaml

12 directories, 25 files

 

posted @ 2023-04-18 19:42  小粉优化大师  阅读(1799)  评论(0编辑  收藏  举报