现在,我正在使用yaml文件在k8上部署应用程序。
就像下面的一个:
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
。
或者我可以用来实现此目的的任何其他解决方法或示例模板。
即使没有通用方法,我也想知道如何将这种特定的Yaml转换为舵图。
也想知道我应该保持所有可配置的内容(我的意思是转换为变量),因为我不能只是将这些资源放在yaml中放在单独的模板文件夹中并称为头盔图。
答案 0 :(得分:3)
从本质上讲,Helm图表仍然只是YAML,因此要制作该图表,只需将该文件拖放到template /下并添加Chart.yml。
答案 1 :(得分:0)
https://github.com/mailchannels/palinurus/tree/master
此git repo包含一个python脚本,该脚本会将基本yamls转换为头盔图表
答案 2 :(得分:0)
你可以使用这个工具, helmtrans : https://github.com/codeandcode0x/helmtrans 。它可以将 YAML 转换为 Helm Charts 自动化。
示例:
➜ helmtrans yamltohelm -p [源路径] -o [输出路径]