开源项目教程:DandyDeveloper/charts

开源项目教程:DandyDeveloper/charts

chartsVarious helm charts migrated from [helm/stable] due to deprecation项目地址:https://gitcode.com/gh_mirrors/charts17/charts

1. 项目的目录结构及介绍




charts/


├── Chart.yaml


├── charts/


├── templates/


│   ├── NOTES.txt


│   ├── _helpers.tpl


│   ├── deployment.yaml


│   ├── ingress.yaml


│   ├── service.yaml


│   └── tests/


│       └── test-connection.yaml


└── values.yaml

Chart.yaml: 包含Chart的基本信息,如名称、版本等。charts/: 存放依赖的子Chart。templates/: 存放模板文件,这些文件在部署时会被渲染成Kubernetes资源文件。
NOTES.txt: 部署后显示的帮助信息。_helpers.tpl: 模板助手,用于定义通用的模板片段。deployment.yaml: 定义Kubernetes Deployment资源。ingress.yaml: 定义Kubernetes Ingress资源。service.yaml: 定义Kubernetes Service资源。tests/: 存放测试文件。
test-connection.yaml: 用于测试连接的资源文件。 values.yaml: 包含Chart的默认配置值。

2. 项目的启动文件介绍

templates/目录下,deployment.yaml是项目的启动文件。它定义了如何部署应用程序到Kubernetes集群中。以下是deployment.yaml的关键部分:




apiVersion: apps/v1


kind: Deployment


metadata:


  name: {{ template "fullname" . }}


  labels:


    app: {{ template "fullname" . }}


spec:


  replicas: {{ .Values.replicaCount }}


  selector:


    matchLabels:


      app: {{ template "fullname" . }}


  template:


    metadata:


      labels:


        app: {{ template "fullname" . }}


    spec:


      containers:


        - name: {{ .Chart.Name }}


          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"


          imagePullPolicy: {{ .Values.image.pullPolicy }}


          ports:


            - containerPort: {{ .Values.service.internalPort }}

apiVersion: 指定API版本。kind: 指定资源类型为Deployment。metadata: 定义Deployment的名称和标签。spec: 定义Deployment的详细配置,包括副本数量、选择器和模板。template: 定义Pod的模板,包括容器名称、镜像、拉取策略和端口。

3. 项目的配置文件介绍

values.yaml是项目的配置文件,它包含了Chart的默认配置值。以下是values.yaml的关键部分:




replicaCount: 1


 


image:


  repository: nginx


  tag: stable


  pullPolicy: IfNotPresent


 


service:


  type: ClusterIP


  port: 80


  internalPort: 80


 


ingress:


  enabled: false


  annotations: {}


  hosts:


    - host: chart-example.local


      paths: []


 


resources: {}

replicaCount: 定义Pod的副本数量。image: 定义镜像的仓库、标签和拉取策略。service: 定义服务的类型、端口和内部端口。ingress: 定义Ingress的启用状态、注解和主机配置。resources: 定义容器的资源限制和请求。

通过修改values.yaml文件,可以自定义部署的配置,以满足不同的需求。

chartsVarious helm charts migrated from [helm/stable] due to deprecation项目地址:https://gitcode.com/gh_mirrors/charts17/charts

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...