# Helm同时部署多个域名

**啥也不说，直接上代码**

```bash
helm create nginx-dev
```

```bash
[root@kp nginx-dev]# tree    (删除了没用的 test 文件夹)
.
├── charts
├── Chart.yaml
├── templates
│   ├── deployment.yaml
│   ├── _helpers.tpl
│   ├── hpa.yaml
│   ├── ingress.yaml
│   ├── NOTES.txt
│   ├── serviceaccount.yaml
│   └── service.yaml
└── values.yaml
```

```bash
[root@kp nginx-dev]# cat Chart.yaml       
# 添加了 icon, 规范参考：https://v3-0.docs.kubesphere.io/zh/docs/application-store/app-developer-guide/helm-specification/
apiVersion: v2
name: nginx-dev
description: A Helm chart for Kubernetes
icon: https://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/Nginx_logo.svg/500px-Nginx_logo.svg.png
type: application
version: 0.1.0
appVersion: 1.16.0
```

```bash
[root@kp nginx-dev]#  cat values.yaml 
''' 其他无修改，开启了ingress，并添加了一些内容 '''
ingress:
  enabled: true
  annotations:
    # kubernetes.io/tls-acme: "true"
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/rewrite-target: "http://www.baidu.com"
    nginx.ingress.kubernetes.io/limit-rps: "100"
    nginx.ingress.kubernetes.io/limit-rpm: "1000"
    nginx.ingress.kubernetes.io/limit-connections: "200"
  paths:
    - /
  hosts:
    - host: chart-example1.local
    - host: chart-example2.local
    - host: chart-example3.local
    - host: chart-example4.local
'''
```

```bash
[root@kp nginx-dev]# cat templates/ingress.yaml                # 修改两个地方
''' 略
{{- $ingressPaths := .Values.ingress.paths -}}   # 这里定义了一个变量
''' 略
          {{- range $ingressPaths }}             # 继承上面变量
          - path: {{ . }}
            backend:
              serviceName: {{ $fullName }}
              servicePort: {{ $svcPort }}
          {{- end }}
''' 略
```

```bash
helm package nginx-dev/              # 会生成一个压缩包
```

```bash
上传到你的 helm-charts 仓库，我这里使用的 github (略)；如果是github，需要生成参考url: 
# helm repo index --url https://helmchars.github.io/helm-charts/ .      下面会多一个 index.yaml 文件
```

```bash
[root@kp ~]# helm repo list
Error: no repositories to show

[root@kp ~]# helm repo add myrepo https://helmchars.github.io/helm-charts
"myrepo" has been added to your repositories

[root@kp ~]# helm repo list
NAME    URL                                    
myrepo  https://helmchars.github.io/helm-charts

[root@kp ~]# helm search repo nginx
NAME                    CHART VERSION   APP VERSION     DESCRIPTION                
myrepo/nginx-dev        0.1.0           1.16.0          A Helm chart for Kubernetes
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://close.gitbook.io/yun-wei-bi-ji/kubernetes/helm/helm-tong-shi-bu-shu-duo-ge-yu-ming.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
