使用 Helm Chart 部署分布式 GreptimeDB
# 在values.yaml文件中设置默认值
replicaCount: 3
image:
repository: timescale/greptime-kubernetes
tag: 0.7.0-beta.1
pullPolicy: IfNotPresent
service:
type: ClusterIP
port: 5432
pod:
resources:
limits:
cpu: 1000m
memory: 2Gi
requests:
cpu: 100m
memory: 200Mi
nodeSelector: {}
tolerations: []
affinity: {}
# 在Helm模板文件中使用这些值
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Values.nameOverride }}-greptime-deployment
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: {{ .Values.nameOverride }}-greptime-app
template:
metadata:
labels:
app: {{ .Values.nameOverride }}-greptime-app
spec:
containers:
- name: {{ .Values.nameOverride }}-greptime-container
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- containerPort: 5432
resources:
{{ toYaml .Values.pod.resources | indent 12 }}
env:
- name: POSTGRES_DB
value: greptime
- name: POSTGRES_USER
value: greptime
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Values.nameOverride }}-greptime-secret
key: password
affinity:
{{ toYaml .Values.pod.affinity | indent 8 }}
tolerations:
{{ toYaml .Values.pod.tolerations | indent 8 }}
nodeSelector:
{{ toYaml .Values.pod.nodeSelector | indent 8 }}
---
apiVersion: v1
kind: Service
metadata:
name: {{ .Values.nameOverride }}-greptime-service
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 5432
selector:
app: {{ .Values.nameOverride }}-greptime-app
这个代码实例展示了如何在Helm模板中使用values.yaml
文件中定义的变量来设置一个分布式GreptimeDB的部署和服务。这里使用了toYaml
和indent
函数来正确地插入嵌套的YAML结构。这样的实践可以使模板更加清晰和可维护。
评论已关闭