Skip to content

Commit f83577b

Browse files
committed
[helm] feat: add hello helm code for dev namespace.
1 parent 4dfa13b commit f83577b

2 files changed

Lines changed: 44 additions & 0 deletions

File tree

README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,44 @@ curl http://192.168.59.100/hello
18531853
# [v6] Hello, Helm! Message from helm values: It works with Helm Values!, From namespace: default, From host: hellok8s-deployment-57d7df7964-482xw, Get Database Connect URL: http://DB_ADDRESS_DEFAULT, Database Connect Password: db_password
18541854
```
18551855

1856+
#### 多环境配置
1857+
1858+
使用 Helm 也很容易多环境部署,新建 `values-dev.yaml` 文件,里面内容自定义 `dev` 环境需要的配置信息。
1859+
1860+
```yaml
1861+
application:
1862+
hellok8s:
1863+
message: "It works with Helm Values values-dev.yaml!"
1864+
database:
1865+
url: "http://DB_ADDRESS_DEV"
1866+
password: "db_password_dev"
1867+
```
1868+
1869+
可以多次指定'--values -f'参数,最后(最右边)指定的文件优先级最高,这里最右边的是 `values-dev.yaml` 文件,所以 `values-dev.yaml` 文件中的值会覆盖 `values.yaml` 中相同的值,`-n dev` 表示在名字为 dev 的 namespace 中创建 k8s 资源,执行完成后,我们可以通过 `curl` 命令看到返回的字符串中读取的是 `values-dev.yaml` 文件的配置,并且 `From namespace = dev`。
1870+
1871+
```shell
1872+
helm upgrade --install hello-helm -f values.yaml -f values-dev.yaml -n dev .
1873+
1874+
# Release "hello-helm" does not exist. Installing it now.
1875+
# NAME: hello-helm
1876+
# NAMESPACE: dev
1877+
# STATUS: deployed
1878+
# REVISION: 1
1879+
1880+
curl http://192.168.59.100/hello
1881+
# [v6] Hello, Helm! Message from helm values: It works with Helm Values values-dev.yaml!, From namespace: dev, From host: hellok8s-deployment-f5fff9df-89sn6, Get Database Connect URL: http://DB_ADDRESS_DEV, Database Connect Password: db_password_dev
1882+
1883+
kubectl get pods -n dev
1884+
# NAME READY STATUS RESTARTS AGE
1885+
# hellok8s-deployment-f5fff9df-89sn6 1/1 Running 0 4m23s
1886+
# hellok8s-deployment-f5fff9df-tkh6g 1/1 Running 0 4m23s
1887+
# hellok8s-deployment-f5fff9df-wmlpb 1/1 Running 0 4m23s
1888+
# nginx-deployment-d47fd7f66-cdlmf 1/1 Running 0 4m23s
1889+
# nginx-deployment-d47fd7f66-cgst2 1/1 Running 0 4m23s
1890+
```
1891+
1892+
上面的例子说明我们可以一行命令在一个新的 namespace 环境中安装所有需要的 k8s 资源!这也同样说明我们教程需要的所有 k8s 资源,可以快速的进行打包、分发和下载!
1893+
18561894
### helm chart 打包和发布
18571895

18581896
//TODO

hello-helm/values-dev.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
application:
2+
hellok8s:
3+
message: "It works with Helm Values values-dev.yaml!"
4+
database:
5+
url: "http://DB_ADDRESS_DEV"
6+
password: "db_password_dev"

0 commit comments

Comments
 (0)