如何将 k8s yaml 转换为 helm 图表 [英] How to convert k8s yaml to helm chart

查看:22
本文介绍了如何将 k8s yaml 转换为 helm 图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我正在使用 yaml 文件在 k8s 上部署应用程序.

Right now I'm deploying applications on k8s using yaml files.

如下图:

apiVersion: v1
kind: Service
metadata:
  name: serviceA
  namespace: flow
spec:
  ports:
  - port: 8080
    targetPort: 8080
  selector:
    app: serviceA
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: serviceA-ingress
  namespace: flow
  annotations:
    nginx.ingress.kubernetes.io/use-regex: "true"
    kubernetes.io/ingress.class: nginx
    certmanager.k8s.io/cluster-issuer: letsencrypt-prod
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  tls:
  - hosts:
    - serviceA.xyz.com
    secretName: letsencrypt-prod
  rules:
  - host: serviceA.xyz.com
    http:
      paths:
      - path: /
        backend:
          serviceName: serviceA
          servicePort: 8080
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: serviceA-config
  namespace: flow
data:
  application-dev.properties: |
    spring.application.name=serviceA-main
    server.port=8080
    logging.level.org.springframework.jdbc.core=debug
    lead.pg.url=serviceB.flow.svc:8080/lead
    task.pg.url=serviceB.flow.svc:8080/task
---
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: serviceA-deployment
  namespace: flow
spec:
  selector:
    matchLabels:
      app: serviceA
  replicas: 1 # tells deployment to run 2 pods matching the template
  template:
    metadata:
      labels:
        app: serviceA
    spec:
      containers:
      - name: serviceA
        image: xyzaccount.dkr.ecr.eu-west-1.amazonaws.com/flow/test:serviceA-v1
        command: [ "java", "-jar", "-agentlib:jdwp=transport=dt_socket,address=9098,server=y,suspend=n", "serviceA-service.jar", "--spring.config.additional-location=/config/application-dev.properties" ]
        ports:
        - containerPort: 8080
        volumeMounts:
        - name: serviceA-application-config
          mountPath: "/config"
          readOnly: true
      volumes:
      - name: serviceA-application-config
        configMap:
          name: serviceA-config
          items:
          - key: application-dev.properties
            path: application-dev.properties
      restartPolicy: Always

有没有什么自动化的方法可以把这个 yaml 转换成 helm charts.

Is there any automated way to convert this yaml into helm charts.

或者我可以用来实现此目的的任何其他解决方法或示例模板.

Or any other workaround or sample template that I can use to achieve this.

就算没有通用的方法,那我也想知道怎么把这个具体的yaml转成helm chart.

Even if there is no any generic way, then I would like to know how to convert this specific yaml into helm chart.

还想知道我应该保持可配置的所有内容(我的意思是转换为变量),因为我不能将 yaml 中的这些资源放入单独的模板文件夹中,并将其称为 helm chart.

Also want to know what all things should I keep configurable (I mean convert into variables) as I can't just put these resource in yaml into separate template folder and called it helm chart.

推荐答案

Helm 图表本质上仍然只是 YAML,因此要制作图表,只需将该文件放在 templates/下并添加 Chart.yml.

At heart a Helm chart is still just YAML so to make that a chart, just drop that file under templates/ and add a Chart.yml.

这篇关于如何将 k8s yaml 转换为 helm 图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆