Compare commits
214 Commits
main
...
codex/temp
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02ca9ea187 | ||
|
|
dba6f60e7a | ||
|
|
e1e98890c2 | ||
|
|
e8db48027b | ||
|
|
ea4aa2ea16 | ||
|
|
f5e5ae0b22 | ||
|
|
d30962b90a | ||
|
|
31f0954489 | ||
|
|
c213455f96 | ||
|
|
d11df4cd85 | ||
|
|
51cff23e25 | ||
|
|
83546a20de | ||
|
|
bd64a9f97e | ||
|
|
b0f6ebd3f3 | ||
|
|
8237383d58 | ||
|
|
98e6ed6ed5 | ||
|
|
3f2f359d73 | ||
|
|
7e9836f795 | ||
|
|
eee662d328 | ||
|
|
8bb069f7b8 | ||
|
|
26dcd76def | ||
|
|
3944061589 | ||
|
|
06a3492a48 | ||
|
|
462ec9592a | ||
|
|
68a8eaf1ad | ||
|
|
9320acf1a0 | ||
|
|
ff109b3085 | ||
|
|
497b7c9de0 | ||
|
|
b66477abd9 | ||
|
|
112e152469 | ||
|
|
38969a99db | ||
|
|
374acc6776 | ||
|
|
c873404bcb | ||
|
|
3f5a2a3bd0 | ||
|
|
9075932399 | ||
|
|
ca6372e629 | ||
|
|
89cd9466fc | ||
|
|
174d35affc | ||
|
|
3090e1eb09 | ||
|
|
988bd7a2b4 | ||
|
|
1561fc145c | ||
|
|
7e2e929f60 | ||
|
|
e8fd85b0d4 | ||
|
|
e7c2ef8753 | ||
|
|
b7e53d6ca9 | ||
|
|
8890ba5d7a | ||
|
|
1955d8fd6f | ||
|
|
0d802ed7df | ||
|
|
ffe0c4fdf1 | ||
|
|
ddf3e6d48a | ||
|
|
c861a3cf38 | ||
|
|
21628e6ac9 | ||
|
|
a954e5c3fd | ||
|
|
2be64e2491 | ||
|
|
034c34fc7a | ||
|
|
6a31c18f8d | ||
|
|
b5dee68f23 | ||
|
|
7f1e3515e1 | ||
|
|
d6e486ad2a | ||
|
|
79cb568a4a | ||
|
|
454df79578 | ||
|
|
c8ededf913 | ||
|
|
a02d2c8196 | ||
|
|
3f6faff10f | ||
|
|
544fe48f08 | ||
|
|
c1ec57d1fa | ||
|
|
738b24bfd0 | ||
|
|
0f0dab6c3b | ||
|
|
23c5111e0c | ||
|
|
071474dac2 | ||
|
|
d27c73f272 | ||
|
|
d6899eb705 | ||
|
|
a71a871819 | ||
|
|
3e20c1c6ec | ||
|
|
4ddb034534 | ||
|
|
ee125ea42f | ||
|
|
3b87370c77 | ||
|
|
0e1c9c8924 | ||
|
|
8241a40012 | ||
|
|
1d4d4ab30b | ||
|
|
8fd5bc6000 | ||
|
|
6753b50473 | ||
|
|
985596f1ea | ||
|
|
1fa683a18a | ||
|
|
beb0bdf337 | ||
|
|
c9b7badd76 | ||
|
|
31adf195b1 | ||
|
|
998effa5a8 | ||
|
|
88955b78a3 | ||
|
|
0abb0a961f | ||
|
|
c91cb3bb10 | ||
|
|
8513984e49 | ||
|
|
844113d13e | ||
|
|
ae7a07d3d2 | ||
|
|
9790a666da | ||
|
|
d6ffad1445 | ||
|
|
3cd9f58488 | ||
|
|
9c3defed67 | ||
|
|
c080e71ac0 | ||
|
|
7b0bea90e1 | ||
|
|
5357f854f2 | ||
|
|
91f1231c50 | ||
|
|
0c89b74b73 | ||
|
|
af93640e0f | ||
|
|
359bc52ef2 | ||
|
|
453fd924e7 | ||
|
|
2bbd367683 | ||
|
|
959579d9c0 | ||
|
|
57be1121ea | ||
|
|
c724071a65 | ||
|
|
adddc2c186 | ||
|
|
12547b608c | ||
|
|
e810c963f4 | ||
|
|
09e5059a63 | ||
|
|
f4e0e4fae2 | ||
|
|
abea8f0727 | ||
|
|
62c5a47591 | ||
|
|
2bf9df3274 | ||
|
|
c5eaac2ce6 | ||
|
|
995725c793 | ||
|
|
098f2700fd | ||
|
|
5e6a352286 | ||
|
|
caf844c486 | ||
|
|
bee672a91a | ||
|
|
b19d9f950b | ||
|
|
fbf87ef5b7 | ||
|
|
3cca3f04d1 | ||
|
|
75ec257ff4 | ||
|
|
f643a0bf4a | ||
|
|
a0f553d89d | ||
|
|
b28e1e5ae8 | ||
|
|
856997c8eb | ||
|
|
e0b68c24d0 | ||
|
|
2d296c95ac | ||
|
|
64eb61e38d | ||
|
|
6f65af587c | ||
|
|
7164b20736 | ||
|
|
b296acd33a | ||
|
|
85be7e78e9 | ||
|
|
e6c8bec317 | ||
|
|
8a6387c5de | ||
|
|
a9c239abab | ||
|
|
99e5ae2362 | ||
|
|
0b80aaba78 | ||
|
|
5f6e9013af | ||
|
|
b17bd5444d | ||
|
|
eb8fb9d0c1 | ||
|
|
ab92eeb02e | ||
|
|
d7fef1c0b4 | ||
|
|
8475e122d3 | ||
|
|
60edf7f299 | ||
|
|
42ff88bf0b | ||
|
|
e9a0ea65e3 | ||
|
|
6f39beb92d | ||
|
|
dfa1b5ac83 | ||
|
|
b6cce0564b | ||
|
|
60936c9d9a | ||
|
|
f266c24650 | ||
|
|
3acff6ec48 | ||
|
|
66d5f2cb49 | ||
|
|
06a15aa335 | ||
|
|
af7df3579c | ||
|
|
4de072761a | ||
|
|
46ea2bd5db | ||
|
|
6a934742d9 | ||
|
|
98e6ffc5b0 | ||
|
|
61ff5be4e2 | ||
|
|
6025c5c2f5 | ||
|
|
d4e7b13d92 | ||
|
|
19d9b03c97 | ||
|
|
7031d05283 | ||
|
|
0feb0400b1 | ||
|
|
48096a61b5 | ||
|
|
aba13c8b19 | ||
|
|
ce59e49ebe | ||
|
|
28085fb339 | ||
|
|
019257c8f9 | ||
|
|
548ba2d2a3 | ||
|
|
cda17a27fe | ||
|
|
eba486bb47 | ||
|
|
cc636da9cf | ||
|
|
cf313e5ab7 | ||
|
|
13e671acb6 | ||
|
|
dd0c466d84 | ||
|
|
97e2baf938 | ||
|
|
b0a1702d90 | ||
|
|
8000138bb2 | ||
|
|
9bf08bed2f | ||
|
|
aaf874d02e | ||
|
|
b07bf14a06 | ||
|
|
3e49e1681a | ||
|
|
d234075d16 | ||
|
|
5a6769a8b6 | ||
|
|
21f7a978e9 | ||
|
|
2fb43276b2 | ||
|
|
a7beef416b | ||
|
|
d326affafa | ||
|
|
076836d018 | ||
|
|
1e2f655b2c | ||
|
|
edcdd42b1c | ||
|
|
2e4a369a06 | ||
|
|
c571355cbd | ||
|
|
0b1e7edae5 | ||
|
|
c85639f50d | ||
|
|
33610d93db | ||
|
|
9ed1c4aeff | ||
|
|
234b9d3473 | ||
|
|
597f91207b | ||
|
|
15f1127e81 | ||
|
|
789959b6ae | ||
|
|
89075de759 | ||
|
|
add4a007b2 | ||
|
|
86afbd03f8 | ||
|
|
b606decbbd |
21
.github/branch-protection-rules.json
vendored
Normal file
21
.github/branch-protection-rules.json
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"required_status_checks": {
|
||||||
|
"strict": true,
|
||||||
|
"checks": [
|
||||||
|
{ "context": "Lint / go-vet" },
|
||||||
|
{ "context": "Lint / actionlint" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"enforce_admins": true,
|
||||||
|
"required_pull_request_reviews": {
|
||||||
|
"dismiss_stale_reviews": true,
|
||||||
|
"require_code_owner_reviews": false,
|
||||||
|
"required_approving_review_count": 1
|
||||||
|
},
|
||||||
|
"restrictions": null,
|
||||||
|
"required_linear_history": false,
|
||||||
|
"allow_force_pushes": false,
|
||||||
|
"allow_deletions": false,
|
||||||
|
"block_creations": false,
|
||||||
|
"required_conversation_resolution": true
|
||||||
|
}
|
||||||
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# 忽略所有 .DS_Store 文件
|
||||||
|
*.DS_Store
|
||||||
|
|
||||||
|
# 忽略 playbooks/deepflow 目录下的 tar.gz 文件
|
||||||
|
playbooks/deepflow/*.zip
|
||||||
|
playbooks/deepflow/*.tar.gz
|
||||||
|
playbooks/deepflow/deepflow-agent-playbook/*.zip
|
||||||
|
|
||||||
|
remotes.before.txt
|
||||||
101
README.md
101
README.md
@ -1 +1,100 @@
|
|||||||
# gitops
|
# ansible-playbook
|
||||||
|
|
||||||
|
This repository contains a collection of Ansible playbooks and roles for various infrastructure setups and service management tasks.
|
||||||
|
|
||||||
|
For a quick overview of the directory layout see [docs/repo-structure.md](docs/repo-structure.md).
|
||||||
|
Additional documentation is stored under the `docs/` folder.
|
||||||
|
|
||||||
|
## Playbook 角色说明
|
||||||
|
|
||||||
|
1. playbooks/roles/docker:适用于简单的、单机环境的部署,主要使用 Docker 和 Docker Compose 进行容器化管理。
|
||||||
|
2. playbooks/roles/charts:面向大规模的 Kubernetes 集群,使用 Helm 和标准化 Chart 部署模式进行高可用和可扩展的管理。
|
||||||
|
3. playbooks/roles/vhosts:传统的非容器化部署方式,通常涉及手动配置服务器和虚拟主机,适用于不使用容器的应用场景。
|
||||||
|
|
||||||
|
|
||||||
|
## Role Summary
|
||||||
|
|
||||||
|
| Role Name | Description | Docker | Charts | VHosts | CICD | Validate | Last Update |
|
||||||
|
|-------------------------|-------------------------------------------------------|--------|--------|--------|--------|--------|------------|
|
||||||
|
| `common` | 通用角色,包含一些常用的功能,如日志记录、监控等。 | | | ✔ | | yes | 2025-02-14 |
|
||||||
|
| `keycloak` | 用于管理身份认证和授权服务。 | ✔ | | | github | yes | 2024-11-10 |
|
||||||
|
| `harbor` | 容器镜像仓库角色,用于存储和管理容器镜像。 | ✔ | | | github | yes | 2024-11-14 |
|
||||||
|
| `app` | 参考模板。 | | | | | | |
|
||||||
|
| `nginx` | 用于设置 Nginx | | ✔ | ✔ | | | |
|
||||||
|
| `grafana` | 用于设置 Grafana | | ✔ | ✔ | | | |
|
||||||
|
| `grafana-loki` | 用于设置 Grafana-loki | | ✔ | ✔ | | | |
|
||||||
|
| `Grafana-tempo` | 用于设置 Grafana-tempo | | ✔ | ✔ | | | |
|
||||||
|
| `prometheus` | 用于设置 Prometheus | | ✔ | ✔ | | | |
|
||||||
|
| `prometheus-transfer` | 用于 Prometheus 数据传输设置。 | | | ✔ | | | |
|
||||||
|
| `vector` | 用于配置日志收集代理。 | | | ✔ | | | |
|
||||||
|
| `node-exporter` | 用于导出系统和硬件的监控数据。 | | ✔ | | | | |
|
||||||
|
| `observability-agent` | 用于管理 Observability 代理。 | | ✔ | ✔ | | | |
|
||||||
|
| `observability-server` | 用于设置 Observability 服务端。 | | ✔ | ✔ | | | |
|
||||||
|
| `wireguard-client` | 用于设置 WireGuard 客户端。 | | | ✔ | | | |
|
||||||
|
| `wireguard-gateway` | 用于设置 WireGuard 网关。 | | | ✔ | | | |
|
||||||
|
| `vault` | 用于管理敏感数据和密钥。 | | | ✔ | | | |
|
||||||
|
| `postgresql` | PostgreSQL 数据库角色,用于提供 PostgreSQL 数据库服务。 | | ✔ | | | | |
|
||||||
|
| `redis` | Redis 数据库角色,用于提供 Redis 数据库服务。 | | ✔ | | | | |
|
||||||
|
| `chartmuseum` | 图表仓库角色,用于存储和管理 Kubernetes 图表。 | | ✔ | | | | |
|
||||||
|
| `gitlab` | 代码仓库角色,用于存储和管理代码。 | | ✔ | | | | |
|
||||||
|
| `mysql` | MySQL 数据库角色,用于提供 MySQL 数据库服务。 | | ✔ | | | | |
|
||||||
|
| `argo-server` | 用于设置和管理 Argo Server。 | | ✔ | | | | |
|
||||||
|
| `deepflow` | 用于流量监控与网络性能分析的 DeepFlow 服务。 | | ✔ | | | | |
|
||||||
|
| `jenkins` | Jenkins 自动化构建工具角色,用于 CI/CD 管道。 | | ✔ | | | | |
|
||||||
|
| `chaos-mesh` | 用于 Chaos Engineering 测试的 Chaos Mesh 角色。 | | ✔ | | | | |
|
||||||
|
| `flagger-loadtester` | 用于负载测试的 Flagger Loadtester 角色。 | | ✔ | | | | |
|
||||||
|
| `splunk-otel-collector` | 用于配置 Splunk OpenTelemetry Collector。 | | ✔ | | | | |
|
||||||
|
| `openldap` | 用于设置和管理 OpenLDAP 身份认证服务。 | | ✔ | | | | |
|
||||||
|
| `alerting` | 用于设置和管理警报系统。 | | | ✔ | | | |
|
||||||
|
| `k3s` | 用于创建 Kubernetes 集群。 | | | ✔ | | | |
|
||||||
|
| `k3s-reset` | 用于重置 Kubernetes 集群。 | | | ✔ | | | |
|
||||||
|
| `k3s-addon` | 用于安装 Kubernetes 集群插件。 | | | ✔ | | | |
|
||||||
|
| `secret-manger` | 密钥管理角色,用于管理密钥。 | | | ✔ | | | |
|
||||||
|
| `cert-manager` | 证书管理角色,用于管理证书。 | | | ✔ | | | |
|
||||||
|
| `ssh-trust` | 配置 ops 主机与节点的 SSH 互信。 | | | ✔ | | | |
|
||||||
|
|
||||||
|
表格说明
|
||||||
|
- Docker:是否属于 Docker 角色。
|
||||||
|
- Charts:是否属于 Helm Chart 角色。
|
||||||
|
- VHosts:是否属于虚拟主机管理相关角色。
|
||||||
|
- CICD:是否启用 CICD 管道,标明是否集成了自动化流程。
|
||||||
|
- Validate:是否经过验证测试。
|
||||||
|
- Last Update:最后更新时间。
|
||||||
|
|
||||||
|
## Usage Examples
|
||||||
|
|
||||||
|
- Linux OS Setup
|
||||||
|
|
||||||
|
ansible-playbook -i inventory/hosts/all playbooks/common -D -C
|
||||||
|
ansible-playbook -i inventory/hosts/all playbooks/common -D
|
||||||
|
|
||||||
|
- Gather Network Information
|
||||||
|
|
||||||
|
ansible-playbook -i inventory gather_network_info.yml -e target_group=master
|
||||||
|
|
||||||
|
- Display network information on all nodes
|
||||||
|
|
||||||
|
ansible -i inventory all -m script -a 'roles/network_info/tasks/files/display_network_info.sh'
|
||||||
|
|
||||||
|
- Deploy Keycloak Server
|
||||||
|
|
||||||
|
ansible-playbook -i inventory/hosts/core playbooks/keycloak_server -D
|
||||||
|
|
||||||
|
- Set up WireGuard Gateway
|
||||||
|
|
||||||
|
ansible-playbook -i inventory/hosts/vpn playbooks/wireguard_gateway.yaml -D
|
||||||
|
|
||||||
|
- Set up Grafana Alloy
|
||||||
|
|
||||||
|
ansible-playbook -i inventory/k3s-cluster playbooks/init_grafana_alloy -D -C -l cn-k3s-server.svc.plus -e @playbooks/roles/alloy/files/loki_journal_sources_k3s_server.yml -e "ansible_become_pass='xxxx'"
|
||||||
|
|
||||||
|
|
||||||
|
- Setup VPN gateway
|
||||||
|
|
||||||
|
ansible-playbook -i inventory/hosts/all playbooks/common -l gateway -D
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
|
||||||
|
- [docs/gpu-k8s-role.md](docs/gpu-k8s-role.md) - How to run the GPU-enabled Kubernetes role.
|
||||||
|
- [docs/repo-structure.md](docs/repo-structure.md) - Overview of repository layout.
|
||||||
|
|
||||||
|
|||||||
26
ansible.cfg
Normal file
26
ansible.cfg
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
[defaults]
|
||||||
|
# 常用参数
|
||||||
|
inventory = ./inventory # 默认清单文件路径,可按需改
|
||||||
|
vault_password_file = ~/.vault_password
|
||||||
|
timeout = 10
|
||||||
|
forks = 10
|
||||||
|
poll_interval = 10
|
||||||
|
transport = smart
|
||||||
|
gathering = smart
|
||||||
|
|
||||||
|
# 输出配置:推荐 yaml,兼容性最好
|
||||||
|
stdout_callback = yaml
|
||||||
|
bin_ansible_callbacks = True
|
||||||
|
callbacks_enabled = profile_tasks,timer
|
||||||
|
|
||||||
|
# Python 解释器
|
||||||
|
ansible_python_interpreter = /usr/bin/python3
|
||||||
|
|
||||||
|
# 其他常用设置
|
||||||
|
host_key_checking = False
|
||||||
|
deprecation_warnings = False
|
||||||
|
|
||||||
|
[inventory]
|
||||||
|
cache = True
|
||||||
|
cache_plugin = jsonfile
|
||||||
|
cache_timeout = 3600
|
||||||
5
apps/itsm-dev/kustomization.yaml
Normal file
5
apps/itsm-dev/kustomization.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namespace: itsm-dev
|
||||||
|
resources:
|
||||||
|
- release.yaml
|
||||||
40
apps/itsm-dev/release.yaml
Normal file
40
apps/itsm-dev/release.yaml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: itsm-dev
|
||||||
|
namespace: itsm-dev
|
||||||
|
spec:
|
||||||
|
interval: 1m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
version: "0.1.16"
|
||||||
|
chart: itsm
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: stable
|
||||||
|
namespace: itsm-dev
|
||||||
|
interval: 1m
|
||||||
|
values:
|
||||||
|
novu:
|
||||||
|
web:
|
||||||
|
ingress:
|
||||||
|
enabled: true
|
||||||
|
hostname: novu-web.onwalk.net
|
||||||
|
ingressClassName: 'nginx'
|
||||||
|
apisix:
|
||||||
|
dashboard:
|
||||||
|
ingress:
|
||||||
|
enabled: true
|
||||||
|
className: "nginx"
|
||||||
|
hosts:
|
||||||
|
- host: apisix-dashboard.onwalk.net
|
||||||
|
paths:
|
||||||
|
- /*
|
||||||
|
etcd-adapter:
|
||||||
|
enabled: true
|
||||||
|
mysql:
|
||||||
|
host: mysql
|
||||||
|
port: 3306
|
||||||
|
username: apisix
|
||||||
|
password: apisix
|
||||||
|
database: apisix
|
||||||
5
apps/minio/kustomization.yaml
Normal file
5
apps/minio/kustomization.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namespace: itsm-dev
|
||||||
|
resources:
|
||||||
|
- release.yaml
|
||||||
37
apps/minio/release.yaml
Normal file
37
apps/minio/release.yaml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: minio
|
||||||
|
namespace: itsm-dev
|
||||||
|
spec:
|
||||||
|
interval: 1m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
version: "5.0.15"
|
||||||
|
chart: minio
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: stable
|
||||||
|
namespace: itsm-dev
|
||||||
|
interval: 1m
|
||||||
|
values:
|
||||||
|
enabled: true
|
||||||
|
nameOverride: minio
|
||||||
|
mode: standalone
|
||||||
|
replicas: 2
|
||||||
|
ingress:
|
||||||
|
enabled: true
|
||||||
|
ingressClassName: "nginx"
|
||||||
|
hosts:
|
||||||
|
- minio.local
|
||||||
|
persistence:
|
||||||
|
enabled: true
|
||||||
|
size: 10Gi
|
||||||
|
existingSecret: minio-secret
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: 50Mi
|
||||||
|
cpu: 50m
|
||||||
|
limits:
|
||||||
|
cpu: "100m"
|
||||||
|
memory: "100Mi"
|
||||||
5
apps/mongodb/kustomization.yaml
Normal file
5
apps/mongodb/kustomization.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namespace: itsm-dev
|
||||||
|
resources:
|
||||||
|
- release.yaml
|
||||||
42
apps/mongodb/release.yaml
Normal file
42
apps/mongodb/release.yaml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: mongodb
|
||||||
|
namespace: itsm-dev
|
||||||
|
spec:
|
||||||
|
interval: 1m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
version: "14.8.3"
|
||||||
|
chart: mongodb
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: stable
|
||||||
|
namespace: itsm-dev
|
||||||
|
interval: 1m
|
||||||
|
values:
|
||||||
|
enabled: true
|
||||||
|
nameOverride: "mongodb"
|
||||||
|
architecture: standalone
|
||||||
|
useStatefulSet: true
|
||||||
|
global:
|
||||||
|
imageRegistry: ""
|
||||||
|
persistence:
|
||||||
|
enabled: true
|
||||||
|
auth:
|
||||||
|
enabled: true
|
||||||
|
rootUser: root
|
||||||
|
rootPassword: "mongodb"
|
||||||
|
usernames:
|
||||||
|
- novu
|
||||||
|
passwords:
|
||||||
|
- novu
|
||||||
|
databases:
|
||||||
|
- novu-db
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: 100Mi
|
||||||
|
cpu: 100m
|
||||||
|
limits:
|
||||||
|
cpu: "500m"
|
||||||
|
memory: "500Mi"
|
||||||
5
apps/mysql/kustomization.yaml
Normal file
5
apps/mysql/kustomization.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namespace: itsm-dev
|
||||||
|
resources:
|
||||||
|
- release.yaml
|
||||||
37
apps/mysql/release.yaml
Normal file
37
apps/mysql/release.yaml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: mysql
|
||||||
|
namespace: itsm-dev
|
||||||
|
spec:
|
||||||
|
interval: 1m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
version: "9.21.2"
|
||||||
|
chart: mysql
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: stable
|
||||||
|
namespace: itsm-dev
|
||||||
|
interval: 1m
|
||||||
|
values:
|
||||||
|
global:
|
||||||
|
imageRegistry: "artifact.onwalk.net/public"
|
||||||
|
architecture: standalone
|
||||||
|
auth:
|
||||||
|
createDatabase: true
|
||||||
|
database: "apisix"
|
||||||
|
username: "apisix"
|
||||||
|
password: "apisix"
|
||||||
|
existingSecret: ""
|
||||||
|
primary:
|
||||||
|
persistence:
|
||||||
|
enabled: true
|
||||||
|
size: 8Gi
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
cpu: 250m
|
||||||
|
memory: 400Mi
|
||||||
|
limits:
|
||||||
|
cpu: 500m
|
||||||
|
memory: 800Mi
|
||||||
5
apps/postgresql/kustomization.yaml
Normal file
5
apps/postgresql/kustomization.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namespace: itsm-dev
|
||||||
|
resources:
|
||||||
|
- release.yaml
|
||||||
37
apps/postgresql/release.yaml
Normal file
37
apps/postgresql/release.yaml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: postgresql
|
||||||
|
namespace: itsm-dev
|
||||||
|
spec:
|
||||||
|
interval: 1m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
version: "12.3.1"
|
||||||
|
chart: postgresql
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: stable
|
||||||
|
namespace: itsm-dev
|
||||||
|
interval: 1m
|
||||||
|
values:
|
||||||
|
enabled: true
|
||||||
|
fullnameOverride: windmill-postgresql
|
||||||
|
global:
|
||||||
|
imageRegistry: ""
|
||||||
|
postgresql:
|
||||||
|
auth:
|
||||||
|
postgresPassword: "windmill"
|
||||||
|
username: "postgres"
|
||||||
|
password: "windmill"
|
||||||
|
database: "windmill"
|
||||||
|
primary:
|
||||||
|
persistence:
|
||||||
|
enabled: true
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: 100Mi
|
||||||
|
cpu: 100m
|
||||||
|
limits:
|
||||||
|
cpu: "200m"
|
||||||
|
memory: "300Mi"
|
||||||
5
apps/redis/kustomization.yaml
Normal file
5
apps/redis/kustomization.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
namespace: itsm-dev
|
||||||
|
resources:
|
||||||
|
- release.yaml
|
||||||
38
apps/redis/release.yaml
Normal file
38
apps/redis/release.yaml
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
apiVersion: helm.toolkit.fluxcd.io/v2beta2
|
||||||
|
kind: HelmRelease
|
||||||
|
metadata:
|
||||||
|
name: redis
|
||||||
|
namespace: itsm-dev
|
||||||
|
spec:
|
||||||
|
interval: 1m
|
||||||
|
chart:
|
||||||
|
spec:
|
||||||
|
version: "18.12.1"
|
||||||
|
chart: redis
|
||||||
|
sourceRef:
|
||||||
|
kind: HelmRepository
|
||||||
|
name: stable
|
||||||
|
namespace: itsm-dev
|
||||||
|
interval: 1m
|
||||||
|
values:
|
||||||
|
enabled: true
|
||||||
|
nameOverride: "redis"
|
||||||
|
architecture: standalone
|
||||||
|
global:
|
||||||
|
imageRegistry: ""
|
||||||
|
redis:
|
||||||
|
password: "redis"
|
||||||
|
auth:
|
||||||
|
enabled: true
|
||||||
|
sentinel: false
|
||||||
|
password: ""
|
||||||
|
master:
|
||||||
|
persistence:
|
||||||
|
enabled: false
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: 100Mi
|
||||||
|
cpu: 100m
|
||||||
|
limits:
|
||||||
|
cpu: "200m"
|
||||||
|
memory: "300Mi"
|
||||||
@ -5,8 +5,8 @@ resources:
|
|||||||
- ../../apps/monitor/observability-agent/
|
- ../../apps/monitor/observability-agent/
|
||||||
- ../../apps/monitor/kube-prometheus-stack/
|
- ../../apps/monitor/kube-prometheus-stack/
|
||||||
- ../../apps/monitor/flagger/
|
- ../../apps/monitor/flagger/
|
||||||
- ../../apps/c-demo/
|
- ../../apps/demo/c-app
|
||||||
- ../../apps/js-demo/
|
- ../../apps/demo/js-app
|
||||||
- ../../apps/python-demo/
|
- ../../apps/demo/python-app
|
||||||
- ../../apps/go-demo/
|
- ../../apps/demo/go-app
|
||||||
- ../../apps/rust-demo/
|
- ../../apps/demo/rust-app
|
||||||
|
|||||||
11
clusters/k3s-local/kustomization.yaml
Normal file
11
clusters/k3s-local/kustomization.yaml
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
resources:
|
||||||
|
- namespace.yaml
|
||||||
|
- repository.yaml
|
||||||
|
- ../../apps/itsm-dev/
|
||||||
|
- ../../apps/redis/
|
||||||
|
- ../../apps/mysql/
|
||||||
|
- ../../apps/postgresql/
|
||||||
|
- ../../apps/mongodb/
|
||||||
|
- ../../apps/minio/
|
||||||
4
clusters/k3s-local/namespace.yaml
Normal file
4
clusters/k3s-local/namespace.yaml
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
apiVersion: v1
|
||||||
|
kind: Namespace
|
||||||
|
metadata:
|
||||||
|
name: itsm-dev
|
||||||
8
clusters/k3s-local/repository.yaml
Normal file
8
clusters/k3s-local/repository.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
apiVersion: source.toolkit.fluxcd.io/v1beta2
|
||||||
|
kind: HelmRepository
|
||||||
|
metadata:
|
||||||
|
name: stable
|
||||||
|
namespace: itsm-dev
|
||||||
|
spec:
|
||||||
|
interval: 1m0s
|
||||||
|
url: https://charts.onwalk.net
|
||||||
@ -5,8 +5,8 @@ resources:
|
|||||||
- ../../apps/monitor/observability-agent/
|
- ../../apps/monitor/observability-agent/
|
||||||
- ../../apps/monitor/kube-prometheus-stack/
|
- ../../apps/monitor/kube-prometheus-stack/
|
||||||
- ../../apps/monitor/flagger/
|
- ../../apps/monitor/flagger/
|
||||||
- ../../apps/c-demo/
|
- ../../apps/demo/c-app
|
||||||
- ../../apps/js-demo/
|
- ../../apps/demo/js-app
|
||||||
- ../../apps/python-demo/
|
- ../../apps/demo/python-app
|
||||||
- ../../apps/go-demo/
|
- ../../apps/demo/go-app
|
||||||
- ../../apps/rust-demo/
|
- ../../apps/demo/rust-app
|
||||||
|
|||||||
@ -5,8 +5,8 @@ resources:
|
|||||||
- ../../apps/monitor/observability-agent/
|
- ../../apps/monitor/observability-agent/
|
||||||
- ../../apps/monitor/kube-prometheus-stack/
|
- ../../apps/monitor/kube-prometheus-stack/
|
||||||
- ../../apps/monitor/flagger/
|
- ../../apps/monitor/flagger/
|
||||||
- ../../apps/c-demo/
|
- ../../apps/demo/c-app
|
||||||
- ../../apps/js-demo/
|
- ../../apps/demo/js-app
|
||||||
- ../../apps/python-demo/
|
- ../../apps/demo/python-app
|
||||||
- ../../apps/go-demo/
|
- ../../apps/demo/go-app
|
||||||
- ../../apps/rust-demo/
|
- ../../apps/demo/rust-app
|
||||||
|
|||||||
@ -5,8 +5,8 @@ resources:
|
|||||||
- ../../apps/monitor/observability-agent/
|
- ../../apps/monitor/observability-agent/
|
||||||
- ../../apps/monitor/kube-prometheus-stack/
|
- ../../apps/monitor/kube-prometheus-stack/
|
||||||
- ../../apps/monitor/flagger/
|
- ../../apps/monitor/flagger/
|
||||||
- ../../apps/c-demo/
|
- ../../apps/demo/c-app
|
||||||
- ../../apps/js-demo/
|
- ../../apps/demo/js-app
|
||||||
- ../../apps/python-demo/
|
- ../../apps/demo/python-app
|
||||||
- ../../apps/go-demo/
|
- ../../apps/demo/go-app
|
||||||
- ../../apps/rust-demo/
|
- ../../apps/demo/rust-app
|
||||||
|
|||||||
113
docs/gpu-k8s-role.md
Normal file
113
docs/gpu-k8s-role.md
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
# GPU Kubernetes Role
|
||||||
|
|
||||||
|
This document describes how to use the `gpu-k8s` role to deploy a simple Kubernetes cluster with NVIDIA GPU support.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
The role performs four main tasks:
|
||||||
|
|
||||||
|
1. **Create the Kubernetes cluster** using [sealos](https://github.com/labring/sealos). It runs the provided `sealos run` command to bootstrap the master and worker nodes.
|
||||||
|
2. **Install NVIDIA drivers and the NVIDIA container toolkit** on the target hosts so that Kubernetes can access GPU resources.
|
||||||
|
3. **Verify the cluster state** after initialization, displaying the `sealos` version and the current Kubernetes nodes.
|
||||||
|
4. **Verify GPU access** by deploying the official NVIDIA device plugin and running a small CUDA workload.
|
||||||
|
|
||||||
|
When `sealos_version` is set to `latest` (the default), the role automatically
|
||||||
|
fetches the most recent stable release from GitHub. The Kubernetes image tag is
|
||||||
|
controlled separately via `kubernetes_version`, which defaults to `v1.25.16` but
|
||||||
|
can be overridden to any compatible release.
|
||||||
|
|
||||||
|
|
||||||
|
The following command is used to create the cluster (example with one master and one worker):
|
||||||
|
|
||||||
|
```bash
|
||||||
|
REGISTRY=$(playbooks/roles/vhosts/gpu-k8s/files/get_labring_registry.sh)
|
||||||
|
sealos run \
|
||||||
|
${REGISTRY}/kubernetes:<kubernetes_version> \
|
||||||
|
${REGISTRY}/cilium:<cilium_version> \
|
||||||
|
${REGISTRY}/helm:<helm_version> \
|
||||||
|
--masters 172.16.11.120 \
|
||||||
|
--nodes 172.16.11.152 \
|
||||||
|
--env '{}' \
|
||||||
|
--cmd "kubeadm init --skip-phases=addon/kube-proxy"
|
||||||
|
```
|
||||||
|
If deploying with a non-root user the command also requires `--user` and
|
||||||
|
`--pk` options pointing to the user's SSH key. The host running Sealos must have
|
||||||
|
`newuidmap` and `newgidmap` installed (typically provided by the `uidmap`
|
||||||
|
package) along with the `fuse-overlayfs` binary to enable user namespaces.
|
||||||
|
|
||||||
|
After the cluster is running the role installs the NVIDIA device plugin and runs a test pod to ensure `nvidia-smi` works inside the cluster.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
Add the role to your playbook along with the `ssh-trust` role which configures passwordless access from the ops host to the cluster nodes:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- hosts: all
|
||||||
|
roles:
|
||||||
|
- ssh-trust
|
||||||
|
- gpu-k8s
|
||||||
|
```
|
||||||
|
|
||||||
|
By default the SSH key is created for the same user Ansible connects with. You
|
||||||
|
can override this by setting `ssh_user`. When `ansible_user` is defined it will
|
||||||
|
be used automatically, otherwise `root` is assumed. The role also allows you to
|
||||||
|
specify the private key path via `ssh_private_key`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- hosts: all
|
||||||
|
vars:
|
||||||
|
ssh_user: ubuntu
|
||||||
|
ssh_private_key: /home/ubuntu/.ssh/myuser_id_rsa
|
||||||
|
roles:
|
||||||
|
- ssh-trust
|
||||||
|
- gpu-k8s
|
||||||
|
```
|
||||||
|
|
||||||
|
The specified user must be able to log in without a password and have sudo
|
||||||
|
access on the target hosts.
|
||||||
|
|
||||||
|
|
||||||
|
Example playbook snippet defining the IP lists:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- hosts: all
|
||||||
|
vars:
|
||||||
|
master_ips:
|
||||||
|
- "172.16.11.120"
|
||||||
|
node_ips:
|
||||||
|
- "172.16.11.152"
|
||||||
|
roles:
|
||||||
|
- ssh-trust
|
||||||
|
- gpu-k8s
|
||||||
|
```
|
||||||
|
|
||||||
|
You can also specify hostnames and let the role look up the IPs:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
- hosts: all
|
||||||
|
vars:
|
||||||
|
masters:
|
||||||
|
- "k8s-1"
|
||||||
|
nodes:
|
||||||
|
- "k8s-2"
|
||||||
|
- "k8s-3"
|
||||||
|
roles:
|
||||||
|
- ssh-trust
|
||||||
|
- gpu-k8s
|
||||||
|
```
|
||||||
|
|
||||||
|
The playbook expects at least one master and one node. You can provide the
|
||||||
|
addresses directly via `master_ips` and `node_ips`, or give hostnames in the
|
||||||
|
`masters` and `nodes` variables. When hostnames are used, the role will look up
|
||||||
|
their `ansible_host` values from the inventory to obtain the IPs. Up to three
|
||||||
|
masters can be specified.
|
||||||
|
|
||||||
|
|
||||||
|
Run the playbook with your inventory that contains the master and node IP addresses.
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible-playbook -i inventory/hosts/all playbooks/demo_gpu_k8s.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
The final step prints the output of `nvidia-smi` from inside a Kubernetes pod, confirming that the GPU is available.
|
||||||
19
docs/repo-structure.md
Normal file
19
docs/repo-structure.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Repository Structure
|
||||||
|
|
||||||
|
This repository combines Ansible playbooks with Kubernetes manifests and
|
||||||
|
automation scripts. Below is a short overview of the key directories.
|
||||||
|
|
||||||
|
| Directory | Purpose |
|
||||||
|
|-----------|---------|
|
||||||
|
| `playbooks` | Ansible playbooks and role definitions. |
|
||||||
|
| `apps` | Flux HelmRelease and Kustomize files for applications. |
|
||||||
|
| `clusters` | Kustomize overlays for different clusters referencing the `apps` definitions. |
|
||||||
|
| `helmfiles` | Sample [helmfile](https://github.com/helmfile/helmfile) declarations. |
|
||||||
|
| `helm` | Local Helm charts used in some playbooks. |
|
||||||
|
| `inventory` | Example inventories and group variables for Ansible. |
|
||||||
|
| `scripts` | Utility scripts such as cluster setup or secret management. |
|
||||||
|
| `sync` | Tasks for local host setup and testing. |
|
||||||
|
| `docs` | Additional documentation. |
|
||||||
|
|
||||||
|
See `docs/gpu-k8s-role.md` for an example walkthrough deploying a GPU-enabled
|
||||||
|
Kubernetes cluster.
|
||||||
23
helm/redis/.helmignore
Normal file
23
helm/redis/.helmignore
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# Patterns to ignore when building packages.
|
||||||
|
# This supports shell glob matching, relative path matching, and
|
||||||
|
# negation (prefixed with !). Only one pattern per line.
|
||||||
|
.DS_Store
|
||||||
|
# Common VCS dirs
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
.bzr/
|
||||||
|
.bzrignore
|
||||||
|
.hg/
|
||||||
|
.hgignore
|
||||||
|
.svn/
|
||||||
|
# Common backup files
|
||||||
|
*.swp
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
*~
|
||||||
|
# Various IDEs
|
||||||
|
.project
|
||||||
|
.idea/
|
||||||
|
*.tmproj
|
||||||
|
# img folder
|
||||||
|
img/
|
||||||
6
helm/redis/Chart.lock
Normal file
6
helm/redis/Chart.lock
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
dependencies:
|
||||||
|
- name: common
|
||||||
|
repository: oci://registry-1.docker.io/bitnamicharts
|
||||||
|
version: 2.14.1
|
||||||
|
digest: sha256:5ccbe5f1fe4459864a8c9d7329c400b678666b6cfb1450818a830bda81995bc3
|
||||||
|
generated: "2023-12-19T19:11:00.40217662Z"
|
||||||
36
helm/redis/Chart.yaml
Normal file
36
helm/redis/Chart.yaml
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
annotations:
|
||||||
|
category: Database
|
||||||
|
images: |
|
||||||
|
- name: os-shell
|
||||||
|
image: docker.io/bitnami/os-shell:11-debian-11-r96
|
||||||
|
- name: redis-exporter
|
||||||
|
image: docker.io/bitnami/redis-exporter:1.57.0-debian-11-r2
|
||||||
|
- name: redis-sentinel
|
||||||
|
image: docker.io/bitnami/redis-sentinel:7.2.4-debian-11-r6
|
||||||
|
- name: redis
|
||||||
|
image: docker.io/bitnami/redis:7.2.4-debian-11-r5
|
||||||
|
licenses: Apache-2.0
|
||||||
|
apiVersion: v2
|
||||||
|
appVersion: 7.2.4
|
||||||
|
dependencies:
|
||||||
|
- name: common
|
||||||
|
repository: oci://registry-1.docker.io/bitnamicharts
|
||||||
|
tags:
|
||||||
|
- bitnami-common
|
||||||
|
version: 2.x.x
|
||||||
|
description: Redis(R) is an open source, advanced key-value store. It is often referred
|
||||||
|
to as a data structure server since keys can contain strings, hashes, lists, sets
|
||||||
|
and sorted sets.
|
||||||
|
home: https://bitnami.com
|
||||||
|
icon: https://bitnami.com/assets/stacks/redis/img/redis-stack-220x234.png
|
||||||
|
keywords:
|
||||||
|
- redis
|
||||||
|
- keyvalue
|
||||||
|
- database
|
||||||
|
maintainers:
|
||||||
|
- name: VMware, Inc.
|
||||||
|
url: https://github.com/bitnami/charts
|
||||||
|
name: redis
|
||||||
|
sources:
|
||||||
|
- https://github.com/bitnami/charts/tree/main/bitnami/redis
|
||||||
|
version: 18.12.1
|
||||||
1226
helm/redis/README.md
Normal file
1226
helm/redis/README.md
Normal file
File diff suppressed because it is too large
Load Diff
22
helm/redis/charts/common/.helmignore
Normal file
22
helm/redis/charts/common/.helmignore
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
# Patterns to ignore when building packages.
|
||||||
|
# This supports shell glob matching, relative path matching, and
|
||||||
|
# negation (prefixed with !). Only one pattern per line.
|
||||||
|
.DS_Store
|
||||||
|
# Common VCS dirs
|
||||||
|
.git/
|
||||||
|
.gitignore
|
||||||
|
.bzr/
|
||||||
|
.bzrignore
|
||||||
|
.hg/
|
||||||
|
.hgignore
|
||||||
|
.svn/
|
||||||
|
# Common backup files
|
||||||
|
*.swp
|
||||||
|
*.bak
|
||||||
|
*.tmp
|
||||||
|
*~
|
||||||
|
# Various IDEs
|
||||||
|
.project
|
||||||
|
.idea/
|
||||||
|
*.tmproj
|
||||||
|
.vscode/
|
||||||
23
helm/redis/charts/common/Chart.yaml
Normal file
23
helm/redis/charts/common/Chart.yaml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
annotations:
|
||||||
|
category: Infrastructure
|
||||||
|
licenses: Apache-2.0
|
||||||
|
apiVersion: v2
|
||||||
|
appVersion: 2.14.1
|
||||||
|
description: A Library Helm Chart for grouping common logic between bitnami charts.
|
||||||
|
This chart is not deployable by itself.
|
||||||
|
home: https://bitnami.com
|
||||||
|
icon: https://bitnami.com/downloads/logos/bitnami-mark.png
|
||||||
|
keywords:
|
||||||
|
- common
|
||||||
|
- helper
|
||||||
|
- template
|
||||||
|
- function
|
||||||
|
- bitnami
|
||||||
|
maintainers:
|
||||||
|
- name: VMware, Inc.
|
||||||
|
url: https://github.com/bitnami/charts
|
||||||
|
name: common
|
||||||
|
sources:
|
||||||
|
- https://github.com/bitnami/charts
|
||||||
|
type: library
|
||||||
|
version: 2.14.1
|
||||||
235
helm/redis/charts/common/README.md
Normal file
235
helm/redis/charts/common/README.md
Normal file
@ -0,0 +1,235 @@
|
|||||||
|
# Bitnami Common Library Chart
|
||||||
|
|
||||||
|
A [Helm Library Chart](https://helm.sh/docs/topics/library_charts/#helm) for grouping common logic between Bitnami charts.
|
||||||
|
|
||||||
|
## TL;DR
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
dependencies:
|
||||||
|
- name: common
|
||||||
|
version: 2.x.x
|
||||||
|
repository: oci://registry-1.docker.io/bitnamicharts
|
||||||
|
```
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm dependency update
|
||||||
|
```
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ include "common.names.fullname" . }}
|
||||||
|
data:
|
||||||
|
myvalue: "Hello World"
|
||||||
|
```
|
||||||
|
|
||||||
|
Looking to use our applications in production? Try [VMware Tanzu Application Catalog](https://bitnami.com/enterprise), the enterprise edition of Bitnami Application Catalog.
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
This chart provides a common template helpers which can be used to develop new charts using [Helm](https://helm.sh) package manager.
|
||||||
|
|
||||||
|
Bitnami charts can be used with [Kubeapps](https://kubeapps.dev/) for deployment and management of Helm Charts in clusters.
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- Kubernetes 1.23+
|
||||||
|
- Helm 3.8.0+
|
||||||
|
|
||||||
|
## Parameters
|
||||||
|
|
||||||
|
## Special input schemas
|
||||||
|
|
||||||
|
### ImageRoot
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
registry:
|
||||||
|
type: string
|
||||||
|
description: Docker registry where the image is located
|
||||||
|
example: docker.io
|
||||||
|
|
||||||
|
repository:
|
||||||
|
type: string
|
||||||
|
description: Repository and image name
|
||||||
|
example: bitnami/nginx
|
||||||
|
|
||||||
|
tag:
|
||||||
|
type: string
|
||||||
|
description: image tag
|
||||||
|
example: 1.16.1-debian-10-r63
|
||||||
|
|
||||||
|
pullPolicy:
|
||||||
|
type: string
|
||||||
|
description: Specify a imagePullPolicy. Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
|
||||||
|
|
||||||
|
pullSecrets:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
description: Optionally specify an array of imagePullSecrets (evaluated as templates).
|
||||||
|
|
||||||
|
debug:
|
||||||
|
type: boolean
|
||||||
|
description: Set to true if you would like to see extra information on logs
|
||||||
|
example: false
|
||||||
|
|
||||||
|
## An instance would be:
|
||||||
|
# registry: docker.io
|
||||||
|
# repository: bitnami/nginx
|
||||||
|
# tag: 1.16.1-debian-10-r63
|
||||||
|
# pullPolicy: IfNotPresent
|
||||||
|
# debug: false
|
||||||
|
```
|
||||||
|
|
||||||
|
### Persistence
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
enabled:
|
||||||
|
type: boolean
|
||||||
|
description: Whether enable persistence.
|
||||||
|
example: true
|
||||||
|
|
||||||
|
storageClass:
|
||||||
|
type: string
|
||||||
|
description: Ghost data Persistent Volume Storage Class, If set to "-", storageClassName: "" which disables dynamic provisioning.
|
||||||
|
example: "-"
|
||||||
|
|
||||||
|
accessMode:
|
||||||
|
type: string
|
||||||
|
description: Access mode for the Persistent Volume Storage.
|
||||||
|
example: ReadWriteOnce
|
||||||
|
|
||||||
|
size:
|
||||||
|
type: string
|
||||||
|
description: Size the Persistent Volume Storage.
|
||||||
|
example: 8Gi
|
||||||
|
|
||||||
|
path:
|
||||||
|
type: string
|
||||||
|
description: Path to be persisted.
|
||||||
|
example: /bitnami
|
||||||
|
|
||||||
|
## An instance would be:
|
||||||
|
# enabled: true
|
||||||
|
# storageClass: "-"
|
||||||
|
# accessMode: ReadWriteOnce
|
||||||
|
# size: 8Gi
|
||||||
|
# path: /bitnami
|
||||||
|
```
|
||||||
|
|
||||||
|
### ExistingSecret
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
name:
|
||||||
|
type: string
|
||||||
|
description: Name of the existing secret.
|
||||||
|
example: mySecret
|
||||||
|
keyMapping:
|
||||||
|
description: Mapping between the expected key name and the name of the key in the existing secret.
|
||||||
|
type: object
|
||||||
|
|
||||||
|
## An instance would be:
|
||||||
|
# name: mySecret
|
||||||
|
# keyMapping:
|
||||||
|
# password: myPasswordKey
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Example of use
|
||||||
|
|
||||||
|
When we store sensitive data for a deployment in a secret, some times we want to give to users the possibility of using theirs existing secrets.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# templates/secret.yaml
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: {{ include "common.names.fullname" . }}
|
||||||
|
labels:
|
||||||
|
app: {{ include "common.names.fullname" . }}
|
||||||
|
type: Opaque
|
||||||
|
data:
|
||||||
|
password: {{ .Values.password | b64enc | quote }}
|
||||||
|
|
||||||
|
# templates/dpl.yaml
|
||||||
|
---
|
||||||
|
...
|
||||||
|
env:
|
||||||
|
- name: PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ include "common.secrets.name" (dict "existingSecret" .Values.existingSecret "context" $) }}
|
||||||
|
key: {{ include "common.secrets.key" (dict "existingSecret" .Values.existingSecret "key" "password") }}
|
||||||
|
...
|
||||||
|
|
||||||
|
# values.yaml
|
||||||
|
---
|
||||||
|
name: mySecret
|
||||||
|
keyMapping:
|
||||||
|
password: myPasswordKey
|
||||||
|
```
|
||||||
|
|
||||||
|
### ValidateValue
|
||||||
|
|
||||||
|
#### NOTES.txt
|
||||||
|
|
||||||
|
```console
|
||||||
|
{{- $validateValueConf00 := (dict "valueKey" "path.to.value00" "secret" "secretName" "field" "password-00") -}}
|
||||||
|
{{- $validateValueConf01 := (dict "valueKey" "path.to.value01" "secret" "secretName" "field" "password-01") -}}
|
||||||
|
|
||||||
|
{{ include "common.validations.values.multiple.empty" (dict "required" (list $validateValueConf00 $validateValueConf01) "context" $) }}
|
||||||
|
```
|
||||||
|
|
||||||
|
If we force those values to be empty we will see some alerts
|
||||||
|
|
||||||
|
```console
|
||||||
|
helm install test mychart --set path.to.value00="",path.to.value01=""
|
||||||
|
'path.to.value00' must not be empty, please add '--set path.to.value00=$PASSWORD_00' to the command. To get the current value:
|
||||||
|
|
||||||
|
export PASSWORD_00=$(kubectl get secret --namespace default secretName -o jsonpath="{.data.password-00}" | base64 -d)
|
||||||
|
|
||||||
|
'path.to.value01' must not be empty, please add '--set path.to.value01=$PASSWORD_01' to the command. To get the current value:
|
||||||
|
|
||||||
|
export PASSWORD_01=$(kubectl get secret --namespace default secretName -o jsonpath="{.data.password-01}" | base64 -d)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Upgrading
|
||||||
|
|
||||||
|
### To 1.0.0
|
||||||
|
|
||||||
|
[On November 13, 2020, Helm v2 support was formally finished](https://github.com/helm/charts#status-of-the-project), this major version is the result of the required changes applied to the Helm Chart to be able to incorporate the different features added in Helm v3 and to be consistent with the Helm project itself regarding the Helm v2 EOL.
|
||||||
|
|
||||||
|
#### What changes were introduced in this major version?
|
||||||
|
|
||||||
|
- Previous versions of this Helm Chart use `apiVersion: v1` (installable by both Helm 2 and 3), this Helm Chart was updated to `apiVersion: v2` (installable by Helm 3 only). [Here](https://helm.sh/docs/topics/charts/#the-apiversion-field) you can find more information about the `apiVersion` field.
|
||||||
|
- Use `type: library`. [Here](https://v3.helm.sh/docs/faq/#library-chart-support) you can find more information.
|
||||||
|
- The different fields present in the *Chart.yaml* file has been ordered alphabetically in a homogeneous way for all the Bitnami Helm Charts
|
||||||
|
|
||||||
|
#### Considerations when upgrading to this version
|
||||||
|
|
||||||
|
- If you want to upgrade to this version from a previous one installed with Helm v3, you shouldn't face any issues
|
||||||
|
- If you want to upgrade to this version using Helm v2, this scenario is not supported as this version doesn't support Helm v2 anymore
|
||||||
|
- If you installed the previous version with Helm v2 and wants to upgrade to this version with Helm v3, please refer to the [official Helm documentation](https://helm.sh/docs/topics/v2_v3_migration/#migration-use-cases) about migrating from Helm v2 to v3
|
||||||
|
|
||||||
|
#### Useful links
|
||||||
|
|
||||||
|
- <https://docs.bitnami.com/tutorials/resolve-helm2-helm3-post-migration-issues/>
|
||||||
|
- <https://helm.sh/docs/topics/v2_v3_migration/>
|
||||||
|
- <https://helm.sh/blog/migrate-from-helm-v2-to-helm-v3/>
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
Copyright © 2023 VMware, Inc.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
<http://www.apache.org/licenses/LICENSE-2.0>
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
139
helm/redis/charts/common/templates/_affinities.tpl
Normal file
139
helm/redis/charts/common/templates/_affinities.tpl
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return a soft nodeAffinity definition
|
||||||
|
{{ include "common.affinities.nodes.soft" (dict "key" "FOO" "values" (list "BAR" "BAZ")) -}}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.affinities.nodes.soft" -}}
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- preference:
|
||||||
|
matchExpressions:
|
||||||
|
- key: {{ .key }}
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
{{- range .values }}
|
||||||
|
- {{ . | quote }}
|
||||||
|
{{- end }}
|
||||||
|
weight: 1
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return a hard nodeAffinity definition
|
||||||
|
{{ include "common.affinities.nodes.hard" (dict "key" "FOO" "values" (list "BAR" "BAZ")) -}}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.affinities.nodes.hard" -}}
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
nodeSelectorTerms:
|
||||||
|
- matchExpressions:
|
||||||
|
- key: {{ .key }}
|
||||||
|
operator: In
|
||||||
|
values:
|
||||||
|
{{- range .values }}
|
||||||
|
- {{ . | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return a nodeAffinity definition
|
||||||
|
{{ include "common.affinities.nodes" (dict "type" "soft" "key" "FOO" "values" (list "BAR" "BAZ")) -}}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.affinities.nodes" -}}
|
||||||
|
{{- if eq .type "soft" }}
|
||||||
|
{{- include "common.affinities.nodes.soft" . -}}
|
||||||
|
{{- else if eq .type "hard" }}
|
||||||
|
{{- include "common.affinities.nodes.hard" . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return a topologyKey definition
|
||||||
|
{{ include "common.affinities.topologyKey" (dict "topologyKey" "BAR") -}}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.affinities.topologyKey" -}}
|
||||||
|
{{ .topologyKey | default "kubernetes.io/hostname" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return a soft podAffinity/podAntiAffinity definition
|
||||||
|
{{ include "common.affinities.pods.soft" (dict "component" "FOO" "customLabels" .Values.podLabels "extraMatchLabels" .Values.extraMatchLabels "topologyKey" "BAR" "extraPodAffinityTerms" .Values.extraPodAffinityTerms "context" $) -}}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.affinities.pods.soft" -}}
|
||||||
|
{{- $component := default "" .component -}}
|
||||||
|
{{- $customLabels := default (dict) .customLabels -}}
|
||||||
|
{{- $extraMatchLabels := default (dict) .extraMatchLabels -}}
|
||||||
|
{{- $extraPodAffinityTerms := default (list) .extraPodAffinityTerms -}}
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- podAffinityTerm:
|
||||||
|
labelSelector:
|
||||||
|
matchLabels: {{- (include "common.labels.matchLabels" ( dict "customLabels" $customLabels "context" .context )) | nindent 10 }}
|
||||||
|
{{- if not (empty $component) }}
|
||||||
|
{{ printf "app.kubernetes.io/component: %s" $component }}
|
||||||
|
{{- end }}
|
||||||
|
{{- range $key, $value := $extraMatchLabels }}
|
||||||
|
{{ $key }}: {{ $value | quote }}
|
||||||
|
{{- end }}
|
||||||
|
topologyKey: {{ include "common.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
|
||||||
|
weight: 1
|
||||||
|
{{- range $extraPodAffinityTerms }}
|
||||||
|
- podAffinityTerm:
|
||||||
|
labelSelector:
|
||||||
|
matchLabels: {{- (include "common.labels.matchLabels" ( dict "customLabels" $customLabels "context" $.context )) | nindent 10 }}
|
||||||
|
{{- if not (empty $component) }}
|
||||||
|
{{ printf "app.kubernetes.io/component: %s" $component }}
|
||||||
|
{{- end }}
|
||||||
|
{{- range $key, $value := .extraMatchLabels }}
|
||||||
|
{{ $key }}: {{ $value | quote }}
|
||||||
|
{{- end }}
|
||||||
|
topologyKey: {{ include "common.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
|
||||||
|
weight: {{ .weight | default 1 -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return a hard podAffinity/podAntiAffinity definition
|
||||||
|
{{ include "common.affinities.pods.hard" (dict "component" "FOO" "customLabels" .Values.podLabels "extraMatchLabels" .Values.extraMatchLabels "topologyKey" "BAR" "extraPodAffinityTerms" .Values.extraPodAffinityTerms "context" $) -}}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.affinities.pods.hard" -}}
|
||||||
|
{{- $component := default "" .component -}}
|
||||||
|
{{- $customLabels := default (dict) .customLabels -}}
|
||||||
|
{{- $extraMatchLabels := default (dict) .extraMatchLabels -}}
|
||||||
|
{{- $extraPodAffinityTerms := default (list) .extraPodAffinityTerms -}}
|
||||||
|
requiredDuringSchedulingIgnoredDuringExecution:
|
||||||
|
- labelSelector:
|
||||||
|
matchLabels: {{- (include "common.labels.matchLabels" ( dict "customLabels" $customLabels "context" .context )) | nindent 8 }}
|
||||||
|
{{- if not (empty $component) }}
|
||||||
|
{{ printf "app.kubernetes.io/component: %s" $component }}
|
||||||
|
{{- end }}
|
||||||
|
{{- range $key, $value := $extraMatchLabels }}
|
||||||
|
{{ $key }}: {{ $value | quote }}
|
||||||
|
{{- end }}
|
||||||
|
topologyKey: {{ include "common.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
|
||||||
|
{{- range $extraPodAffinityTerms }}
|
||||||
|
- labelSelector:
|
||||||
|
matchLabels: {{- (include "common.labels.matchLabels" ( dict "customLabels" $customLabels "context" $.context )) | nindent 8 }}
|
||||||
|
{{- if not (empty $component) }}
|
||||||
|
{{ printf "app.kubernetes.io/component: %s" $component }}
|
||||||
|
{{- end }}
|
||||||
|
{{- range $key, $value := .extraMatchLabels }}
|
||||||
|
{{ $key }}: {{ $value | quote }}
|
||||||
|
{{- end }}
|
||||||
|
topologyKey: {{ include "common.affinities.topologyKey" (dict "topologyKey" .topologyKey) }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return a podAffinity/podAntiAffinity definition
|
||||||
|
{{ include "common.affinities.pods" (dict "type" "soft" "key" "FOO" "values" (list "BAR" "BAZ")) -}}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.affinities.pods" -}}
|
||||||
|
{{- if eq .type "soft" }}
|
||||||
|
{{- include "common.affinities.pods.soft" . -}}
|
||||||
|
{{- else if eq .type "hard" }}
|
||||||
|
{{- include "common.affinities.pods.hard" . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
229
helm/redis/charts/common/templates/_capabilities.tpl
Normal file
229
helm/redis/charts/common/templates/_capabilities.tpl
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the target Kubernetes version
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.kubeVersion" -}}
|
||||||
|
{{- if .Values.global }}
|
||||||
|
{{- if .Values.global.kubeVersion }}
|
||||||
|
{{- .Values.global.kubeVersion -}}
|
||||||
|
{{- else }}
|
||||||
|
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else }}
|
||||||
|
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for poddisruptionbudget.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.policy.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.21-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "policy/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "policy/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for networkpolicy.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.networkPolicy.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.7-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "extensions/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "networking.k8s.io/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for cronjob.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.cronjob.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.21-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "batch/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "batch/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for daemonset.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.daemonset.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "extensions/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "apps/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for deployment.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.deployment.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "extensions/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "apps/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for statefulset.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.statefulset.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "apps/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "apps/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for ingress.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.ingress.apiVersion" -}}
|
||||||
|
{{- if .Values.ingress -}}
|
||||||
|
{{- if .Values.ingress.apiVersion -}}
|
||||||
|
{{- .Values.ingress.apiVersion -}}
|
||||||
|
{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "extensions/v1beta1" -}}
|
||||||
|
{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "networking.k8s.io/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "networking.k8s.io/v1" -}}
|
||||||
|
{{- end }}
|
||||||
|
{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "extensions/v1beta1" -}}
|
||||||
|
{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "networking.k8s.io/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "networking.k8s.io/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for RBAC resources.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.rbac.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.17-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "rbac.authorization.k8s.io/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "rbac.authorization.k8s.io/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for CRDs.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.crd.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "apiextensions.k8s.io/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "apiextensions.k8s.io/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for APIService.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.apiService.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.10-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "apiregistration.k8s.io/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "apiregistration.k8s.io/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for Horizontal Pod Autoscaler.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.hpa.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .context) -}}
|
||||||
|
{{- if .beta2 -}}
|
||||||
|
{{- print "autoscaling/v2beta2" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "autoscaling/v2beta1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "autoscaling/v2" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for Vertical Pod Autoscaler.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.vpa.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .context) -}}
|
||||||
|
{{- if .beta2 -}}
|
||||||
|
{{- print "autoscaling/v2beta2" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "autoscaling/v2beta1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "autoscaling/v2" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Returns true if PodSecurityPolicy is supported
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.psp.supported" -}}
|
||||||
|
{{- if semverCompare "<1.25-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- true -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Returns true if AdmissionConfiguration is supported
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.admissionConfiguration.supported" -}}
|
||||||
|
{{- if semverCompare ">=1.23-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- true -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for AdmissionConfiguration.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.admissionConfiguration.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "apiserver.config.k8s.io/v1alpha1" -}}
|
||||||
|
{{- else if semverCompare "<1.25-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "apiserver.config.k8s.io/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "apiserver.config.k8s.io/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for PodSecurityConfiguration.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.podSecurityConfiguration.apiVersion" -}}
|
||||||
|
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "pod-security.admission.config.k8s.io/v1alpha1" -}}
|
||||||
|
{{- else if semverCompare "<1.25-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "pod-security.admission.config.k8s.io/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "pod-security.admission.config.k8s.io/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Returns true if the used Helm version is 3.3+.
|
||||||
|
A way to check the used Helm version was not introduced until version 3.3.0 with .Capabilities.HelmVersion, which contains an additional "{}}" structure.
|
||||||
|
This check is introduced as a regexMatch instead of {{ if .Capabilities.HelmVersion }} because checking for the key HelmVersion in <3.3 results in a "interface not found" error.
|
||||||
|
**To be removed when the catalog's minimun Helm version is 3.3**
|
||||||
|
*/}}
|
||||||
|
{{- define "common.capabilities.supportsHelmVersion" -}}
|
||||||
|
{{- if regexMatch "{(v[0-9])*[^}]*}}$" (.Capabilities | toString ) }}
|
||||||
|
{{- true -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
28
helm/redis/charts/common/templates/_errors.tpl
Normal file
28
helm/redis/charts/common/templates/_errors.tpl
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Through error when upgrading using empty passwords values that must not be empty.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{- $validationError00 := include "common.validations.values.single.empty" (dict "valueKey" "path.to.password00" "secret" "secretName" "field" "password-00") -}}
|
||||||
|
{{- $validationError01 := include "common.validations.values.single.empty" (dict "valueKey" "path.to.password01" "secret" "secretName" "field" "password-01") -}}
|
||||||
|
{{ include "common.errors.upgrade.passwords.empty" (dict "validationErrors" (list $validationError00 $validationError01) "context" $) }}
|
||||||
|
|
||||||
|
Required password params:
|
||||||
|
- validationErrors - String - Required. List of validation strings to be return, if it is empty it won't throw error.
|
||||||
|
- context - Context - Required. Parent context.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.errors.upgrade.passwords.empty" -}}
|
||||||
|
{{- $validationErrors := join "" .validationErrors -}}
|
||||||
|
{{- if and $validationErrors .context.Release.IsUpgrade -}}
|
||||||
|
{{- $errorString := "\nPASSWORDS ERROR: You must provide your current passwords when upgrading the release." -}}
|
||||||
|
{{- $errorString = print $errorString "\n Note that even after reinstallation, old credentials may be needed as they may be kept in persistent volume claims." -}}
|
||||||
|
{{- $errorString = print $errorString "\n Further information can be obtained at https://docs.bitnami.com/general/how-to/troubleshoot-helm-chart-issues/#credential-errors-while-upgrading-chart-releases" -}}
|
||||||
|
{{- $errorString = print $errorString "\n%s" -}}
|
||||||
|
{{- printf $errorString $validationErrors | fail -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
117
helm/redis/charts/common/templates/_images.tpl
Normal file
117
helm/redis/charts/common/templates/_images.tpl
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Return the proper image name
|
||||||
|
{{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global ) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.images.image" -}}
|
||||||
|
{{- $registryName := .imageRoot.registry -}}
|
||||||
|
{{- $repositoryName := .imageRoot.repository -}}
|
||||||
|
{{- $separator := ":" -}}
|
||||||
|
{{- $termination := .imageRoot.tag | toString -}}
|
||||||
|
{{- if .global }}
|
||||||
|
{{- if .global.imageRegistry }}
|
||||||
|
{{- $registryName = .global.imageRegistry -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if .imageRoot.digest }}
|
||||||
|
{{- $separator = "@" -}}
|
||||||
|
{{- $termination = .imageRoot.digest | toString -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if $registryName }}
|
||||||
|
{{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%s%s%s" $repositoryName $separator $termination -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the proper Docker Image Registry Secret Names (deprecated: use common.images.renderPullSecrets instead)
|
||||||
|
{{ include "common.images.pullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "global" .Values.global) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.images.pullSecrets" -}}
|
||||||
|
{{- $pullSecrets := list }}
|
||||||
|
|
||||||
|
{{- if .global }}
|
||||||
|
{{- range .global.imagePullSecrets -}}
|
||||||
|
{{- if kindIs "map" . -}}
|
||||||
|
{{- $pullSecrets = append $pullSecrets .name -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $pullSecrets = append $pullSecrets . -}}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- range .images -}}
|
||||||
|
{{- range .pullSecrets -}}
|
||||||
|
{{- if kindIs "map" . -}}
|
||||||
|
{{- $pullSecrets = append $pullSecrets .name -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $pullSecrets = append $pullSecrets . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if (not (empty $pullSecrets)) }}
|
||||||
|
imagePullSecrets:
|
||||||
|
{{- range $pullSecrets | uniq }}
|
||||||
|
- name: {{ . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the proper Docker Image Registry Secret Names evaluating values as templates
|
||||||
|
{{ include "common.images.renderPullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.images.renderPullSecrets" -}}
|
||||||
|
{{- $pullSecrets := list }}
|
||||||
|
{{- $context := .context }}
|
||||||
|
|
||||||
|
{{- if $context.Values.global }}
|
||||||
|
{{- range $context.Values.global.imagePullSecrets -}}
|
||||||
|
{{- if kindIs "map" . -}}
|
||||||
|
{{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" .name "context" $context)) -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" . "context" $context)) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- range .images -}}
|
||||||
|
{{- range .pullSecrets -}}
|
||||||
|
{{- if kindIs "map" . -}}
|
||||||
|
{{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" .name "context" $context)) -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" . "context" $context)) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if (not (empty $pullSecrets)) }}
|
||||||
|
imagePullSecrets:
|
||||||
|
{{- range $pullSecrets | uniq }}
|
||||||
|
- name: {{ . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the proper image version (ingores image revision/prerelease info & fallbacks to chart appVersion)
|
||||||
|
{{ include "common.images.version" ( dict "imageRoot" .Values.path.to.the.image "chart" .Chart ) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.images.version" -}}
|
||||||
|
{{- $imageTag := .imageRoot.tag | toString -}}
|
||||||
|
{{/* regexp from https://github.com/Masterminds/semver/blob/23f51de38a0866c5ef0bfc42b3f735c73107b700/version.go#L41-L44 */}}
|
||||||
|
{{- if regexMatch `^([0-9]+)(\.[0-9]+)?(\.[0-9]+)?(-([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?(\+([0-9A-Za-z\-]+(\.[0-9A-Za-z\-]+)*))?$` $imageTag -}}
|
||||||
|
{{- $version := semver $imageTag -}}
|
||||||
|
{{- printf "%d.%d.%d" $version.Major $version.Minor $version.Patch -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print .chart.AppVersion -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
73
helm/redis/charts/common/templates/_ingress.tpl
Normal file
73
helm/redis/charts/common/templates/_ingress.tpl
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Generate backend entry that is compatible with all Kubernetes API versions.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.ingress.backend" (dict "serviceName" "backendName" "servicePort" "backendPort" "context" $) }}
|
||||||
|
|
||||||
|
Params:
|
||||||
|
- serviceName - String. Name of an existing service backend
|
||||||
|
- servicePort - String/Int. Port name (or number) of the service. It will be translated to different yaml depending if it is a string or an integer.
|
||||||
|
- context - Dict - Required. The context for the template evaluation.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.ingress.backend" -}}
|
||||||
|
{{- $apiVersion := (include "common.capabilities.ingress.apiVersion" .context) -}}
|
||||||
|
{{- if or (eq $apiVersion "extensions/v1beta1") (eq $apiVersion "networking.k8s.io/v1beta1") -}}
|
||||||
|
serviceName: {{ .serviceName }}
|
||||||
|
servicePort: {{ .servicePort }}
|
||||||
|
{{- else -}}
|
||||||
|
service:
|
||||||
|
name: {{ .serviceName }}
|
||||||
|
port:
|
||||||
|
{{- if typeIs "string" .servicePort }}
|
||||||
|
name: {{ .servicePort }}
|
||||||
|
{{- else if or (typeIs "int" .servicePort) (typeIs "float64" .servicePort) }}
|
||||||
|
number: {{ .servicePort | int }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Print "true" if the API pathType field is supported
|
||||||
|
Usage:
|
||||||
|
{{ include "common.ingress.supportsPathType" . }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.ingress.supportsPathType" -}}
|
||||||
|
{{- if (semverCompare "<1.18-0" (include "common.capabilities.kubeVersion" .)) -}}
|
||||||
|
{{- print "false" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "true" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Returns true if the ingressClassname field is supported
|
||||||
|
Usage:
|
||||||
|
{{ include "common.ingress.supportsIngressClassname" . }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.ingress.supportsIngressClassname" -}}
|
||||||
|
{{- if semverCompare "<1.18-0" (include "common.capabilities.kubeVersion" .) -}}
|
||||||
|
{{- print "false" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "true" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return true if cert-manager required annotations for TLS signed
|
||||||
|
certificates are set in the Ingress annotations
|
||||||
|
Ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations
|
||||||
|
Usage:
|
||||||
|
{{ include "common.ingress.certManagerRequest" ( dict "annotations" .Values.path.to.the.ingress.annotations ) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.ingress.certManagerRequest" -}}
|
||||||
|
{{ if or (hasKey .annotations "cert-manager.io/cluster-issuer") (hasKey .annotations "cert-manager.io/issuer") (hasKey .annotations "kubernetes.io/tls-acme") }}
|
||||||
|
{{- true -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
46
helm/redis/charts/common/templates/_labels.tpl
Normal file
46
helm/redis/charts/common/templates/_labels.tpl
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Kubernetes standard labels
|
||||||
|
{{ include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) -}}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.labels.standard" -}}
|
||||||
|
{{- if and (hasKey . "customLabels") (hasKey . "context") -}}
|
||||||
|
{{- $default := dict "app.kubernetes.io/name" (include "common.names.name" .context) "helm.sh/chart" (include "common.names.chart" .context) "app.kubernetes.io/instance" .context.Release.Name "app.kubernetes.io/managed-by" .context.Release.Service -}}
|
||||||
|
{{- with .context.Chart.AppVersion -}}
|
||||||
|
{{- $_ := set $default "app.kubernetes.io/version" . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{ template "common.tplvalues.merge" (dict "values" (list .customLabels $default) "context" .context) }}
|
||||||
|
{{- else -}}
|
||||||
|
app.kubernetes.io/name: {{ include "common.names.name" . }}
|
||||||
|
helm.sh/chart: {{ include "common.names.chart" . }}
|
||||||
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
|
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||||
|
{{- with .Chart.AppVersion }}
|
||||||
|
app.kubernetes.io/version: {{ . | quote }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Labels used on immutable fields such as deploy.spec.selector.matchLabels or svc.spec.selector
|
||||||
|
{{ include "common.labels.matchLabels" (dict "customLabels" .Values.podLabels "context" $) -}}
|
||||||
|
|
||||||
|
We don't want to loop over custom labels appending them to the selector
|
||||||
|
since it's very likely that it will break deployments, services, etc.
|
||||||
|
However, it's important to overwrite the standard labels if the user
|
||||||
|
overwrote them on metadata.labels fields.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.labels.matchLabels" -}}
|
||||||
|
{{- if and (hasKey . "customLabels") (hasKey . "context") -}}
|
||||||
|
{{ merge (pick (include "common.tplvalues.render" (dict "value" .customLabels "context" .context) | fromYaml) "app.kubernetes.io/name" "app.kubernetes.io/instance") (dict "app.kubernetes.io/name" (include "common.names.name" .context) "app.kubernetes.io/instance" .context.Release.Name ) | toYaml }}
|
||||||
|
{{- else -}}
|
||||||
|
app.kubernetes.io/name: {{ include "common.names.name" . }}
|
||||||
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
71
helm/redis/charts/common/templates/_names.tpl
Normal file
71
helm/redis/charts/common/templates/_names.tpl
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Expand the name of the chart.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.names.name" -}}
|
||||||
|
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Create chart name and version as used by the chart label.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.names.chart" -}}
|
||||||
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Create a default fully qualified app name.
|
||||||
|
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||||
|
If release name contains chart name it will be used as a full name.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.names.fullname" -}}
|
||||||
|
{{- if .Values.fullnameOverride -}}
|
||||||
|
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||||
|
{{- if contains $name .Release.Name -}}
|
||||||
|
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Create a default fully qualified dependency name.
|
||||||
|
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||||
|
If release name contains chart name it will be used as a full name.
|
||||||
|
Usage:
|
||||||
|
{{ include "common.names.dependency.fullname" (dict "chartName" "dependency-chart-name" "chartValues" .Values.dependency-chart "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.names.dependency.fullname" -}}
|
||||||
|
{{- if .chartValues.fullnameOverride -}}
|
||||||
|
{{- .chartValues.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $name := default .chartName .chartValues.nameOverride -}}
|
||||||
|
{{- if contains $name .context.Release.Name -}}
|
||||||
|
{{- .context.Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%s-%s" .context.Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Allow the release namespace to be overridden for multi-namespace deployments in combined charts.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.names.namespace" -}}
|
||||||
|
{{- default .Release.Namespace .Values.namespaceOverride | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Create a fully qualified app name adding the installation's namespace.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.names.fullname.namespace" -}}
|
||||||
|
{{- printf "%s-%s" (include "common.names.fullname" .) (include "common.names.namespace" .) | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
||||||
182
helm/redis/charts/common/templates/_secrets.tpl
Normal file
182
helm/redis/charts/common/templates/_secrets.tpl
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Generate secret name.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.secrets.name" (dict "existingSecret" .Values.path.to.the.existingSecret "defaultNameSuffix" "mySuffix" "context" $) }}
|
||||||
|
|
||||||
|
Params:
|
||||||
|
- existingSecret - ExistingSecret/String - Optional. The path to the existing secrets in the values.yaml given by the user
|
||||||
|
to be used instead of the default one. Allows for it to be of type String (just the secret name) for backwards compatibility.
|
||||||
|
+info: https://github.com/bitnami/charts/tree/main/bitnami/common#existingsecret
|
||||||
|
- defaultNameSuffix - String - Optional. It is used only if we have several secrets in the same deployment.
|
||||||
|
- context - Dict - Required. The context for the template evaluation.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.secrets.name" -}}
|
||||||
|
{{- $name := (include "common.names.fullname" .context) -}}
|
||||||
|
|
||||||
|
{{- if .defaultNameSuffix -}}
|
||||||
|
{{- $name = printf "%s-%s" $name .defaultNameSuffix | trunc 63 | trimSuffix "-" -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- with .existingSecret -}}
|
||||||
|
{{- if not (typeIs "string" .) -}}
|
||||||
|
{{- with .name -}}
|
||||||
|
{{- $name = . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- $name = . -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- printf "%s" $name -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Generate secret key.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.secrets.key" (dict "existingSecret" .Values.path.to.the.existingSecret "key" "keyName") }}
|
||||||
|
|
||||||
|
Params:
|
||||||
|
- existingSecret - ExistingSecret/String - Optional. The path to the existing secrets in the values.yaml given by the user
|
||||||
|
to be used instead of the default one. Allows for it to be of type String (just the secret name) for backwards compatibility.
|
||||||
|
+info: https://github.com/bitnami/charts/tree/main/bitnami/common#existingsecret
|
||||||
|
- key - String - Required. Name of the key in the secret.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.secrets.key" -}}
|
||||||
|
{{- $key := .key -}}
|
||||||
|
|
||||||
|
{{- if .existingSecret -}}
|
||||||
|
{{- if not (typeIs "string" .existingSecret) -}}
|
||||||
|
{{- if .existingSecret.keyMapping -}}
|
||||||
|
{{- $key = index .existingSecret.keyMapping $.key -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- printf "%s" $key -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Generate secret password or retrieve one if already created.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.secrets.passwords.manage" (dict "secret" "secret-name" "key" "keyName" "providedValues" (list "path.to.password1" "path.to.password2") "length" 10 "strong" false "chartName" "chartName" "context" $) }}
|
||||||
|
|
||||||
|
Params:
|
||||||
|
- secret - String - Required - Name of the 'Secret' resource where the password is stored.
|
||||||
|
- key - String - Required - Name of the key in the secret.
|
||||||
|
- providedValues - List<String> - Required - The path to the validating value in the values.yaml, e.g: "mysql.password". Will pick first parameter with a defined value.
|
||||||
|
- length - int - Optional - Length of the generated random password.
|
||||||
|
- strong - Boolean - Optional - Whether to add symbols to the generated random password.
|
||||||
|
- chartName - String - Optional - Name of the chart used when said chart is deployed as a subchart.
|
||||||
|
- context - Context - Required - Parent context.
|
||||||
|
- failOnNew - Boolean - Optional - Default to true. If set to false, skip errors adding new keys to existing secrets.
|
||||||
|
- skipB64enc - Boolean - Optional - Default to false. If set to true, no the secret will not be base64 encrypted.
|
||||||
|
- skipQuote - Boolean - Optional - Default to false. If set to true, no quotes will be added around the secret.
|
||||||
|
The order in which this function returns a secret password:
|
||||||
|
1. Already existing 'Secret' resource
|
||||||
|
(If a 'Secret' resource is found under the name provided to the 'secret' parameter to this function and that 'Secret' resource contains a key with the name passed as the 'key' parameter to this function then the value of this existing secret password will be returned)
|
||||||
|
2. Password provided via the values.yaml
|
||||||
|
(If one of the keys passed to the 'providedValues' parameter to this function is a valid path to a key in the values.yaml and has a value, the value of the first key with a value will be returned)
|
||||||
|
3. Randomly generated secret password
|
||||||
|
(A new random secret password with the length specified in the 'length' parameter will be generated and returned)
|
||||||
|
|
||||||
|
*/}}
|
||||||
|
{{- define "common.secrets.passwords.manage" -}}
|
||||||
|
|
||||||
|
{{- $password := "" }}
|
||||||
|
{{- $subchart := "" }}
|
||||||
|
{{- $chartName := default "" .chartName }}
|
||||||
|
{{- $passwordLength := default 10 .length }}
|
||||||
|
{{- $providedPasswordKey := include "common.utils.getKeyFromList" (dict "keys" .providedValues "context" $.context) }}
|
||||||
|
{{- $providedPasswordValue := include "common.utils.getValueFromKey" (dict "key" $providedPasswordKey "context" $.context) }}
|
||||||
|
{{- $secretData := (lookup "v1" "Secret" (include "common.names.namespace" .context) .secret).data }}
|
||||||
|
{{- if $secretData }}
|
||||||
|
{{- if hasKey $secretData .key }}
|
||||||
|
{{- $password = index $secretData .key | b64dec }}
|
||||||
|
{{- else if not (eq .failOnNew false) }}
|
||||||
|
{{- printf "\nPASSWORDS ERROR: The secret \"%s\" does not contain the key \"%s\"\n" .secret .key | fail -}}
|
||||||
|
{{- else if $providedPasswordValue }}
|
||||||
|
{{- $password = $providedPasswordValue | toString }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- else if $providedPasswordValue }}
|
||||||
|
{{- $password = $providedPasswordValue | toString }}
|
||||||
|
{{- else }}
|
||||||
|
|
||||||
|
{{- if .context.Values.enabled }}
|
||||||
|
{{- $subchart = $chartName }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- $requiredPassword := dict "valueKey" $providedPasswordKey "secret" .secret "field" .key "subchart" $subchart "context" $.context -}}
|
||||||
|
{{- $requiredPasswordError := include "common.validations.values.single.empty" $requiredPassword -}}
|
||||||
|
{{- $passwordValidationErrors := list $requiredPasswordError -}}
|
||||||
|
{{- include "common.errors.upgrade.passwords.empty" (dict "validationErrors" $passwordValidationErrors "context" $.context) -}}
|
||||||
|
|
||||||
|
{{- if .strong }}
|
||||||
|
{{- $subStr := list (lower (randAlpha 1)) (randNumeric 1) (upper (randAlpha 1)) | join "_" }}
|
||||||
|
{{- $password = randAscii $passwordLength }}
|
||||||
|
{{- $password = regexReplaceAllLiteral "\\W" $password "@" | substr 5 $passwordLength }}
|
||||||
|
{{- $password = printf "%s%s" $subStr $password | toString | shuffle }}
|
||||||
|
{{- else }}
|
||||||
|
{{- $password = randAlphaNum $passwordLength }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if not .skipB64enc }}
|
||||||
|
{{- $password = $password | b64enc }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if .skipQuote -}}
|
||||||
|
{{- printf "%s" $password -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%s" $password | quote -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Reuses the value from an existing secret, otherwise sets its value to a default value.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.secrets.lookup" (dict "secret" "secret-name" "key" "keyName" "defaultValue" .Values.myValue "context" $) }}
|
||||||
|
|
||||||
|
Params:
|
||||||
|
- secret - String - Required - Name of the 'Secret' resource where the password is stored.
|
||||||
|
- key - String - Required - Name of the key in the secret.
|
||||||
|
- defaultValue - String - Required - The path to the validating value in the values.yaml, e.g: "mysql.password". Will pick first parameter with a defined value.
|
||||||
|
- context - Context - Required - Parent context.
|
||||||
|
|
||||||
|
*/}}
|
||||||
|
{{- define "common.secrets.lookup" -}}
|
||||||
|
{{- $value := "" -}}
|
||||||
|
{{- $secretData := (lookup "v1" "Secret" (include "common.names.namespace" .context) .secret).data -}}
|
||||||
|
{{- if and $secretData (hasKey $secretData .key) -}}
|
||||||
|
{{- $value = index $secretData .key -}}
|
||||||
|
{{- else if .defaultValue -}}
|
||||||
|
{{- $value = .defaultValue | toString | b64enc -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- if $value -}}
|
||||||
|
{{- printf "%s" $value -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Returns whether a previous generated secret already exists
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.secrets.exists" (dict "secret" "secret-name" "context" $) }}
|
||||||
|
|
||||||
|
Params:
|
||||||
|
- secret - String - Required - Name of the 'Secret' resource where the password is stored.
|
||||||
|
- context - Context - Required - Parent context.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.secrets.exists" -}}
|
||||||
|
{{- $secret := (lookup "v1" "Secret" (include "common.names.namespace" .context) .secret) }}
|
||||||
|
{{- if $secret }}
|
||||||
|
{{- true -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
28
helm/redis/charts/common/templates/_storage.tpl
Normal file
28
helm/redis/charts/common/templates/_storage.tpl
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Return the proper Storage Class
|
||||||
|
{{ include "common.storage.class" ( dict "persistence" .Values.path.to.the.persistence "global" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.storage.class" -}}
|
||||||
|
|
||||||
|
{{- $storageClass := .persistence.storageClass -}}
|
||||||
|
{{- if .global -}}
|
||||||
|
{{- if .global.storageClass -}}
|
||||||
|
{{- $storageClass = .global.storageClass -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if $storageClass -}}
|
||||||
|
{{- if (eq "-" $storageClass) -}}
|
||||||
|
{{- printf "storageClassName: \"\"" -}}
|
||||||
|
{{- else }}
|
||||||
|
{{- printf "storageClassName: %s" $storageClass -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- end -}}
|
||||||
38
helm/redis/charts/common/templates/_tplvalues.tpl
Normal file
38
helm/redis/charts/common/templates/_tplvalues.tpl
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Renders a value that contains template perhaps with scope if the scope is present.
|
||||||
|
Usage:
|
||||||
|
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ ) }}
|
||||||
|
{{ include "common.tplvalues.render" ( dict "value" .Values.path.to.the.Value "context" $ "scope" $app ) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.tplvalues.render" -}}
|
||||||
|
{{- $value := typeIs "string" .value | ternary .value (.value | toYaml) }}
|
||||||
|
{{- if contains "{{" (toJson .value) }}
|
||||||
|
{{- if .scope }}
|
||||||
|
{{- tpl (cat "{{- with $.RelativeScope -}}" $value "{{- end }}") (merge (dict "RelativeScope" .scope) .context) }}
|
||||||
|
{{- else }}
|
||||||
|
{{- tpl $value .context }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
{{- $value }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Merge a list of values that contains template after rendering them.
|
||||||
|
Merge precedence is consistent with http://masterminds.github.io/sprig/dicts.html#merge-mustmerge
|
||||||
|
Usage:
|
||||||
|
{{ include "common.tplvalues.merge" ( dict "values" (list .Values.path.to.the.Value1 .Values.path.to.the.Value2) "context" $ ) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.tplvalues.merge" -}}
|
||||||
|
{{- $dst := dict -}}
|
||||||
|
{{- range .values -}}
|
||||||
|
{{- $dst = include "common.tplvalues.render" (dict "value" . "context" $.context "scope" $.scope) | fromYaml | merge $dst -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{ $dst | toYaml }}
|
||||||
|
{{- end -}}
|
||||||
77
helm/redis/charts/common/templates/_utils.tpl
Normal file
77
helm/redis/charts/common/templates/_utils.tpl
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Print instructions to get a secret value.
|
||||||
|
Usage:
|
||||||
|
{{ include "common.utils.secret.getvalue" (dict "secret" "secret-name" "field" "secret-value-field" "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.utils.secret.getvalue" -}}
|
||||||
|
{{- $varname := include "common.utils.fieldToEnvVar" . -}}
|
||||||
|
export {{ $varname }}=$(kubectl get secret --namespace {{ include "common.names.namespace" .context | quote }} {{ .secret }} -o jsonpath="{.data.{{ .field }}}" | base64 -d)
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Build env var name given a field
|
||||||
|
Usage:
|
||||||
|
{{ include "common.utils.fieldToEnvVar" dict "field" "my-password" }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.utils.fieldToEnvVar" -}}
|
||||||
|
{{- $fieldNameSplit := splitList "-" .field -}}
|
||||||
|
{{- $upperCaseFieldNameSplit := list -}}
|
||||||
|
|
||||||
|
{{- range $fieldNameSplit -}}
|
||||||
|
{{- $upperCaseFieldNameSplit = append $upperCaseFieldNameSplit ( upper . ) -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{ join "_" $upperCaseFieldNameSplit }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Gets a value from .Values given
|
||||||
|
Usage:
|
||||||
|
{{ include "common.utils.getValueFromKey" (dict "key" "path.to.key" "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.utils.getValueFromKey" -}}
|
||||||
|
{{- $splitKey := splitList "." .key -}}
|
||||||
|
{{- $value := "" -}}
|
||||||
|
{{- $latestObj := $.context.Values -}}
|
||||||
|
{{- range $splitKey -}}
|
||||||
|
{{- if not $latestObj -}}
|
||||||
|
{{- printf "please review the entire path of '%s' exists in values" $.key | fail -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- $value = ( index $latestObj . ) -}}
|
||||||
|
{{- $latestObj = $value -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- printf "%v" (default "" $value) -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Returns first .Values key with a defined value or first of the list if all non-defined
|
||||||
|
Usage:
|
||||||
|
{{ include "common.utils.getKeyFromList" (dict "keys" (list "path.to.key1" "path.to.key2") "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.utils.getKeyFromList" -}}
|
||||||
|
{{- $key := first .keys -}}
|
||||||
|
{{- $reverseKeys := reverse .keys }}
|
||||||
|
{{- range $reverseKeys }}
|
||||||
|
{{- $value := include "common.utils.getValueFromKey" (dict "key" . "context" $.context ) }}
|
||||||
|
{{- if $value -}}
|
||||||
|
{{- $key = . }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- printf "%s" $key -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Checksum a template at "path" containing a *single* resource (ConfigMap,Secret) for use in pod annotations, excluding the metadata (see #18376).
|
||||||
|
Usage:
|
||||||
|
{{ include "common.utils.checksumTemplate" (dict "path" "/configmap.yaml" "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.utils.checksumTemplate" -}}
|
||||||
|
{{- $obj := include (print .context.Template.BasePath .path) .context | fromYaml -}}
|
||||||
|
{{ omit $obj "apiVersion" "kind" "metadata" | toYaml | sha256sum }}
|
||||||
|
{{- end -}}
|
||||||
19
helm/redis/charts/common/templates/_warnings.tpl
Normal file
19
helm/redis/charts/common/templates/_warnings.tpl
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Warning about using rolling tag.
|
||||||
|
Usage:
|
||||||
|
{{ include "common.warnings.rollingTag" .Values.path.to.the.imageRoot }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.warnings.rollingTag" -}}
|
||||||
|
|
||||||
|
{{- if and (contains "bitnami/" .repository) (not (.tag | toString | regexFind "-r\\d+$|sha256:")) }}
|
||||||
|
WARNING: Rolling tag detected ({{ .repository }}:{{ .tag }}), please note that it is strongly recommended to avoid using rolling tags in a production environment.
|
||||||
|
+info https://docs.bitnami.com/containers/how-to/understand-rolling-tags-containers/
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- end -}}
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Validate Cassandra required passwords are not empty.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.validations.values.cassandra.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
|
||||||
|
Params:
|
||||||
|
- secret - String - Required. Name of the secret where Cassandra values are stored, e.g: "cassandra-passwords-secret"
|
||||||
|
- subchart - Boolean - Optional. Whether Cassandra is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.validations.values.cassandra.passwords" -}}
|
||||||
|
{{- $existingSecret := include "common.cassandra.values.existingSecret" . -}}
|
||||||
|
{{- $enabled := include "common.cassandra.values.enabled" . -}}
|
||||||
|
{{- $dbUserPrefix := include "common.cassandra.values.key.dbUser" . -}}
|
||||||
|
{{- $valueKeyPassword := printf "%s.password" $dbUserPrefix -}}
|
||||||
|
|
||||||
|
{{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") -}}
|
||||||
|
{{- $requiredPasswords := list -}}
|
||||||
|
|
||||||
|
{{- $requiredPassword := dict "valueKey" $valueKeyPassword "secret" .secret "field" "cassandra-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredPassword -}}
|
||||||
|
|
||||||
|
{{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
|
||||||
|
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for existingSecret.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.cassandra.values.existingSecret" (dict "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether Cassandra is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.cassandra.values.existingSecret" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- .context.Values.cassandra.dbUser.existingSecret | quote -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- .context.Values.dbUser.existingSecret | quote -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for enabled cassandra.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.cassandra.values.enabled" (dict "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.cassandra.values.enabled" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- printf "%v" .context.Values.cassandra.enabled -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%v" (not .context.Values.enabled) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for the key dbUser
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.cassandra.values.key.dbUser" (dict "subchart" "true" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether Cassandra is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.cassandra.values.key.dbUser" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
cassandra.dbUser
|
||||||
|
{{- else -}}
|
||||||
|
dbUser
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
108
helm/redis/charts/common/templates/validations/_mariadb.tpl
Normal file
108
helm/redis/charts/common/templates/validations/_mariadb.tpl
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Validate MariaDB required passwords are not empty.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.validations.values.mariadb.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
|
||||||
|
Params:
|
||||||
|
- secret - String - Required. Name of the secret where MariaDB values are stored, e.g: "mysql-passwords-secret"
|
||||||
|
- subchart - Boolean - Optional. Whether MariaDB is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.validations.values.mariadb.passwords" -}}
|
||||||
|
{{- $existingSecret := include "common.mariadb.values.auth.existingSecret" . -}}
|
||||||
|
{{- $enabled := include "common.mariadb.values.enabled" . -}}
|
||||||
|
{{- $architecture := include "common.mariadb.values.architecture" . -}}
|
||||||
|
{{- $authPrefix := include "common.mariadb.values.key.auth" . -}}
|
||||||
|
{{- $valueKeyRootPassword := printf "%s.rootPassword" $authPrefix -}}
|
||||||
|
{{- $valueKeyUsername := printf "%s.username" $authPrefix -}}
|
||||||
|
{{- $valueKeyPassword := printf "%s.password" $authPrefix -}}
|
||||||
|
{{- $valueKeyReplicationPassword := printf "%s.replicationPassword" $authPrefix -}}
|
||||||
|
|
||||||
|
{{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") -}}
|
||||||
|
{{- $requiredPasswords := list -}}
|
||||||
|
|
||||||
|
{{- $requiredRootPassword := dict "valueKey" $valueKeyRootPassword "secret" .secret "field" "mariadb-root-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredRootPassword -}}
|
||||||
|
|
||||||
|
{{- $valueUsername := include "common.utils.getValueFromKey" (dict "key" $valueKeyUsername "context" .context) }}
|
||||||
|
{{- if not (empty $valueUsername) -}}
|
||||||
|
{{- $requiredPassword := dict "valueKey" $valueKeyPassword "secret" .secret "field" "mariadb-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredPassword -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if (eq $architecture "replication") -}}
|
||||||
|
{{- $requiredReplicationPassword := dict "valueKey" $valueKeyReplicationPassword "secret" .secret "field" "mariadb-replication-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredReplicationPassword -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
|
||||||
|
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for existingSecret.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mariadb.values.auth.existingSecret" (dict "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether MariaDB is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mariadb.values.auth.existingSecret" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- .context.Values.mariadb.auth.existingSecret | quote -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- .context.Values.auth.existingSecret | quote -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for enabled mariadb.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mariadb.values.enabled" (dict "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mariadb.values.enabled" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- printf "%v" .context.Values.mariadb.enabled -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%v" (not .context.Values.enabled) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for architecture
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mariadb.values.architecture" (dict "subchart" "true" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether MariaDB is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mariadb.values.architecture" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- .context.Values.mariadb.architecture -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- .context.Values.architecture -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for the key auth
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mariadb.values.key.auth" (dict "subchart" "true" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether MariaDB is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mariadb.values.key.auth" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
mariadb.auth
|
||||||
|
{{- else -}}
|
||||||
|
auth
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
113
helm/redis/charts/common/templates/validations/_mongodb.tpl
Normal file
113
helm/redis/charts/common/templates/validations/_mongodb.tpl
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Validate MongoDB® required passwords are not empty.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.validations.values.mongodb.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
|
||||||
|
Params:
|
||||||
|
- secret - String - Required. Name of the secret where MongoDB® values are stored, e.g: "mongodb-passwords-secret"
|
||||||
|
- subchart - Boolean - Optional. Whether MongoDB® is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.validations.values.mongodb.passwords" -}}
|
||||||
|
{{- $existingSecret := include "common.mongodb.values.auth.existingSecret" . -}}
|
||||||
|
{{- $enabled := include "common.mongodb.values.enabled" . -}}
|
||||||
|
{{- $authPrefix := include "common.mongodb.values.key.auth" . -}}
|
||||||
|
{{- $architecture := include "common.mongodb.values.architecture" . -}}
|
||||||
|
{{- $valueKeyRootPassword := printf "%s.rootPassword" $authPrefix -}}
|
||||||
|
{{- $valueKeyUsername := printf "%s.username" $authPrefix -}}
|
||||||
|
{{- $valueKeyDatabase := printf "%s.database" $authPrefix -}}
|
||||||
|
{{- $valueKeyPassword := printf "%s.password" $authPrefix -}}
|
||||||
|
{{- $valueKeyReplicaSetKey := printf "%s.replicaSetKey" $authPrefix -}}
|
||||||
|
{{- $valueKeyAuthEnabled := printf "%s.enabled" $authPrefix -}}
|
||||||
|
|
||||||
|
{{- $authEnabled := include "common.utils.getValueFromKey" (dict "key" $valueKeyAuthEnabled "context" .context) -}}
|
||||||
|
|
||||||
|
{{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") (eq $authEnabled "true") -}}
|
||||||
|
{{- $requiredPasswords := list -}}
|
||||||
|
|
||||||
|
{{- $requiredRootPassword := dict "valueKey" $valueKeyRootPassword "secret" .secret "field" "mongodb-root-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredRootPassword -}}
|
||||||
|
|
||||||
|
{{- $valueUsername := include "common.utils.getValueFromKey" (dict "key" $valueKeyUsername "context" .context) }}
|
||||||
|
{{- $valueDatabase := include "common.utils.getValueFromKey" (dict "key" $valueKeyDatabase "context" .context) }}
|
||||||
|
{{- if and $valueUsername $valueDatabase -}}
|
||||||
|
{{- $requiredPassword := dict "valueKey" $valueKeyPassword "secret" .secret "field" "mongodb-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredPassword -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if (eq $architecture "replicaset") -}}
|
||||||
|
{{- $requiredReplicaSetKey := dict "valueKey" $valueKeyReplicaSetKey "secret" .secret "field" "mongodb-replica-set-key" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredReplicaSetKey -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
|
||||||
|
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for existingSecret.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mongodb.values.auth.existingSecret" (dict "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether MongoDb is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mongodb.values.auth.existingSecret" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- .context.Values.mongodb.auth.existingSecret | quote -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- .context.Values.auth.existingSecret | quote -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for enabled mongodb.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mongodb.values.enabled" (dict "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mongodb.values.enabled" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- printf "%v" .context.Values.mongodb.enabled -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%v" (not .context.Values.enabled) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for the key auth
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mongodb.values.key.auth" (dict "subchart" "true" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether MongoDB® is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mongodb.values.key.auth" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
mongodb.auth
|
||||||
|
{{- else -}}
|
||||||
|
auth
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for architecture
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mongodb.values.architecture" (dict "subchart" "true" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether MongoDB® is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mongodb.values.architecture" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- .context.Values.mongodb.architecture -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- .context.Values.architecture -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
108
helm/redis/charts/common/templates/validations/_mysql.tpl
Normal file
108
helm/redis/charts/common/templates/validations/_mysql.tpl
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Validate MySQL required passwords are not empty.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.validations.values.mysql.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
|
||||||
|
Params:
|
||||||
|
- secret - String - Required. Name of the secret where MySQL values are stored, e.g: "mysql-passwords-secret"
|
||||||
|
- subchart - Boolean - Optional. Whether MySQL is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.validations.values.mysql.passwords" -}}
|
||||||
|
{{- $existingSecret := include "common.mysql.values.auth.existingSecret" . -}}
|
||||||
|
{{- $enabled := include "common.mysql.values.enabled" . -}}
|
||||||
|
{{- $architecture := include "common.mysql.values.architecture" . -}}
|
||||||
|
{{- $authPrefix := include "common.mysql.values.key.auth" . -}}
|
||||||
|
{{- $valueKeyRootPassword := printf "%s.rootPassword" $authPrefix -}}
|
||||||
|
{{- $valueKeyUsername := printf "%s.username" $authPrefix -}}
|
||||||
|
{{- $valueKeyPassword := printf "%s.password" $authPrefix -}}
|
||||||
|
{{- $valueKeyReplicationPassword := printf "%s.replicationPassword" $authPrefix -}}
|
||||||
|
|
||||||
|
{{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") -}}
|
||||||
|
{{- $requiredPasswords := list -}}
|
||||||
|
|
||||||
|
{{- $requiredRootPassword := dict "valueKey" $valueKeyRootPassword "secret" .secret "field" "mysql-root-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredRootPassword -}}
|
||||||
|
|
||||||
|
{{- $valueUsername := include "common.utils.getValueFromKey" (dict "key" $valueKeyUsername "context" .context) }}
|
||||||
|
{{- if not (empty $valueUsername) -}}
|
||||||
|
{{- $requiredPassword := dict "valueKey" $valueKeyPassword "secret" .secret "field" "mysql-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredPassword -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- if (eq $architecture "replication") -}}
|
||||||
|
{{- $requiredReplicationPassword := dict "valueKey" $valueKeyReplicationPassword "secret" .secret "field" "mysql-replication-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredReplicationPassword -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
|
||||||
|
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for existingSecret.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mysql.values.auth.existingSecret" (dict "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether MySQL is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mysql.values.auth.existingSecret" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- .context.Values.mysql.auth.existingSecret | quote -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- .context.Values.auth.existingSecret | quote -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for enabled mysql.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mysql.values.enabled" (dict "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mysql.values.enabled" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- printf "%v" .context.Values.mysql.enabled -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%v" (not .context.Values.enabled) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for architecture
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mysql.values.architecture" (dict "subchart" "true" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether MySQL is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mysql.values.architecture" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- .context.Values.mysql.architecture -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- .context.Values.architecture -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for the key auth
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.mysql.values.key.auth" (dict "subchart" "true" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether MySQL is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.mysql.values.key.auth" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
mysql.auth
|
||||||
|
{{- else -}}
|
||||||
|
auth
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
134
helm/redis/charts/common/templates/validations/_postgresql.tpl
Normal file
134
helm/redis/charts/common/templates/validations/_postgresql.tpl
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Validate PostgreSQL required passwords are not empty.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.validations.values.postgresql.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
|
||||||
|
Params:
|
||||||
|
- secret - String - Required. Name of the secret where postgresql values are stored, e.g: "postgresql-passwords-secret"
|
||||||
|
- subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.validations.values.postgresql.passwords" -}}
|
||||||
|
{{- $existingSecret := include "common.postgresql.values.existingSecret" . -}}
|
||||||
|
{{- $enabled := include "common.postgresql.values.enabled" . -}}
|
||||||
|
{{- $valueKeyPostgresqlPassword := include "common.postgresql.values.key.postgressPassword" . -}}
|
||||||
|
{{- $valueKeyPostgresqlReplicationEnabled := include "common.postgresql.values.key.replicationPassword" . -}}
|
||||||
|
{{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") -}}
|
||||||
|
{{- $requiredPasswords := list -}}
|
||||||
|
{{- $requiredPostgresqlPassword := dict "valueKey" $valueKeyPostgresqlPassword "secret" .secret "field" "postgresql-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredPostgresqlPassword -}}
|
||||||
|
|
||||||
|
{{- $enabledReplication := include "common.postgresql.values.enabled.replication" . -}}
|
||||||
|
{{- if (eq $enabledReplication "true") -}}
|
||||||
|
{{- $requiredPostgresqlReplicationPassword := dict "valueKey" $valueKeyPostgresqlReplicationEnabled "secret" .secret "field" "postgresql-replication-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredPostgresqlReplicationPassword -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to decide whether evaluate global values.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.postgresql.values.use.global" (dict "key" "key-of-global" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- key - String - Required. Field to be evaluated within global, e.g: "existingSecret"
|
||||||
|
*/}}
|
||||||
|
{{- define "common.postgresql.values.use.global" -}}
|
||||||
|
{{- if .context.Values.global -}}
|
||||||
|
{{- if .context.Values.global.postgresql -}}
|
||||||
|
{{- index .context.Values.global.postgresql .key | quote -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for existingSecret.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.postgresql.values.existingSecret" (dict "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.postgresql.values.existingSecret" -}}
|
||||||
|
{{- $globalValue := include "common.postgresql.values.use.global" (dict "key" "existingSecret" "context" .context) -}}
|
||||||
|
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- default (.context.Values.postgresql.existingSecret | quote) $globalValue -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- default (.context.Values.existingSecret | quote) $globalValue -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for enabled postgresql.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.postgresql.values.enabled" (dict "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.postgresql.values.enabled" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- printf "%v" .context.Values.postgresql.enabled -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%v" (not .context.Values.enabled) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for the key postgressPassword.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.postgresql.values.key.postgressPassword" (dict "subchart" "true" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.postgresql.values.key.postgressPassword" -}}
|
||||||
|
{{- $globalValue := include "common.postgresql.values.use.global" (dict "key" "postgresqlUsername" "context" .context) -}}
|
||||||
|
|
||||||
|
{{- if not $globalValue -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
postgresql.postgresqlPassword
|
||||||
|
{{- else -}}
|
||||||
|
postgresqlPassword
|
||||||
|
{{- end -}}
|
||||||
|
{{- else -}}
|
||||||
|
global.postgresql.postgresqlPassword
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for enabled.replication.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.postgresql.values.enabled.replication" (dict "subchart" "true" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.postgresql.values.enabled.replication" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- printf "%v" .context.Values.postgresql.replication.enabled -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%v" .context.Values.replication.enabled -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for the key replication.password.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.postgresql.values.key.replicationPassword" (dict "subchart" "true" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether postgresql is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.postgresql.values.key.replicationPassword" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
postgresql.replication.password
|
||||||
|
{{- else -}}
|
||||||
|
replication.password
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
81
helm/redis/charts/common/templates/validations/_redis.tpl
Normal file
81
helm/redis/charts/common/templates/validations/_redis.tpl
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Validate Redis® required passwords are not empty.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.validations.values.redis.passwords" (dict "secret" "secretName" "subchart" false "context" $) }}
|
||||||
|
Params:
|
||||||
|
- secret - String - Required. Name of the secret where redis values are stored, e.g: "redis-passwords-secret"
|
||||||
|
- subchart - Boolean - Optional. Whether redis is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.validations.values.redis.passwords" -}}
|
||||||
|
{{- $enabled := include "common.redis.values.enabled" . -}}
|
||||||
|
{{- $valueKeyPrefix := include "common.redis.values.keys.prefix" . -}}
|
||||||
|
{{- $standarizedVersion := include "common.redis.values.standarized.version" . }}
|
||||||
|
|
||||||
|
{{- $existingSecret := ternary (printf "%s%s" $valueKeyPrefix "auth.existingSecret") (printf "%s%s" $valueKeyPrefix "existingSecret") (eq $standarizedVersion "true") }}
|
||||||
|
{{- $existingSecretValue := include "common.utils.getValueFromKey" (dict "key" $existingSecret "context" .context) }}
|
||||||
|
|
||||||
|
{{- $valueKeyRedisPassword := ternary (printf "%s%s" $valueKeyPrefix "auth.password") (printf "%s%s" $valueKeyPrefix "password") (eq $standarizedVersion "true") }}
|
||||||
|
{{- $valueKeyRedisUseAuth := ternary (printf "%s%s" $valueKeyPrefix "auth.enabled") (printf "%s%s" $valueKeyPrefix "usePassword") (eq $standarizedVersion "true") }}
|
||||||
|
|
||||||
|
{{- if and (or (not $existingSecret) (eq $existingSecret "\"\"")) (eq $enabled "true") -}}
|
||||||
|
{{- $requiredPasswords := list -}}
|
||||||
|
|
||||||
|
{{- $useAuth := include "common.utils.getValueFromKey" (dict "key" $valueKeyRedisUseAuth "context" .context) -}}
|
||||||
|
{{- if eq $useAuth "true" -}}
|
||||||
|
{{- $requiredRedisPassword := dict "valueKey" $valueKeyRedisPassword "secret" .secret "field" "redis-password" -}}
|
||||||
|
{{- $requiredPasswords = append $requiredPasswords $requiredRedisPassword -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- include "common.validations.values.multiple.empty" (dict "required" $requiredPasswords "context" .context) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right value for enabled redis.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.redis.values.enabled" (dict "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.redis.values.enabled" -}}
|
||||||
|
{{- if .subchart -}}
|
||||||
|
{{- printf "%v" .context.Values.redis.enabled -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%v" (not .context.Values.enabled) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Auxiliary function to get the right prefix path for the values
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.redis.values.key.prefix" (dict "subchart" "true" "context" $) }}
|
||||||
|
Params:
|
||||||
|
- subchart - Boolean - Optional. Whether redis is used as subchart or not. Default: false
|
||||||
|
*/}}
|
||||||
|
{{- define "common.redis.values.keys.prefix" -}}
|
||||||
|
{{- if .subchart -}}redis.{{- else -}}{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Checks whether the redis chart's includes the standarizations (version >= 14)
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.redis.values.standarized.version" (dict "context" $) }}
|
||||||
|
*/}}
|
||||||
|
{{- define "common.redis.values.standarized.version" -}}
|
||||||
|
|
||||||
|
{{- $standarizedAuth := printf "%s%s" (include "common.redis.values.keys.prefix" .) "auth" -}}
|
||||||
|
{{- $standarizedAuthValues := include "common.utils.getValueFromKey" (dict "key" $standarizedAuth "context" .context) }}
|
||||||
|
|
||||||
|
{{- if $standarizedAuthValues -}}
|
||||||
|
{{- true -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
@ -0,0 +1,51 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
{{/*
|
||||||
|
Validate values must not be empty.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{- $validateValueConf00 := (dict "valueKey" "path.to.value" "secret" "secretName" "field" "password-00") -}}
|
||||||
|
{{- $validateValueConf01 := (dict "valueKey" "path.to.value" "secret" "secretName" "field" "password-01") -}}
|
||||||
|
{{ include "common.validations.values.empty" (dict "required" (list $validateValueConf00 $validateValueConf01) "context" $) }}
|
||||||
|
|
||||||
|
Validate value params:
|
||||||
|
- valueKey - String - Required. The path to the validating value in the values.yaml, e.g: "mysql.password"
|
||||||
|
- secret - String - Optional. Name of the secret where the validating value is generated/stored, e.g: "mysql-passwords-secret"
|
||||||
|
- field - String - Optional. Name of the field in the secret data, e.g: "mysql-password"
|
||||||
|
*/}}
|
||||||
|
{{- define "common.validations.values.multiple.empty" -}}
|
||||||
|
{{- range .required -}}
|
||||||
|
{{- include "common.validations.values.single.empty" (dict "valueKey" .valueKey "secret" .secret "field" .field "context" $.context) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Validate a value must not be empty.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
{{ include "common.validations.value.empty" (dict "valueKey" "mariadb.password" "secret" "secretName" "field" "my-password" "subchart" "subchart" "context" $) }}
|
||||||
|
|
||||||
|
Validate value params:
|
||||||
|
- valueKey - String - Required. The path to the validating value in the values.yaml, e.g: "mysql.password"
|
||||||
|
- secret - String - Optional. Name of the secret where the validating value is generated/stored, e.g: "mysql-passwords-secret"
|
||||||
|
- field - String - Optional. Name of the field in the secret data, e.g: "mysql-password"
|
||||||
|
- subchart - String - Optional - Name of the subchart that the validated password is part of.
|
||||||
|
*/}}
|
||||||
|
{{- define "common.validations.values.single.empty" -}}
|
||||||
|
{{- $value := include "common.utils.getValueFromKey" (dict "key" .valueKey "context" .context) }}
|
||||||
|
{{- $subchart := ternary "" (printf "%s." .subchart) (empty .subchart) }}
|
||||||
|
|
||||||
|
{{- if not $value -}}
|
||||||
|
{{- $varname := "my-value" -}}
|
||||||
|
{{- $getCurrentValue := "" -}}
|
||||||
|
{{- if and .secret .field -}}
|
||||||
|
{{- $varname = include "common.utils.fieldToEnvVar" . -}}
|
||||||
|
{{- $getCurrentValue = printf " To get the current value:\n\n %s\n" (include "common.utils.secret.getvalue" .) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- printf "\n '%s' must not be empty, please add '--set %s%s=$%s' to the command.%s" .valueKey $subchart .valueKey $varname $getCurrentValue -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
8
helm/redis/charts/common/values.yaml
Normal file
8
helm/redis/charts/common/values.yaml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright VMware, Inc.
|
||||||
|
# SPDX-License-Identifier: APACHE-2.0
|
||||||
|
|
||||||
|
## bitnami/common
|
||||||
|
## It is required by CI/CD tools and processes.
|
||||||
|
## @skip exampleValue
|
||||||
|
##
|
||||||
|
exampleValue: common-chart
|
||||||
191
helm/redis/templates/NOTES.txt
Normal file
191
helm/redis/templates/NOTES.txt
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
CHART NAME: {{ .Chart.Name }}
|
||||||
|
CHART VERSION: {{ .Chart.Version }}
|
||||||
|
APP VERSION: {{ .Chart.AppVersion }}
|
||||||
|
|
||||||
|
** Please be patient while the chart is being deployed **
|
||||||
|
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
The chart has been deployed in diagnostic mode. All probes have been disabled and the command has been overwritten with:
|
||||||
|
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 4 }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 4 }}
|
||||||
|
|
||||||
|
Get the list of pods by executing:
|
||||||
|
|
||||||
|
kubectl get pods --namespace {{ include "common.names.namespace" . }} -l app.kubernetes.io/instance={{ .Release.Name }}
|
||||||
|
|
||||||
|
Access the pod you want to debug by executing
|
||||||
|
|
||||||
|
kubectl exec --namespace {{ include "common.names.namespace" . }} -ti <NAME OF THE POD> -- bash
|
||||||
|
|
||||||
|
In order to replicate the container startup scripts execute this command:
|
||||||
|
|
||||||
|
For Redis:
|
||||||
|
|
||||||
|
/opt/bitnami/scripts/redis/entrypoint.sh /opt/bitnami/scripts/redis/run.sh
|
||||||
|
|
||||||
|
{{- if .Values.sentinel.enabled }}
|
||||||
|
|
||||||
|
For Redis Sentinel:
|
||||||
|
|
||||||
|
/opt/bitnami/scripts/redis-sentinel/entrypoint.sh /opt/bitnami/scripts/redis-sentinel/run.sh
|
||||||
|
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
|
||||||
|
{{- if contains .Values.master.service.type "LoadBalancer" }}
|
||||||
|
{{- if not .Values.auth.enabled }}
|
||||||
|
{{ if and (not .Values.networkPolicy.enabled) (.Values.networkPolicy.allowExternal) }}
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
WARNING
|
||||||
|
|
||||||
|
By specifying "master.service.type=LoadBalancer" and "auth.enabled=false" you have
|
||||||
|
most likely exposed the Redis® service externally without any authentication
|
||||||
|
mechanism.
|
||||||
|
|
||||||
|
For security reasons, we strongly suggest that you switch to "ClusterIP" or
|
||||||
|
"NodePort". As alternative, you can also switch to "auth.enabled=true"
|
||||||
|
providing a valid password on "password" parameter.
|
||||||
|
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if eq .Values.architecture "replication" }}
|
||||||
|
{{- if .Values.sentinel.enabled }}
|
||||||
|
|
||||||
|
Redis® can be accessed via port {{ .Values.sentinel.service.ports.redis }} on the following DNS name from within your cluster:
|
||||||
|
|
||||||
|
{{ template "common.names.fullname" . }}.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }} for read only operations
|
||||||
|
|
||||||
|
For read/write operations, first access the Redis® Sentinel cluster, which is available in port {{ .Values.sentinel.service.ports.sentinel }} using the same domain name above.
|
||||||
|
|
||||||
|
{{- else }}
|
||||||
|
|
||||||
|
Redis® can be accessed on the following DNS names from within your cluster:
|
||||||
|
|
||||||
|
{{ printf "%s-master.%s.svc.%s" (include "common.names.fullname" .) (include "common.names.namespace" . ) .Values.clusterDomain }} for read/write operations (port {{ .Values.master.service.ports.redis }})
|
||||||
|
{{ printf "%s-replicas.%s.svc.%s" (include "common.names.fullname" .) (include "common.names.namespace" . ) .Values.clusterDomain }} for read-only operations (port {{ .Values.replica.service.ports.redis }})
|
||||||
|
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
|
||||||
|
Redis® can be accessed via port {{ .Values.master.service.ports.redis }} on the following DNS name from within your cluster:
|
||||||
|
|
||||||
|
{{ template "common.names.fullname" . }}-master.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}
|
||||||
|
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{ if .Values.auth.enabled }}
|
||||||
|
|
||||||
|
To get your password run:
|
||||||
|
|
||||||
|
export REDIS_PASSWORD=$(kubectl get secret --namespace {{ include "common.names.namespace" . }} {{ template "redis.secretName" . }} -o jsonpath="{.data.redis-password}" | base64 -d)
|
||||||
|
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
To connect to your Redis® server:
|
||||||
|
|
||||||
|
1. Run a Redis® pod that you can use as a client:
|
||||||
|
|
||||||
|
kubectl run --namespace {{ include "common.names.namespace" . }} redis-client --restart='Never' {{ if .Values.auth.enabled }} --env REDIS_PASSWORD=$REDIS_PASSWORD {{ end }} --image {{ template "redis.image" . }} --command -- sleep infinity
|
||||||
|
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
|
||||||
|
Copy your TLS certificates to the pod:
|
||||||
|
|
||||||
|
kubectl cp --namespace {{ include "common.names.namespace" . }} /path/to/client.cert redis-client:/tmp/client.cert
|
||||||
|
kubectl cp --namespace {{ include "common.names.namespace" . }} /path/to/client.key redis-client:/tmp/client.key
|
||||||
|
kubectl cp --namespace {{ include "common.names.namespace" . }} /path/to/CA.cert redis-client:/tmp/CA.cert
|
||||||
|
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
Use the following command to attach to the pod:
|
||||||
|
|
||||||
|
kubectl exec --tty -i redis-client \
|
||||||
|
{{- if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}--labels="{{ template "common.names.fullname" . }}-client=true" \{{- end }}
|
||||||
|
--namespace {{ include "common.names.namespace" . }} -- bash
|
||||||
|
|
||||||
|
2. Connect using the Redis® CLI:
|
||||||
|
|
||||||
|
{{- if eq .Values.architecture "replication" }}
|
||||||
|
{{- if .Values.sentinel.enabled }}
|
||||||
|
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h {{ template "common.names.fullname" . }} -p {{ .Values.sentinel.service.ports.redis }}{{ if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }} # Read only operations
|
||||||
|
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h {{ template "common.names.fullname" . }} -p {{ .Values.sentinel.service.ports.sentinel }}{{ if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }} # Sentinel access
|
||||||
|
{{- else }}
|
||||||
|
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h {{ printf "%s-master" (include "common.names.fullname" .) }}{{ if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||||
|
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h {{ printf "%s-replicas" (include "common.names.fullname" .) }}{{ if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h {{ template "common.names.fullname" . }}-master{{ if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if and (.Values.networkPolicy.enabled) (not .Values.networkPolicy.allowExternal) }}
|
||||||
|
|
||||||
|
Note: Since NetworkPolicy is enabled, only pods with label {{ template "common.names.fullname" . }}-client=true" will be able to connect to redis.
|
||||||
|
|
||||||
|
{{- else }}
|
||||||
|
|
||||||
|
To connect to your database from outside the cluster execute the following commands:
|
||||||
|
|
||||||
|
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled }}
|
||||||
|
{{- if contains "NodePort" .Values.sentinel.service.type }}
|
||||||
|
|
||||||
|
export NODE_IP=$(kubectl get nodes --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||||
|
export NODE_PORT=$(kubectl get --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "common.names.fullname" . }})
|
||||||
|
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h $NODE_IP -p $NODE_PORT {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||||
|
|
||||||
|
{{- else if contains "LoadBalancer" .Values.sentinel.service.type }}
|
||||||
|
|
||||||
|
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||||
|
Watch the status with: 'kubectl get svc --namespace {{ include "common.names.namespace" . }} -w {{ template "common.names.fullname" . }}'
|
||||||
|
|
||||||
|
export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.names.namespace" . }} {{ template "common.names.fullname" . }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
|
||||||
|
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h $SERVICE_IP -p {{ .Values.sentinel.service.ports.redis }} {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||||
|
|
||||||
|
{{- else if contains "ClusterIP" .Values.sentinel.service.type }}
|
||||||
|
|
||||||
|
kubectl port-forward --namespace {{ include "common.names.namespace" . }} svc/{{ template "common.names.fullname" . }} {{ .Values.sentinel.service.ports.redis }}:{{ .Values.sentinel.service.ports.redis }} &
|
||||||
|
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h 127.0.0.1 -p {{ .Values.sentinel.service.ports.redis }} {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||||
|
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
{{- if contains "NodePort" .Values.master.service.type }}
|
||||||
|
|
||||||
|
export NODE_IP=$(kubectl get nodes --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||||
|
export NODE_PORT=$(kubectl get --namespace {{ include "common.names.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ printf "%s-master" (include "common.names.fullname" .) }})
|
||||||
|
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h $NODE_IP -p $NODE_PORT {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||||
|
|
||||||
|
{{- else if contains "LoadBalancer" .Values.master.service.type }}
|
||||||
|
|
||||||
|
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||||
|
Watch the status with: 'kubectl get svc --namespace {{ include "common.names.namespace" . }} -w {{ template "common.names.fullname" . }}'
|
||||||
|
|
||||||
|
export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.names.namespace" . }} {{ printf "%s-master" (include "common.names.fullname" .) }} --template "{{ "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}" }}")
|
||||||
|
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h $SERVICE_IP -p {{ .Values.master.service.ports.redis }} {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||||
|
|
||||||
|
{{- else if contains "ClusterIP" .Values.master.service.type }}
|
||||||
|
|
||||||
|
kubectl port-forward --namespace {{ include "common.names.namespace" . }} svc/{{ printf "%s-master" (include "common.names.fullname" .) }} {{ .Values.master.service.ports.redis }}:{{ .Values.master.service.ports.redis }} &
|
||||||
|
{{ if .Values.auth.enabled }}REDISCLI_AUTH="$REDIS_PASSWORD" {{ end }}redis-cli -h 127.0.0.1 -p {{ .Values.master.service.ports.redis }} {{- if .Values.tls.enabled }} --tls --cert /tmp/client.cert --key /tmp/client.key --cacert /tmp/CA.cert{{ end }}
|
||||||
|
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- include "redis.checkRollingTags" . }}
|
||||||
|
{{- include "common.warnings.rollingTag" .Values.volumePermissions.image }}
|
||||||
|
{{- include "common.warnings.rollingTag" .Values.sysctl.image }}
|
||||||
|
{{- include "redis.validateValues" . }}
|
||||||
|
|
||||||
|
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled (eq .Values.sentinel.service.type "NodePort") (not .Release.IsUpgrade ) }}
|
||||||
|
{{- if $.Values.sentinel.service.nodePorts.sentinel }}
|
||||||
|
No need to upgrade, ports and nodeports have been set from values
|
||||||
|
{{- else }}
|
||||||
|
#!#!#!#!#!#!#!# IMPORTANT #!#!#!#!#!#!#!#
|
||||||
|
YOU NEED TO PERFORM AN UPGRADE FOR THE SERVICES AND WORKLOAD TO BE CREATED
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
328
helm/redis/templates/_helpers.tpl
Normal file
328
helm/redis/templates/_helpers.tpl
Normal file
@ -0,0 +1,328 @@
|
|||||||
|
{{/*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{/* vim: set filetype=mustache: */}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the proper Redis image name
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.image" -}}
|
||||||
|
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the proper Redis Sentinel image name
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.sentinel.image" -}}
|
||||||
|
{{ include "common.images.image" (dict "imageRoot" .Values.sentinel.image "global" .Values.global) }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the proper image name (for the metrics image)
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.metrics.image" -}}
|
||||||
|
{{ include "common.images.image" (dict "imageRoot" .Values.metrics.image "global" .Values.global) }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the proper image name (for the init container volume-permissions image)
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.volumePermissions.image" -}}
|
||||||
|
{{ include "common.images.image" (dict "imageRoot" .Values.volumePermissions.image "global" .Values.global) }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return sysctl image
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.sysctl.image" -}}
|
||||||
|
{{ include "common.images.image" (dict "imageRoot" .Values.sysctl.image "global" .Values.global) }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the proper Docker Image Registry Secret Names
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.imagePullSecrets" -}}
|
||||||
|
{{- include "common.images.renderPullSecrets" (dict "images" (list .Values.image .Values.sentinel.image .Values.metrics.image .Values.volumePermissions.image .Values.sysctl.image) "context" $) -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiVersion for networkpolicy.
|
||||||
|
*/}}
|
||||||
|
{{- define "networkPolicy.apiVersion" -}}
|
||||||
|
{{- if semverCompare ">=1.4-0, <1.7-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||||
|
{{- print "extensions/v1beta1" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "networking.k8s.io/v1" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the appropriate apiGroup for PodSecurityPolicy.
|
||||||
|
*/}}
|
||||||
|
{{- define "podSecurityPolicy.apiGroup" -}}
|
||||||
|
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||||
|
{{- print "policy" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- print "extensions" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return true if a TLS secret object should be created
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.createTlsSecret" -}}
|
||||||
|
{{- if and .Values.tls.enabled .Values.tls.autoGenerated (and (not .Values.tls.existingSecret) (not .Values.tls.certificatesSecret)) }}
|
||||||
|
{{- true -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the secret containing Redis TLS certificates
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.tlsSecretName" -}}
|
||||||
|
{{- $secretName := coalesce .Values.tls.existingSecret .Values.tls.certificatesSecret -}}
|
||||||
|
{{- if $secretName -}}
|
||||||
|
{{- printf "%s" (tpl $secretName $) -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%s-crt" (include "common.names.fullname" .) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the path to the cert file.
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.tlsCert" -}}
|
||||||
|
{{- if (include "redis.createTlsSecret" . ) -}}
|
||||||
|
{{- printf "/opt/bitnami/redis/certs/%s" "tls.crt" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- required "Certificate filename is required when TLS in enabled" .Values.tls.certFilename | printf "/opt/bitnami/redis/certs/%s" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the path to the cert key file.
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.tlsCertKey" -}}
|
||||||
|
{{- if (include "redis.createTlsSecret" . ) -}}
|
||||||
|
{{- printf "/opt/bitnami/redis/certs/%s" "tls.key" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- required "Certificate Key filename is required when TLS in enabled" .Values.tls.certKeyFilename | printf "/opt/bitnami/redis/certs/%s" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the path to the CA cert file.
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.tlsCACert" -}}
|
||||||
|
{{- if (include "redis.createTlsSecret" . ) -}}
|
||||||
|
{{- printf "/opt/bitnami/redis/certs/%s" "ca.crt" -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- required "Certificate CA filename is required when TLS in enabled" .Values.tls.certCAFilename | printf "/opt/bitnami/redis/certs/%s" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the path to the DH params file.
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.tlsDHParams" -}}
|
||||||
|
{{- if .Values.tls.dhParamsFilename -}}
|
||||||
|
{{- printf "/opt/bitnami/redis/certs/%s" .Values.tls.dhParamsFilename -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Create the name of the shared service account to use
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.serviceAccountName" -}}
|
||||||
|
{{- if .Values.serviceAccount.create -}}
|
||||||
|
{{ default (include "common.names.fullname" .) .Values.serviceAccount.name }}
|
||||||
|
{{- else -}}
|
||||||
|
{{ default "default" .Values.serviceAccount.name }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Create the name of the master service account to use
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.masterServiceAccountName" -}}
|
||||||
|
{{- if .Values.master.serviceAccount.create -}}
|
||||||
|
{{ default (printf "%s-master" (include "common.names.fullname" .)) .Values.master.serviceAccount.name }}
|
||||||
|
{{- else -}}
|
||||||
|
{{- if .Values.serviceAccount.create -}}
|
||||||
|
{{ template "redis.serviceAccountName" . }}
|
||||||
|
{{- else -}}
|
||||||
|
{{ default "default" .Values.master.serviceAccount.name }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Create the name of the replicas service account to use
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.replicaServiceAccountName" -}}
|
||||||
|
{{- if .Values.replica.serviceAccount.create -}}
|
||||||
|
{{ default (printf "%s-replica" (include "common.names.fullname" .)) .Values.replica.serviceAccount.name }}
|
||||||
|
{{- else -}}
|
||||||
|
{{- if .Values.serviceAccount.create -}}
|
||||||
|
{{ template "redis.serviceAccountName" . }}
|
||||||
|
{{- else -}}
|
||||||
|
{{ default "default" .Values.replica.serviceAccount.name }}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return the configuration configmap name
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.configmapName" -}}
|
||||||
|
{{- if .Values.existingConfigmap -}}
|
||||||
|
{{- printf "%s" (tpl .Values.existingConfigmap $) -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%s-configuration" (include "common.names.fullname" .) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return true if a configmap object should be created
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.createConfigmap" -}}
|
||||||
|
{{- if empty .Values.existingConfigmap }}
|
||||||
|
{{- true -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Get the password secret.
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.secretName" -}}
|
||||||
|
{{- if .Values.auth.existingSecret -}}
|
||||||
|
{{- printf "%s" (tpl .Values.auth.existingSecret $) -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "%s" (include "common.names.fullname" .) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Get the password key to be retrieved from Redis® secret.
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.secretPasswordKey" -}}
|
||||||
|
{{- if and .Values.auth.existingSecret .Values.auth.existingSecretPasswordKey -}}
|
||||||
|
{{- printf "%s" (tpl .Values.auth.existingSecretPasswordKey $) -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- printf "redis-password" -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Returns the available value for certain key in an existing secret (if it exists),
|
||||||
|
otherwise it generates a random value.
|
||||||
|
*/}}
|
||||||
|
{{- define "getValueFromSecret" }}
|
||||||
|
{{- $len := (default 16 .Length) | int -}}
|
||||||
|
{{- $obj := (lookup "v1" "Secret" .Namespace .Name).data -}}
|
||||||
|
{{- if $obj }}
|
||||||
|
{{- index $obj .Key | b64dec -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- randAlphaNum $len -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Return Redis® password
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.password" -}}
|
||||||
|
{{- if or .Values.auth.enabled .Values.global.redis.password }}
|
||||||
|
{{- if not (empty .Values.global.redis.password) }}
|
||||||
|
{{- .Values.global.redis.password -}}
|
||||||
|
{{- else if not (empty .Values.auth.password) -}}
|
||||||
|
{{- .Values.auth.password -}}
|
||||||
|
{{- else -}}
|
||||||
|
{{- include "getValueFromSecret" (dict "Namespace" (include "common.names.namespace" .) "Name" (include "redis.secretName" .) "Length" 10 "Key" (include "redis.secretPasswordKey" .)) -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{/* Check if there are rolling tags in the images */}}
|
||||||
|
{{- define "redis.checkRollingTags" -}}
|
||||||
|
{{- include "common.warnings.rollingTag" .Values.image }}
|
||||||
|
{{- include "common.warnings.rollingTag" .Values.sentinel.image }}
|
||||||
|
{{- include "common.warnings.rollingTag" .Values.metrics.image }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Compile all warnings into a single message, and call fail.
|
||||||
|
*/}}
|
||||||
|
{{- define "redis.validateValues" -}}
|
||||||
|
{{- $messages := list -}}
|
||||||
|
{{- $messages := append $messages (include "redis.validateValues.topologySpreadConstraints" .) -}}
|
||||||
|
{{- $messages := append $messages (include "redis.validateValues.architecture" .) -}}
|
||||||
|
{{- $messages := append $messages (include "redis.validateValues.podSecurityPolicy.create" .) -}}
|
||||||
|
{{- $messages := append $messages (include "redis.validateValues.tls" .) -}}
|
||||||
|
{{- $messages := without $messages "" -}}
|
||||||
|
{{- $message := join "\n" $messages -}}
|
||||||
|
|
||||||
|
{{- if $message -}}
|
||||||
|
{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/* Validate values of Redis® - spreadConstrainsts K8s version */}}
|
||||||
|
{{- define "redis.validateValues.topologySpreadConstraints" -}}
|
||||||
|
{{- if and (semverCompare "<1.16-0" .Capabilities.KubeVersion.GitVersion) .Values.replica.topologySpreadConstraints -}}
|
||||||
|
redis: topologySpreadConstraints
|
||||||
|
Pod Topology Spread Constraints are only available on K8s >= 1.16
|
||||||
|
Find more information at https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/* Validate values of Redis® - must provide a valid architecture */}}
|
||||||
|
{{- define "redis.validateValues.architecture" -}}
|
||||||
|
{{- if and (ne .Values.architecture "standalone") (ne .Values.architecture "replication") -}}
|
||||||
|
redis: architecture
|
||||||
|
Invalid architecture selected. Valid values are "standalone" and
|
||||||
|
"replication". Please set a valid architecture (--set architecture="xxxx")
|
||||||
|
{{- end -}}
|
||||||
|
{{- if and .Values.sentinel.enabled (not (eq .Values.architecture "replication")) }}
|
||||||
|
redis: architecture
|
||||||
|
Using redis sentinel on standalone mode is not supported.
|
||||||
|
To deploy redis sentinel, please select the "replication" mode
|
||||||
|
(--set "architecture=replication,sentinel.enabled=true")
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/* Validate values of Redis® - PodSecurityPolicy create */}}
|
||||||
|
{{- define "redis.validateValues.podSecurityPolicy.create" -}}
|
||||||
|
{{- if and .Values.podSecurityPolicy.create (not .Values.podSecurityPolicy.enabled) }}
|
||||||
|
redis: podSecurityPolicy.create
|
||||||
|
In order to create PodSecurityPolicy, you also need to enable
|
||||||
|
podSecurityPolicy.enabled field
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/* Validate values of Redis® - TLS enabled */}}
|
||||||
|
{{- define "redis.validateValues.tls" -}}
|
||||||
|
{{- if and .Values.tls.enabled (not .Values.tls.autoGenerated) (not .Values.tls.existingSecret) (not .Values.tls.certificatesSecret) }}
|
||||||
|
redis: tls.enabled
|
||||||
|
In order to enable TLS, you also need to provide
|
||||||
|
an existing secret containing the TLS certificates or
|
||||||
|
enable auto-generated certificates.
|
||||||
|
{{- end -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/* Define the suffix utilized for external-dns */}}
|
||||||
|
{{- define "redis.externalDNS.suffix" -}}
|
||||||
|
{{ printf "%s.%s" (include "common.names.fullname" .) .Values.useExternalDNS.suffix }}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/* Compile all annotations utilized for external-dns */}}
|
||||||
|
{{- define "redis.externalDNS.annotations" -}}
|
||||||
|
{{- if and .Values.useExternalDNS.enabled .Values.useExternalDNS.annotationKey }}
|
||||||
|
{{ .Values.useExternalDNS.annotationKey }}hostname: {{ include "redis.externalDNS.suffix" . }}
|
||||||
|
{{- range $key, $val := .Values.useExternalDNS.additionalAnnotations }}
|
||||||
|
{{ $.Values.useExternalDNS.annotationKey }}{{ $key }}: {{ $val | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
61
helm/redis/templates/configmap.yaml
Normal file
61
helm/redis/templates/configmap.yaml
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if (include "redis.createConfigmap" .) }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-configuration" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
data:
|
||||||
|
redis.conf: |-
|
||||||
|
# User-supplied common configuration:
|
||||||
|
{{- if .Values.commonConfiguration }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.commonConfiguration "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
# End of common configuration
|
||||||
|
master.conf: |-
|
||||||
|
dir {{ .Values.master.persistence.path }}
|
||||||
|
# User-supplied master configuration:
|
||||||
|
{{- if .Values.master.configuration }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.master.configuration "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.disableCommands }}
|
||||||
|
{{- range .Values.master.disableCommands }}
|
||||||
|
rename-command {{ . }} ""
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
# End of master configuration
|
||||||
|
replica.conf: |-
|
||||||
|
dir {{ .Values.replica.persistence.path }}
|
||||||
|
# User-supplied replica configuration:
|
||||||
|
{{- if .Values.replica.configuration }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.configuration "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.disableCommands }}
|
||||||
|
{{- range .Values.replica.disableCommands }}
|
||||||
|
rename-command {{ . }} ""
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
# End of replica configuration
|
||||||
|
{{- if .Values.sentinel.enabled }}
|
||||||
|
sentinel.conf: |-
|
||||||
|
dir "/tmp"
|
||||||
|
port {{ .Values.sentinel.containerPorts.sentinel }}
|
||||||
|
sentinel monitor {{ .Values.sentinel.masterSet }} {{ template "common.names.fullname" . }}-node-0.{{ template "common.names.fullname" . }}-headless.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }} {{ .Values.sentinel.service.ports.redis }} {{ .Values.sentinel.quorum }}
|
||||||
|
sentinel down-after-milliseconds {{ .Values.sentinel.masterSet }} {{ .Values.sentinel.downAfterMilliseconds }}
|
||||||
|
sentinel failover-timeout {{ .Values.sentinel.masterSet }} {{ .Values.sentinel.failoverTimeout }}
|
||||||
|
sentinel parallel-syncs {{ .Values.sentinel.masterSet }} {{ .Values.sentinel.parallelSyncs }}
|
||||||
|
# User-supplied sentinel configuration:
|
||||||
|
{{- if .Values.sentinel.configuration }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.configuration "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
# End of sentinel configuration
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
9
helm/redis/templates/extra-list.yaml
Normal file
9
helm/redis/templates/extra-list.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- range .Values.extraDeploy }}
|
||||||
|
---
|
||||||
|
{{ include "common.tplvalues.render" (dict "value" . "context" $) }}
|
||||||
|
{{- end }}
|
||||||
33
helm/redis/templates/headless-svc.yaml
Normal file
33
helm/redis/templates/headless-svc.yaml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-headless" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
annotations:
|
||||||
|
{{- if or .Values.sentinel.service.headless.annotations .Values.commonAnnotations }}
|
||||||
|
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.sentinel.service.headless.annotations .Values.commonAnnotations ) "context" . ) }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- include "redis.externalDNS.annotations" . | nindent 4 }}
|
||||||
|
spec:
|
||||||
|
type: ClusterIP
|
||||||
|
clusterIP: None
|
||||||
|
{{- if .Values.sentinel.enabled }}
|
||||||
|
publishNotReadyAddresses: true
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: tcp-redis
|
||||||
|
port: {{ if .Values.sentinel.enabled }}{{ .Values.sentinel.service.ports.redis }}{{ else }}{{ .Values.master.service.ports.redis }}{{ end }}
|
||||||
|
targetPort: redis
|
||||||
|
{{- if .Values.sentinel.enabled }}
|
||||||
|
- name: tcp-sentinel
|
||||||
|
port: {{ .Values.sentinel.service.ports.sentinel }}
|
||||||
|
targetPort: redis-sentinel
|
||||||
|
{{- end }}
|
||||||
|
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
194
helm/redis/templates/health-configmap.yaml
Normal file
194
helm/redis/templates/health-configmap.yaml
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-health" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
data:
|
||||||
|
ping_readiness_local.sh: |-
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||||
|
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
|
||||||
|
response=$(
|
||||||
|
timeout -s 15 $1 \
|
||||||
|
redis-cli \
|
||||||
|
-h localhost \
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
-p $REDIS_TLS_PORT \
|
||||||
|
--tls \
|
||||||
|
--cacert {{ template "redis.tlsCACert" . }} \
|
||||||
|
{{- if .Values.tls.authClients }}
|
||||||
|
--cert {{ template "redis.tlsCert" . }} \
|
||||||
|
--key {{ template "redis.tlsCertKey" . }} \
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
-p $REDIS_PORT \
|
||||||
|
{{- end }}
|
||||||
|
ping
|
||||||
|
)
|
||||||
|
if [ "$?" -eq "124" ]; then
|
||||||
|
echo "Timed out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$response" != "PONG" ]; then
|
||||||
|
echo "$response"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
ping_liveness_local.sh: |-
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||||
|
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
|
||||||
|
response=$(
|
||||||
|
timeout -s 15 $1 \
|
||||||
|
redis-cli \
|
||||||
|
-h localhost \
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
-p $REDIS_TLS_PORT \
|
||||||
|
--tls \
|
||||||
|
--cacert {{ template "redis.tlsCACert" . }} \
|
||||||
|
{{- if .Values.tls.authClients }}
|
||||||
|
--cert {{ template "redis.tlsCert" . }} \
|
||||||
|
--key {{ template "redis.tlsCertKey" . }} \
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
-p $REDIS_PORT \
|
||||||
|
{{- end }}
|
||||||
|
ping
|
||||||
|
)
|
||||||
|
if [ "$?" -eq "124" ]; then
|
||||||
|
echo "Timed out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
responseFirstWord=$(echo $response | head -n1 | awk '{print $1;}')
|
||||||
|
if [ "$response" != "PONG" ] && [ "$responseFirstWord" != "LOADING" ] && [ "$responseFirstWord" != "MASTERDOWN" ]; then
|
||||||
|
echo "$response"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
{{- if .Values.sentinel.enabled }}
|
||||||
|
ping_sentinel.sh: |-
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
{{- if .Values.auth.sentinel }}
|
||||||
|
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||||
|
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
|
||||||
|
{{- end }}
|
||||||
|
response=$(
|
||||||
|
timeout -s 15 $1 \
|
||||||
|
redis-cli \
|
||||||
|
-h localhost \
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
-p $REDIS_SENTINEL_TLS_PORT_NUMBER \
|
||||||
|
--tls \
|
||||||
|
--cacert "$REDIS_SENTINEL_TLS_CA_FILE" \
|
||||||
|
{{- if .Values.tls.authClients }}
|
||||||
|
--cert "$REDIS_SENTINEL_TLS_CERT_FILE" \
|
||||||
|
--key "$REDIS_SENTINEL_TLS_KEY_FILE" \
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
-p $REDIS_SENTINEL_PORT \
|
||||||
|
{{- end }}
|
||||||
|
ping
|
||||||
|
)
|
||||||
|
if [ "$?" -eq "124" ]; then
|
||||||
|
echo "Timed out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$response" != "PONG" ]; then
|
||||||
|
echo "$response"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
parse_sentinels.awk: |-
|
||||||
|
/ip/ {FOUND_IP=1}
|
||||||
|
/port/ {FOUND_PORT=1}
|
||||||
|
/runid/ {FOUND_RUNID=1}
|
||||||
|
!/ip|port|runid/ {
|
||||||
|
if (FOUND_IP==1) {
|
||||||
|
IP=$1; FOUND_IP=0;
|
||||||
|
}
|
||||||
|
else if (FOUND_PORT==1) {
|
||||||
|
PORT=$1;
|
||||||
|
FOUND_PORT=0;
|
||||||
|
} else if (FOUND_RUNID==1) {
|
||||||
|
printf "\nsentinel known-sentinel {{ .Values.sentinel.masterSet }} %s %s %s", IP, PORT, $0; FOUND_RUNID=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{{- end }}
|
||||||
|
ping_readiness_master.sh: |-
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
[[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
|
||||||
|
[[ -n "$REDIS_MASTER_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_MASTER_PASSWORD"
|
||||||
|
response=$(
|
||||||
|
timeout -s 15 $1 \
|
||||||
|
redis-cli \
|
||||||
|
-h $REDIS_MASTER_HOST \
|
||||||
|
-p $REDIS_MASTER_PORT_NUMBER \
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
--tls \
|
||||||
|
--cacert {{ template "redis.tlsCACert" . }} \
|
||||||
|
{{- if .Values.tls.authClients }}
|
||||||
|
--cert {{ template "redis.tlsCert" . }} \
|
||||||
|
--key {{ template "redis.tlsCertKey" . }} \
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
ping
|
||||||
|
)
|
||||||
|
if [ "$?" -eq "124" ]; then
|
||||||
|
echo "Timed out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ "$response" != "PONG" ]; then
|
||||||
|
echo "$response"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
ping_liveness_master.sh: |-
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
[[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
|
||||||
|
[[ -n "$REDIS_MASTER_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_MASTER_PASSWORD"
|
||||||
|
response=$(
|
||||||
|
timeout -s 15 $1 \
|
||||||
|
redis-cli \
|
||||||
|
-h $REDIS_MASTER_HOST \
|
||||||
|
-p $REDIS_MASTER_PORT_NUMBER \
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
--tls \
|
||||||
|
--cacert {{ template "redis.tlsCACert" . }} \
|
||||||
|
{{- if .Values.tls.authClients }}
|
||||||
|
--cert {{ template "redis.tlsCert" . }} \
|
||||||
|
--key {{ template "redis.tlsCertKey" . }} \
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
ping
|
||||||
|
)
|
||||||
|
if [ "$?" -eq "124" ]; then
|
||||||
|
echo "Timed out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
responseFirstWord=$(echo $response | head -n1 | awk '{print $1;}')
|
||||||
|
if [ "$response" != "PONG" ] && [ "$responseFirstWord" != "LOADING" ]; then
|
||||||
|
echo "$response"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
ping_readiness_local_and_master.sh: |-
|
||||||
|
script_dir="$(dirname "$0")"
|
||||||
|
exit_status=0
|
||||||
|
"$script_dir/ping_readiness_local.sh" $1 || exit_status=$?
|
||||||
|
"$script_dir/ping_readiness_master.sh" $1 || exit_status=$?
|
||||||
|
exit $exit_status
|
||||||
|
ping_liveness_local_and_master.sh: |-
|
||||||
|
script_dir="$(dirname "$0")"
|
||||||
|
exit_status=0
|
||||||
|
"$script_dir/ping_liveness_local.sh" $1 || exit_status=$?
|
||||||
|
"$script_dir/ping_liveness_master.sh" $1 || exit_status=$?
|
||||||
|
exit $exit_status
|
||||||
534
helm/redis/templates/master/application.yaml
Normal file
534
helm/redis/templates/master/application.yaml
Normal file
@ -0,0 +1,534 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if gt (int64 .Values.master.count) 0 -}}
|
||||||
|
{{- if or (not (eq .Values.architecture "replication")) (not .Values.sentinel.enabled) }}
|
||||||
|
apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
|
||||||
|
kind: {{ .Values.master.kind }}
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-master" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: master
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
{{- if not (eq .Values.master.kind "DaemonSet") }}
|
||||||
|
replicas: {{ .Values.master.count }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.master.podLabels .Values.commonLabels ) "context" . ) }}
|
||||||
|
selector:
|
||||||
|
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
|
||||||
|
app.kubernetes.io/component: master
|
||||||
|
{{- if (eq .Values.master.kind "StatefulSet") }}
|
||||||
|
serviceName: {{ printf "%s-headless" (include "common.names.fullname" .) }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.updateStrategy }}
|
||||||
|
{{- if (eq .Values.master.kind "Deployment") }}
|
||||||
|
strategy: {{- toYaml .Values.master.updateStrategy | nindent 4 }}
|
||||||
|
{{- else }}
|
||||||
|
updateStrategy: {{- toYaml .Values.master.updateStrategy | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and .Values.master.minReadySeconds (semverCompare ">= 1.23-0" (include "common.capabilities.kubeVersion" .)) }}
|
||||||
|
minReadySeconds: {{ .Values.master.minReadySeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
|
||||||
|
app.kubernetes.io/component: master
|
||||||
|
{{- if and .Values.metrics.enabled .Values.metrics.podLabels }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podLabels "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
annotations:
|
||||||
|
{{- if (include "redis.createConfigmap" .) }}
|
||||||
|
checksum/configmap: {{ pick ( include (print $.Template.BasePath "/configmap.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
{{- end }}
|
||||||
|
checksum/health: {{ pick ( include (print $.Template.BasePath "/health-configmap.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
checksum/scripts: {{ pick ( include (print $.Template.BasePath "/scripts-configmap.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
checksum/secret: {{ pick ( include (print $.Template.BasePath "/secret.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
{{- if .Values.master.podAnnotations }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.master.podAnnotations "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
{{- include "redis.imagePullSecrets" . | nindent 6 }}
|
||||||
|
{{- if .Values.master.hostAliases }}
|
||||||
|
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.master.hostAliases "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.podSecurityContext.enabled }}
|
||||||
|
securityContext: {{- omit .Values.master.podSecurityContext "enabled" | toYaml | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
serviceAccountName: {{ template "redis.masterServiceAccountName" . }}
|
||||||
|
automountServiceAccountToken: {{ .Values.master.automountServiceAccountToken }}
|
||||||
|
{{- if .Values.master.priorityClassName }}
|
||||||
|
priorityClassName: {{ .Values.master.priorityClassName | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.affinity }}
|
||||||
|
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.master.affinity "context" $) | nindent 8 }}
|
||||||
|
{{- else }}
|
||||||
|
affinity:
|
||||||
|
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.master.podAffinityPreset "component" "master" "customLabels" $podLabels "context" $) | nindent 10 }}
|
||||||
|
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.master.podAntiAffinityPreset "component" "master" "customLabels" $podLabels "context" $) | nindent 10 }}
|
||||||
|
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.master.nodeAffinityPreset.type "key" .Values.master.nodeAffinityPreset.key "values" .Values.master.nodeAffinityPreset.values) | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.nodeSelector }}
|
||||||
|
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.master.nodeSelector "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.tolerations }}
|
||||||
|
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.master.tolerations "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.topologySpreadConstraints }}
|
||||||
|
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.master.topologySpreadConstraints "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.shareProcessNamespace }}
|
||||||
|
shareProcessNamespace: {{ .Values.master.shareProcessNamespace }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.schedulerName }}
|
||||||
|
schedulerName: {{ .Values.master.schedulerName | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.dnsPolicy }}
|
||||||
|
dnsPolicy: {{ .Values.master.dnsPolicy }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.dnsConfig }}
|
||||||
|
dnsConfig: {{- include "common.tplvalues.render" (dict "value" .Values.master.dnsConfig "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
enableServiceLinks: {{ .Values.master.enableServiceLinks }}
|
||||||
|
terminationGracePeriodSeconds: {{ .Values.master.terminationGracePeriodSeconds }}
|
||||||
|
containers:
|
||||||
|
- name: redis
|
||||||
|
image: {{ template "redis.image" . }}
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
||||||
|
{{- if .Values.master.lifecycleHooks }}
|
||||||
|
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.master.lifecycleHooks "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.containerSecurityContext.enabled }}
|
||||||
|
securityContext: {{- omit .Values.master.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.master.command }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.master.command "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.master.args }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.master.args "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
args:
|
||||||
|
- -c
|
||||||
|
- /opt/bitnami/scripts/start-scripts/start-master.sh
|
||||||
|
{{- end }}
|
||||||
|
env:
|
||||||
|
- name: BITNAMI_DEBUG
|
||||||
|
value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
|
||||||
|
- name: REDIS_REPLICATION_MODE
|
||||||
|
value: master
|
||||||
|
- name: ALLOW_EMPTY_PASSWORD
|
||||||
|
value: {{ ternary "no" "yes" .Values.auth.enabled | quote }}
|
||||||
|
{{- if .Values.auth.enabled }}
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: REDIS_PASSWORD_FILE
|
||||||
|
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||||
|
{{- else }}
|
||||||
|
- name: REDIS_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ template "redis.secretName" . }}
|
||||||
|
key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
- name: REDIS_TLS_ENABLED
|
||||||
|
value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: REDIS_TLS_PORT
|
||||||
|
value: {{ .Values.master.containerPorts.redis | quote }}
|
||||||
|
- name: REDIS_TLS_AUTH_CLIENTS
|
||||||
|
value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
|
||||||
|
- name: REDIS_TLS_CERT_FILE
|
||||||
|
value: {{ template "redis.tlsCert" . }}
|
||||||
|
- name: REDIS_TLS_KEY_FILE
|
||||||
|
value: {{ template "redis.tlsCertKey" . }}
|
||||||
|
- name: REDIS_TLS_CA_FILE
|
||||||
|
value: {{ template "redis.tlsCACert" . }}
|
||||||
|
{{- if .Values.tls.dhParamsFilename }}
|
||||||
|
- name: REDIS_TLS_DH_PARAMS_FILE
|
||||||
|
value: {{ template "redis.tlsDHParams" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
- name: REDIS_PORT
|
||||||
|
value: {{ .Values.master.containerPorts.redis | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.extraEnvVars }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.master.extraEnvVars "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if or .Values.master.extraEnvVarsCM .Values.master.extraEnvVarsSecret }}
|
||||||
|
envFrom:
|
||||||
|
{{- if .Values.master.extraEnvVarsCM }}
|
||||||
|
- configMapRef:
|
||||||
|
name: {{ .Values.master.extraEnvVarsCM }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.extraEnvVarsSecret }}
|
||||||
|
- secretRef:
|
||||||
|
name: {{ .Values.master.extraEnvVarsSecret }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: redis
|
||||||
|
containerPort: {{ .Values.master.containerPorts.redis }}
|
||||||
|
{{- if not .Values.diagnosticMode.enabled }}
|
||||||
|
{{- if .Values.master.customStartupProbe }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.master.customStartupProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.master.startupProbe.enabled }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.master.startupProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
tcpSocket:
|
||||||
|
port: redis
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.customLivenessProbe }}
|
||||||
|
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.master.customLivenessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.master.livenessProbe.enabled }}
|
||||||
|
livenessProbe:
|
||||||
|
initialDelaySeconds: {{ .Values.master.livenessProbe.initialDelaySeconds }}
|
||||||
|
periodSeconds: {{ .Values.master.livenessProbe.periodSeconds }}
|
||||||
|
# One second longer than command timeout should prevent generation of zombie processes.
|
||||||
|
timeoutSeconds: {{ add1 .Values.master.livenessProbe.timeoutSeconds }}
|
||||||
|
successThreshold: {{ .Values.master.livenessProbe.successThreshold }}
|
||||||
|
failureThreshold: {{ .Values.master.livenessProbe.failureThreshold }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- /health/ping_liveness_local.sh {{ .Values.master.livenessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.customReadinessProbe }}
|
||||||
|
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.master.customReadinessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.master.readinessProbe.enabled }}
|
||||||
|
readinessProbe:
|
||||||
|
initialDelaySeconds: {{ .Values.master.readinessProbe.initialDelaySeconds }}
|
||||||
|
periodSeconds: {{ .Values.master.readinessProbe.periodSeconds }}
|
||||||
|
timeoutSeconds: {{ add1 .Values.master.readinessProbe.timeoutSeconds }}
|
||||||
|
successThreshold: {{ .Values.master.readinessProbe.successThreshold }}
|
||||||
|
failureThreshold: {{ .Values.master.readinessProbe.failureThreshold }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- /health/ping_readiness_local.sh {{ .Values.master.readinessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.resources }}
|
||||||
|
resources: {{- toYaml .Values.master.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: start-scripts
|
||||||
|
mountPath: /opt/bitnami/scripts/start-scripts
|
||||||
|
- name: health
|
||||||
|
mountPath: /health
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: redis-password
|
||||||
|
mountPath: /opt/bitnami/redis/secrets/
|
||||||
|
{{- end }}
|
||||||
|
- name: redis-data
|
||||||
|
mountPath: {{ .Values.master.persistence.path }}
|
||||||
|
{{- if .Values.master.persistence.subPath }}
|
||||||
|
subPath: {{ .Values.master.persistence.subPath }}
|
||||||
|
{{- else if .Values.master.persistence.subPathExpr }}
|
||||||
|
subPathExpr: {{ .Values.master.persistence.subPathExpr }}
|
||||||
|
{{- end }}
|
||||||
|
- name: config
|
||||||
|
mountPath: /opt/bitnami/redis/mounted-etc
|
||||||
|
- name: redis-tmp-conf
|
||||||
|
mountPath: /opt/bitnami/redis/etc/
|
||||||
|
- name: tmp
|
||||||
|
mountPath: /tmp
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: redis-certificates
|
||||||
|
mountPath: /opt/bitnami/redis/certs
|
||||||
|
readOnly: true
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.extraVolumeMounts }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.master.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.enabled }}
|
||||||
|
- name: metrics
|
||||||
|
image: {{ include "redis.metrics.image" . }}
|
||||||
|
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
|
||||||
|
{{- if .Values.metrics.containerSecurityContext.enabled }}
|
||||||
|
securityContext: {{- omit .Values.metrics.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.metrics.command }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.command "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
if [[ -f '/secrets/redis-password' ]]; then
|
||||||
|
export REDIS_PASSWORD=$(cat /secrets/redis-password)
|
||||||
|
fi
|
||||||
|
redis_exporter{{- range $key, $value := .Values.metrics.extraArgs }} --{{ $key }}={{ $value }}{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
env:
|
||||||
|
- name: REDIS_ALIAS
|
||||||
|
value: {{ template "common.names.fullname" . }}
|
||||||
|
- name: REDIS_EXPORTER_WEB_LISTEN_ADDRESS
|
||||||
|
value: {{ printf ":%v" .Values.metrics.containerPorts.http }}
|
||||||
|
{{- if .Values.auth.enabled }}
|
||||||
|
- name: REDIS_USER
|
||||||
|
value: default
|
||||||
|
{{- if (not .Values.auth.usePasswordFiles) }}
|
||||||
|
- name: REDIS_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ template "redis.secretName" . }}
|
||||||
|
key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: REDIS_ADDR
|
||||||
|
value: rediss://{{ .Values.metrics.redisTargetHost }}:{{ .Values.master.containerPorts.redis }}
|
||||||
|
{{- if .Values.tls.authClients }}
|
||||||
|
- name: REDIS_EXPORTER_TLS_CLIENT_KEY_FILE
|
||||||
|
value: {{ template "redis.tlsCertKey" . }}
|
||||||
|
- name: REDIS_EXPORTER_TLS_CLIENT_CERT_FILE
|
||||||
|
value: {{ template "redis.tlsCert" . }}
|
||||||
|
{{- end }}
|
||||||
|
- name: REDIS_EXPORTER_TLS_CA_CERT_FILE
|
||||||
|
value: {{ template "redis.tlsCACert" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.extraEnvVars }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.extraEnvVars "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: metrics
|
||||||
|
containerPort: {{ .Values.metrics.containerPorts.http }}
|
||||||
|
{{- if not .Values.diagnosticMode.enabled }}
|
||||||
|
{{- if .Values.metrics.customStartupProbe }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.metrics.startupProbe.enabled }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
tcpSocket:
|
||||||
|
port: metrics
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.customLivenessProbe }}
|
||||||
|
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.metrics.livenessProbe.enabled }}
|
||||||
|
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
tcpSocket:
|
||||||
|
port: metrics
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.customReadinessProbe }}
|
||||||
|
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.metrics.readinessProbe.enabled }}
|
||||||
|
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: metrics
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.resources }}
|
||||||
|
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: redis-password
|
||||||
|
mountPath: /secrets/
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: redis-certificates
|
||||||
|
mountPath: /opt/bitnami/redis/certs
|
||||||
|
readOnly: true
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.extraVolumeMounts }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.sidecars }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.master.sidecars "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $needsVolumePermissions := and .Values.volumePermissions.enabled .Values.master.persistence.enabled .Values.master.podSecurityContext.enabled .Values.master.containerSecurityContext.enabled }}
|
||||||
|
{{- if or .Values.master.initContainers $needsVolumePermissions .Values.sysctl.enabled }}
|
||||||
|
initContainers:
|
||||||
|
{{- if .Values.master.initContainers }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.master.initContainers "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $needsVolumePermissions }}
|
||||||
|
- name: volume-permissions
|
||||||
|
image: {{ include "redis.volumePermissions.image" . }}
|
||||||
|
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -ec
|
||||||
|
- |
|
||||||
|
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||||
|
chown -R `id -u`:`id -G | cut -d " " -f2` {{ .Values.master.persistence.path }}
|
||||||
|
{{- else }}
|
||||||
|
chown -R {{ .Values.master.containerSecurityContext.runAsUser }}:{{ .Values.master.podSecurityContext.fsGroup }} {{ .Values.master.persistence.path }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||||
|
securityContext: {{- omit .Values.volumePermissions.containerSecurityContext "runAsUser" | toYaml | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.volumePermissions.resources }}
|
||||||
|
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: redis-data
|
||||||
|
mountPath: {{ .Values.master.persistence.path }}
|
||||||
|
{{- if .Values.master.persistence.subPath }}
|
||||||
|
subPath: {{ .Values.master.persistence.subPath }}
|
||||||
|
{{- else if .Values.master.persistence.subPathExpr }}
|
||||||
|
subPathExpr: {{ .Values.master.persistence.subPathExpr }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sysctl.enabled }}
|
||||||
|
- name: init-sysctl
|
||||||
|
image: {{ include "redis.sysctl.image" . }}
|
||||||
|
imagePullPolicy: {{ default "" .Values.sysctl.image.pullPolicy | quote }}
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
runAsUser: 0
|
||||||
|
{{- if .Values.sysctl.command }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.sysctl.command "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sysctl.resources }}
|
||||||
|
resources: {{- toYaml .Values.sysctl.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sysctl.mountHostSys }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: host-sys
|
||||||
|
mountPath: /host-sys
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
volumes:
|
||||||
|
- name: start-scripts
|
||||||
|
configMap:
|
||||||
|
name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
|
||||||
|
defaultMode: 0755
|
||||||
|
- name: health
|
||||||
|
configMap:
|
||||||
|
name: {{ printf "%s-health" (include "common.names.fullname" .) }}
|
||||||
|
defaultMode: 0755
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: redis-password
|
||||||
|
secret:
|
||||||
|
secretName: {{ template "redis.secretName" . }}
|
||||||
|
items:
|
||||||
|
- key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
path: redis-password
|
||||||
|
{{- end }}
|
||||||
|
- name: config
|
||||||
|
configMap:
|
||||||
|
name: {{ include "redis.configmapName" . }}
|
||||||
|
{{- if .Values.sysctl.mountHostSys }}
|
||||||
|
- name: host-sys
|
||||||
|
hostPath:
|
||||||
|
path: /sys
|
||||||
|
{{- end }}
|
||||||
|
- name: redis-tmp-conf
|
||||||
|
{{- if or .Values.master.persistence.medium .Values.master.persistence.sizeLimit }}
|
||||||
|
emptyDir:
|
||||||
|
{{- if .Values.master.persistence.medium }}
|
||||||
|
medium: {{ .Values.master.persistence.medium | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.persistence.sizeLimit }}
|
||||||
|
sizeLimit: {{ .Values.master.persistence.sizeLimit | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
emptyDir: {}
|
||||||
|
{{- end }}
|
||||||
|
- name: tmp
|
||||||
|
{{- if or .Values.master.persistence.medium .Values.master.persistence.sizeLimit }}
|
||||||
|
emptyDir:
|
||||||
|
{{- if .Values.master.persistence.medium }}
|
||||||
|
medium: {{ .Values.master.persistence.medium | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.persistence.sizeLimit }}
|
||||||
|
sizeLimit: {{ .Values.master.persistence.sizeLimit | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
emptyDir: {}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: redis-certificates
|
||||||
|
secret:
|
||||||
|
secretName: {{ include "redis.tlsSecretName" . }}
|
||||||
|
defaultMode: 256
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.extraVolumes }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.master.extraVolumes "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.extraVolumes }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumes "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if or (not .Values.master.persistence.enabled) (eq .Values.master.kind "DaemonSet") }}
|
||||||
|
- name: redis-data
|
||||||
|
{{- if or .Values.master.persistence.medium .Values.master.persistence.sizeLimit }}
|
||||||
|
emptyDir:
|
||||||
|
{{- if .Values.master.persistence.medium }}
|
||||||
|
medium: {{ .Values.master.persistence.medium | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.persistence.sizeLimit }}
|
||||||
|
sizeLimit: {{ .Values.master.persistence.sizeLimit | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
emptyDir: {}
|
||||||
|
{{- end }}
|
||||||
|
{{- else if .Values.master.persistence.existingClaim }}
|
||||||
|
- name: redis-data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: {{ printf "%s" (tpl .Values.master.persistence.existingClaim .) }}
|
||||||
|
{{- else if (eq .Values.master.kind "Deployment") }}
|
||||||
|
- name: redis-data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: {{ printf "redis-data-%s-master" (include "common.names.fullname" .) }}
|
||||||
|
{{- else }}
|
||||||
|
{{- if .Values.master.persistentVolumeClaimRetentionPolicy.enabled }}
|
||||||
|
persistentVolumeClaimRetentionPolicy:
|
||||||
|
whenDeleted: {{ .Values.master.persistentVolumeClaimRetentionPolicy.whenDeleted }}
|
||||||
|
whenScaled: {{ .Values.master.persistentVolumeClaimRetentionPolicy.whenScaled }}
|
||||||
|
{{- end }}
|
||||||
|
volumeClaimTemplates:
|
||||||
|
- apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: redis-data
|
||||||
|
{{- $claimLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.master.persistence.labels .Values.commonLabels ) "context" . ) }}
|
||||||
|
labels: {{- include "common.labels.matchLabels" ( dict "customLabels" $claimLabels "context" $ ) | nindent 10 }}
|
||||||
|
app.kubernetes.io/component: master
|
||||||
|
{{- if .Values.master.persistence.annotations }}
|
||||||
|
annotations: {{- toYaml .Values.master.persistence.annotations | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
{{- range .Values.master.persistence.accessModes }}
|
||||||
|
- {{ . | quote }}
|
||||||
|
{{- end }}
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: {{ .Values.master.persistence.size | quote }}
|
||||||
|
{{- if .Values.master.persistence.selector }}
|
||||||
|
selector: {{- include "common.tplvalues.render" (dict "value" .Values.master.persistence.selector "context" $) | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.persistence.dataSource }}
|
||||||
|
dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.master.persistence.dataSource "context" $) | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- include "common.storage.class" (dict "persistence" .Values.master.persistence "global" .Values.global) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
47
helm/redis/templates/master/psp.yaml
Normal file
47
helm/redis/templates/master/psp.yaml
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and (include "common.capabilities.psp.supported" .) .Values.podSecurityPolicy.create }}
|
||||||
|
apiVersion: policy/v1beta1
|
||||||
|
kind: PodSecurityPolicy
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-master" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
fsGroup:
|
||||||
|
rule: 'MustRunAs'
|
||||||
|
ranges:
|
||||||
|
- min: {{ .Values.master.podSecurityContext.fsGroup }}
|
||||||
|
max: {{ .Values.master.podSecurityContext.fsGroup }}
|
||||||
|
hostIPC: false
|
||||||
|
hostNetwork: false
|
||||||
|
hostPID: false
|
||||||
|
privileged: false
|
||||||
|
readOnlyRootFilesystem: false
|
||||||
|
requiredDropCapabilities:
|
||||||
|
- ALL
|
||||||
|
runAsUser:
|
||||||
|
rule: 'MustRunAs'
|
||||||
|
ranges:
|
||||||
|
- min: {{ .Values.master.containerSecurityContext.runAsUser }}
|
||||||
|
max: {{ .Values.master.containerSecurityContext.runAsUser }}
|
||||||
|
seLinux:
|
||||||
|
rule: 'RunAsAny'
|
||||||
|
supplementalGroups:
|
||||||
|
rule: 'MustRunAs'
|
||||||
|
ranges:
|
||||||
|
- min: {{ .Values.master.containerSecurityContext.runAsUser }}
|
||||||
|
max: {{ .Values.master.containerSecurityContext.runAsUser }}
|
||||||
|
volumes:
|
||||||
|
- 'configMap'
|
||||||
|
- 'secret'
|
||||||
|
- 'emptyDir'
|
||||||
|
- 'persistentVolumeClaim'
|
||||||
|
{{- end }}
|
||||||
33
helm/redis/templates/master/pvc.yaml
Normal file
33
helm/redis/templates/master/pvc.yaml
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and (eq .Values.architecture "standalone") (eq .Values.master.kind "Deployment") (.Values.master.persistence.enabled) (not .Values.master.persistence.existingClaim) }}
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
apiVersion: v1
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "redis-data-%s-master" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
{{- $labels := include "common.tplvalues.merge" ( dict "values" ( list .Values.master.persistence.labels .Values.commonLabels ) "context" . ) }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" $labels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: master
|
||||||
|
{{- if .Values.master.persistence.annotations }}
|
||||||
|
annotations: {{- toYaml .Values.master.persistence.annotations | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
{{- range .Values.master.persistence.accessModes }}
|
||||||
|
- {{ . | quote }}
|
||||||
|
{{- end }}
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: {{ .Values.master.persistence.size | quote }}
|
||||||
|
{{- if .Values.master.persistence.selector }}
|
||||||
|
selector: {{- include "common.tplvalues.render" (dict "value" .Values.master.persistence.selector "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.persistence.dataSource }}
|
||||||
|
dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.master.persistence.dataSource "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- include "common.storage.class" (dict "persistence" .Values.master.persistence "global" .Values.global) | nindent 2 }}
|
||||||
|
{{- end }}
|
||||||
62
helm/redis/templates/master/service.yaml
Normal file
62
helm/redis/templates/master/service.yaml
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and (not .Values.sentinel.enabled) (gt (int64 .Values.master.count) 0) }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-master" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: master
|
||||||
|
{{- if or .Values.master.service.annotations .Values.commonAnnotations }}
|
||||||
|
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.master.service.annotations .Values.commonAnnotations ) "context" . ) }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
type: {{ .Values.master.service.type }}
|
||||||
|
{{- if or (eq .Values.master.service.type "LoadBalancer") (eq .Values.master.service.type "NodePort") }}
|
||||||
|
externalTrafficPolicy: {{ .Values.master.service.externalTrafficPolicy | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if (semverCompare ">=1.22-0" (include "common.capabilities.kubeVersion" .)) }}
|
||||||
|
internalTrafficPolicy: {{ .Values.master.service.internalTrafficPolicy }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.master.service.type "LoadBalancer") (not (empty .Values.master.service.loadBalancerIP)) }}
|
||||||
|
loadBalancerIP: {{ .Values.master.service.loadBalancerIP }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.master.service.type "LoadBalancer") .Values.master.service.loadBalancerClass }}
|
||||||
|
loadBalancerClass: {{ .Values.master.service.loadBalancerClass }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.master.service.type "LoadBalancer") (not (empty .Values.master.service.loadBalancerSourceRanges)) }}
|
||||||
|
loadBalancerSourceRanges: {{ toYaml .Values.master.service.loadBalancerSourceRanges | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and .Values.master.service.clusterIP (eq .Values.master.service.type "ClusterIP") }}
|
||||||
|
clusterIP: {{ .Values.master.service.clusterIP }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.service.sessionAffinity }}
|
||||||
|
sessionAffinity: {{ .Values.master.service.sessionAffinity }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.service.sessionAffinityConfig }}
|
||||||
|
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.master.service.sessionAffinityConfig "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.service.externalIPs }}
|
||||||
|
externalIPs: {{- include "common.tplvalues.render" (dict "value" .Values.master.service.externalIPs "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: tcp-redis
|
||||||
|
port: {{ .Values.master.service.ports.redis }}
|
||||||
|
targetPort: redis
|
||||||
|
{{- if and (or (eq .Values.master.service.type "NodePort") (eq .Values.master.service.type "LoadBalancer")) .Values.master.service.nodePorts.redis}}
|
||||||
|
nodePort: {{ .Values.master.service.nodePorts.redis}}
|
||||||
|
{{- else if eq .Values.master.service.type "ClusterIP" }}
|
||||||
|
nodePort: null
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.service.extraPorts }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.master.service.extraPorts "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.master.podLabels .Values.commonLabels ) "context" . ) }}
|
||||||
|
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: master
|
||||||
|
{{- end }}
|
||||||
18
helm/redis/templates/master/serviceaccount.yaml
Normal file
18
helm/redis/templates/master/serviceaccount.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and .Values.master.serviceAccount.create (or (not (eq .Values.architecture "replication")) (not .Values.sentinel.enabled)) }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
automountServiceAccountToken: {{ .Values.master.serviceAccount.automountServiceAccountToken }}
|
||||||
|
metadata:
|
||||||
|
name: {{ template "redis.masterServiceAccountName" . }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if or .Values.master.serviceAccount.annotations .Values.commonAnnotations }}
|
||||||
|
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.master.serviceAccount.annotations .Values.commonAnnotations ) "context" . ) }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
44
helm/redis/templates/metrics-svc.yaml
Normal file
44
helm/redis/templates/metrics-svc.yaml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and .Values.metrics.enabled .Values.metrics.service.enabled }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-metrics" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: metrics
|
||||||
|
{{- if or .Values.metrics.service.annotations .Values.commonAnnotations }}
|
||||||
|
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.metrics.service.annotations .Values.commonAnnotations ) "context" . ) }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
type: {{ .Values.metrics.service.type }}
|
||||||
|
{{- if and .Values.metrics.service.clusterIP (eq .Values.metrics.service.type "ClusterIP") }}
|
||||||
|
clusterIP: {{ .Values.metrics.service.clusterIP }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq .Values.metrics.service.type "LoadBalancer" }}
|
||||||
|
externalTrafficPolicy: {{ .Values.metrics.service.externalTrafficPolicy }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.metrics.service.type "LoadBalancer") .Values.metrics.service.loadBalancerIP }}
|
||||||
|
loadBalancerIP: {{ .Values.metrics.service.loadBalancerIP }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.metrics.service.type "LoadBalancer") .Values.metrics.service.loadBalancerClass }}
|
||||||
|
loadBalancerClass: {{ .Values.metrics.service.loadBalancerClass }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.metrics.service.type "LoadBalancer") .Values.metrics.service.loadBalancerSourceRanges }}
|
||||||
|
loadBalancerSourceRanges: {{- toYaml .Values.metrics.service.loadBalancerSourceRanges | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: http-metrics
|
||||||
|
port: {{ coalesce .Values.metrics.service.ports.http .Values.metrics.service.port }}
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: metrics
|
||||||
|
{{- if .Values.metrics.service.extraPorts }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.service.extraPorts "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
108
helm/redis/templates/networkpolicy.yaml
Normal file
108
helm/redis/templates/networkpolicy.yaml
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if .Values.networkPolicy.enabled }}
|
||||||
|
kind: NetworkPolicy
|
||||||
|
apiVersion: {{ template "networkPolicy.apiVersion" . }}
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
podSelector:
|
||||||
|
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 6 }}
|
||||||
|
policyTypes:
|
||||||
|
- Ingress
|
||||||
|
- Egress
|
||||||
|
{{- if .Values.networkPolicy.allowExternalEgress }}
|
||||||
|
egress:
|
||||||
|
- {}
|
||||||
|
{{- else }}
|
||||||
|
egress:
|
||||||
|
{{- if eq .Values.architecture "replication" }}
|
||||||
|
# Allow dns resolution
|
||||||
|
- ports:
|
||||||
|
- port: 53
|
||||||
|
protocol: UDP
|
||||||
|
# Allow outbound connections to other cluster pods
|
||||||
|
- ports:
|
||||||
|
- port: {{ .Values.master.containerPorts.redis }}
|
||||||
|
{{- if .Values.sentinel.enabled }}
|
||||||
|
- port: {{ .Values.sentinel.containerPorts.sentinel }}
|
||||||
|
{{- end }}
|
||||||
|
to:
|
||||||
|
- podSelector:
|
||||||
|
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.networkPolicy.extraEgress }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraEgress "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
ingress:
|
||||||
|
# Allow inbound connections
|
||||||
|
- ports:
|
||||||
|
- port: {{ .Values.master.containerPorts.redis }}
|
||||||
|
{{- if .Values.sentinel.enabled }}
|
||||||
|
- port: {{ .Values.sentinel.containerPorts.sentinel }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if not .Values.networkPolicy.allowExternal }}
|
||||||
|
from:
|
||||||
|
- podSelector:
|
||||||
|
matchLabels:
|
||||||
|
{{ template "common.names.fullname" . }}-client: "true"
|
||||||
|
- podSelector:
|
||||||
|
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 14 }}
|
||||||
|
{{- if or .Values.networkPolicy.ingressNSMatchLabels .Values.networkPolicy.ingressNSPodMatchLabels }}
|
||||||
|
- namespaceSelector:
|
||||||
|
matchLabels:
|
||||||
|
{{- if .Values.networkPolicy.ingressNSMatchLabels }}
|
||||||
|
{{- range $key, $value := .Values.networkPolicy.ingressNSMatchLabels }}
|
||||||
|
{{ $key | quote }}: {{ $value | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{ else }}
|
||||||
|
{}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.networkPolicy.ingressNSPodMatchLabels }}
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
{{- range $key, $value := .Values.networkPolicy.ingressNSPodMatchLabels }}
|
||||||
|
{{ $key | quote }}: {{ $value | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.enabled }}
|
||||||
|
# Allow prometheus scrapes for metrics
|
||||||
|
- ports:
|
||||||
|
- port: {{ .Values.metrics.containerPorts.http }}
|
||||||
|
{{- if not .Values.networkPolicy.metrics.allowExternal }}
|
||||||
|
from:
|
||||||
|
{{- if or .Values.networkPolicy.metrics.ingressNSMatchLabels .Values.networkPolicy.metrics.ingressNSPodMatchLabels }}
|
||||||
|
- namespaceSelector:
|
||||||
|
matchLabels:
|
||||||
|
{{- if .Values.networkPolicy.metrics.ingressNSMatchLabels }}
|
||||||
|
{{- range $key, $value := .Values.networkPolicy.metrics.ingressNSMatchLabels }}
|
||||||
|
{{ $key | quote }}: {{ $value | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{ else }}
|
||||||
|
{}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.networkPolicy.metrics.ingressNSPodMatchLabels }}
|
||||||
|
podSelector:
|
||||||
|
matchLabels:
|
||||||
|
{{- range $key, $value := .Values.networkPolicy.metrics.ingressNSPodMatchLabels }}
|
||||||
|
{{ $key | quote }}: {{ $value | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.networkPolicy.extraIngress }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.networkPolicy.extraIngress "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
25
helm/redis/templates/pdb.yaml
Normal file
25
helm/redis/templates/pdb.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if .Values.pdb.create }}
|
||||||
|
apiVersion: {{ include "common.capabilities.policy.apiVersion" . }}
|
||||||
|
kind: PodDisruptionBudget
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
{{- if .Values.pdb.minAvailable }}
|
||||||
|
minAvailable: {{ .Values.pdb.minAvailable }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.pdb.maxUnavailable }}
|
||||||
|
maxUnavailable: {{ .Values.pdb.maxUnavailable }}
|
||||||
|
{{- end }}
|
||||||
|
selector:
|
||||||
|
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 6 }}
|
||||||
|
{{- end }}
|
||||||
69
helm/redis/templates/podmonitor.yaml
Normal file
69
helm/redis/templates/podmonitor.yaml
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and .Values.metrics.enabled .Values.metrics.podMonitor.enabled }}
|
||||||
|
apiVersion: monitoring.coreos.com/v1
|
||||||
|
kind: PodMonitor
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
namespace: {{ default (include "common.names.namespace" .) .Values.metrics.podMonitor.namespace | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.metrics.podMonitor.additionalLabels }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.podMonitor.additionalLabels "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
podMetricsEndpoints:
|
||||||
|
- port: metrics
|
||||||
|
{{- if .Values.metrics.podMonitor.interval }}
|
||||||
|
interval: {{ .Values.metrics.podMonitor.interval }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.podMonitor.scrapeTimeout }}
|
||||||
|
scrapeTimeout: {{ .Values.metrics.podMonitor.scrapeTimeout }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.podMonitor.honorLabels }}
|
||||||
|
honorLabels: {{ .Values.metrics.podMonitor.honorLabels }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.podMonitor.relabellings }}
|
||||||
|
relabelings: {{- toYaml .Values.metrics.podMonitor.relabellings | nindent 6 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.podMonitor.metricRelabelings }}
|
||||||
|
metricRelabelings: {{- toYaml .Values.metrics.podMonitor.metricRelabelings | nindent 6 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- range .Values.metrics.podMonitor.additionalEndpoints }}
|
||||||
|
- port: {{ .port }}
|
||||||
|
{{- if .interval }}
|
||||||
|
interval: {{ .interval }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .path }}
|
||||||
|
path: {{ .path }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .params }}
|
||||||
|
params:
|
||||||
|
{{- range $key, $value := .params }}
|
||||||
|
{{ $key }}:
|
||||||
|
{{- range $value }}
|
||||||
|
- {{ . | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.serviceMonitor.podTargetLabels }}
|
||||||
|
podTargetLabels: {{- toYaml .Values.metrics.podMonitor.podTargetLabels | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.metrics.podMonitor.sampleLimit -}}
|
||||||
|
sampleLimit: {{ . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.metrics.podMonitor.targetLimit -}}
|
||||||
|
targetLimit: {{ . }}
|
||||||
|
{{- end }}
|
||||||
|
namespaceSelector:
|
||||||
|
matchNames:
|
||||||
|
- {{ include "common.names.namespace" . | quote }}
|
||||||
|
selector:
|
||||||
|
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 6 }}
|
||||||
|
{{- end }}
|
||||||
23
helm/redis/templates/prometheusrule.yaml
Normal file
23
helm/redis/templates/prometheusrule.yaml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and .Values.metrics.enabled .Values.metrics.prometheusRule.enabled }}
|
||||||
|
apiVersion: monitoring.coreos.com/v1
|
||||||
|
kind: PrometheusRule
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
namespace: {{ default (include "common.names.namespace" .) .Values.metrics.prometheusRule.namespace | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.metrics.prometheusRule.additionalLabels }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.prometheusRule.additionalLabels "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
groups:
|
||||||
|
- name: {{ include "common.names.fullname" . }}
|
||||||
|
rules: {{- include "common.tplvalues.render" ( dict "value" .Values.metrics.prometheusRule.rules "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
535
helm/redis/templates/replicas/application.yaml
Normal file
535
helm/redis/templates/replicas/application.yaml
Normal file
@ -0,0 +1,535 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and (eq .Values.architecture "replication") (not .Values.sentinel.enabled) }}
|
||||||
|
apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
|
||||||
|
kind: {{ .Values.replica.kind }}
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-replicas" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: replica
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
{{- if and (not (eq .Values.replica.kind "DaemonSet")) (not .Values.replica.autoscaling.enabled) }}
|
||||||
|
replicas: {{ .Values.replica.replicaCount }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.replica.podLabels .Values.commonLabels ) "context" . ) }}
|
||||||
|
selector:
|
||||||
|
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
|
||||||
|
app.kubernetes.io/component: replica
|
||||||
|
{{- if (eq .Values.replica.kind "StatefulSet") }}
|
||||||
|
serviceName: {{ printf "%s-headless" (include "common.names.fullname" .) }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.updateStrategy }}
|
||||||
|
updateStrategy: {{- toYaml .Values.replica.updateStrategy | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and .Values.replica.minReadySeconds (semverCompare ">= 1.23-0" (include "common.capabilities.kubeVersion" .)) }}
|
||||||
|
minReadySeconds: {{ .Values.replica.minReadySeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.podManagementPolicy }}
|
||||||
|
podManagementPolicy: {{ .Values.replica.podManagementPolicy | quote }}
|
||||||
|
{{- end }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
|
||||||
|
app.kubernetes.io/component: replica
|
||||||
|
{{- if and .Values.metrics.enabled .Values.metrics.podLabels }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podLabels "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
annotations:
|
||||||
|
{{- if (include "redis.createConfigmap" .) }}
|
||||||
|
checksum/configmap: {{ pick ( include (print $.Template.BasePath "/configmap.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
{{- end }}
|
||||||
|
checksum/health: {{ pick ( include (print $.Template.BasePath "/health-configmap.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
checksum/scripts: {{ pick ( include (print $.Template.BasePath "/scripts-configmap.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
checksum/secret: {{ pick ( include (print $.Template.BasePath "/secret.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
{{- if .Values.replica.podAnnotations }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.podAnnotations "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
{{- include "redis.imagePullSecrets" . | nindent 6 }}
|
||||||
|
{{- if .Values.replica.hostAliases }}
|
||||||
|
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.replica.hostAliases "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.podSecurityContext.enabled }}
|
||||||
|
securityContext: {{- omit .Values.replica.podSecurityContext "enabled" | toYaml | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
serviceAccountName: {{ template "redis.replicaServiceAccountName" . }}
|
||||||
|
automountServiceAccountToken: {{ .Values.replica.automountServiceAccountToken }}
|
||||||
|
{{- if .Values.replica.priorityClassName }}
|
||||||
|
priorityClassName: {{ .Values.replica.priorityClassName | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.affinity }}
|
||||||
|
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.replica.affinity "context" $) | nindent 8 }}
|
||||||
|
{{- else }}
|
||||||
|
affinity:
|
||||||
|
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAffinityPreset "component" "replica" "customLabels" $podLabels "context" $) | nindent 10 }}
|
||||||
|
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAntiAffinityPreset "component" "replica" "customLabels" $podLabels "context" $) | nindent 10 }}
|
||||||
|
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.replica.nodeAffinityPreset.type "key" .Values.replica.nodeAffinityPreset.key "values" .Values.replica.nodeAffinityPreset.values) | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.nodeSelector }}
|
||||||
|
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.replica.nodeSelector "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.tolerations }}
|
||||||
|
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.replica.tolerations "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.topologySpreadConstraints }}
|
||||||
|
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.replica.topologySpreadConstraints "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.shareProcessNamespace }}
|
||||||
|
shareProcessNamespace: {{ .Values.replica.shareProcessNamespace }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.schedulerName }}
|
||||||
|
schedulerName: {{ .Values.replica.schedulerName | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.dnsPolicy }}
|
||||||
|
dnsPolicy: {{ .Values.replica.dnsPolicy }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.dnsConfig }}
|
||||||
|
dnsConfig: {{- include "common.tplvalues.render" (dict "value" .Values.replica.dnsConfig "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
enableServiceLinks: {{ .Values.replica.enableServiceLinks }}
|
||||||
|
terminationGracePeriodSeconds: {{ .Values.replica.terminationGracePeriodSeconds }}
|
||||||
|
containers:
|
||||||
|
- name: redis
|
||||||
|
image: {{ template "redis.image" . }}
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
||||||
|
{{- if not .Values.diagnosticMode.enabled }}
|
||||||
|
{{- if .Values.replica.lifecycleHooks }}
|
||||||
|
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.replica.lifecycleHooks "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.containerSecurityContext.enabled }}
|
||||||
|
securityContext: {{- omit .Values.replica.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.replica.command }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.replica.command "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.replica.args }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.replica.args "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
args:
|
||||||
|
- -c
|
||||||
|
- /opt/bitnami/scripts/start-scripts/start-replica.sh
|
||||||
|
{{- end }}
|
||||||
|
env:
|
||||||
|
- name: BITNAMI_DEBUG
|
||||||
|
value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
|
||||||
|
- name: REDIS_REPLICATION_MODE
|
||||||
|
value: replica
|
||||||
|
- name: REDIS_MASTER_HOST
|
||||||
|
{{- if .Values.replica.externalMaster.enabled }}
|
||||||
|
value: {{ .Values.replica.externalMaster.host | quote }}
|
||||||
|
{{- else if and (eq (int64 .Values.master.count) 1) (eq .Values.master.kind "StatefulSet") }}
|
||||||
|
value: {{ template "common.names.fullname" . }}-master-0.{{ template "common.names.fullname" . }}-headless.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}
|
||||||
|
{{- else }}
|
||||||
|
value: {{ template "common.names.fullname" . }}-master.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}
|
||||||
|
{{- end }}
|
||||||
|
- name: REDIS_MASTER_PORT_NUMBER
|
||||||
|
{{- if .Values.replica.externalMaster.enabled }}
|
||||||
|
value: {{ .Values.replica.externalMaster.port | quote }}
|
||||||
|
{{- else }}
|
||||||
|
value: {{ .Values.master.containerPorts.redis | quote }}
|
||||||
|
{{- end }}
|
||||||
|
- name: ALLOW_EMPTY_PASSWORD
|
||||||
|
value: {{ ternary "no" "yes" .Values.auth.enabled | quote }}
|
||||||
|
{{- if .Values.auth.enabled }}
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: REDIS_PASSWORD_FILE
|
||||||
|
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||||
|
- name: REDIS_MASTER_PASSWORD_FILE
|
||||||
|
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||||
|
{{- else }}
|
||||||
|
- name: REDIS_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ template "redis.secretName" . }}
|
||||||
|
key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
- name: REDIS_MASTER_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ template "redis.secretName" . }}
|
||||||
|
key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
- name: REDIS_TLS_ENABLED
|
||||||
|
value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: REDIS_TLS_PORT
|
||||||
|
value: {{ .Values.replica.containerPorts.redis | quote }}
|
||||||
|
- name: REDIS_TLS_AUTH_CLIENTS
|
||||||
|
value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
|
||||||
|
- name: REDIS_TLS_CERT_FILE
|
||||||
|
value: {{ template "redis.tlsCert" . }}
|
||||||
|
- name: REDIS_TLS_KEY_FILE
|
||||||
|
value: {{ template "redis.tlsCertKey" . }}
|
||||||
|
- name: REDIS_TLS_CA_FILE
|
||||||
|
value: {{ template "redis.tlsCACert" . }}
|
||||||
|
{{- if .Values.tls.dhParamsFilename }}
|
||||||
|
- name: REDIS_TLS_DH_PARAMS_FILE
|
||||||
|
value: {{ template "redis.tlsDHParams" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
- name: REDIS_PORT
|
||||||
|
value: {{ .Values.replica.containerPorts.redis | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.extraEnvVars }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.replica.extraEnvVars "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if or .Values.replica.extraEnvVarsCM .Values.replica.extraEnvVarsSecret }}
|
||||||
|
envFrom:
|
||||||
|
{{- if .Values.replica.extraEnvVarsCM }}
|
||||||
|
- configMapRef:
|
||||||
|
name: {{ .Values.replica.extraEnvVarsCM }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.extraEnvVarsSecret }}
|
||||||
|
- secretRef:
|
||||||
|
name: {{ .Values.replica.extraEnvVarsSecret }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: redis
|
||||||
|
containerPort: {{ .Values.replica.containerPorts.redis }}
|
||||||
|
{{- if not .Values.diagnosticMode.enabled }}
|
||||||
|
{{- if .Values.replica.customStartupProbe }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customStartupProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.replica.startupProbe.enabled }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.replica.startupProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
tcpSocket:
|
||||||
|
port: redis
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.customLivenessProbe }}
|
||||||
|
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customLivenessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.replica.livenessProbe.enabled }}
|
||||||
|
livenessProbe:
|
||||||
|
initialDelaySeconds: {{ .Values.replica.livenessProbe.initialDelaySeconds }}
|
||||||
|
periodSeconds: {{ .Values.replica.livenessProbe.periodSeconds }}
|
||||||
|
timeoutSeconds: {{ add1 .Values.replica.livenessProbe.timeoutSeconds }}
|
||||||
|
successThreshold: {{ .Values.replica.livenessProbe.successThreshold }}
|
||||||
|
failureThreshold: {{ .Values.replica.livenessProbe.failureThreshold }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- /health/ping_liveness_local_and_master.sh {{ .Values.replica.livenessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.customReadinessProbe }}
|
||||||
|
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customReadinessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.replica.readinessProbe.enabled }}
|
||||||
|
readinessProbe:
|
||||||
|
initialDelaySeconds: {{ .Values.replica.readinessProbe.initialDelaySeconds }}
|
||||||
|
periodSeconds: {{ .Values.replica.readinessProbe.periodSeconds }}
|
||||||
|
timeoutSeconds: {{ add1 .Values.replica.readinessProbe.timeoutSeconds }}
|
||||||
|
successThreshold: {{ .Values.replica.readinessProbe.successThreshold }}
|
||||||
|
failureThreshold: {{ .Values.replica.readinessProbe.failureThreshold }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- /health/ping_readiness_local_and_master.sh {{ .Values.replica.readinessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.resources }}
|
||||||
|
resources: {{- toYaml .Values.replica.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: start-scripts
|
||||||
|
mountPath: /opt/bitnami/scripts/start-scripts
|
||||||
|
- name: health
|
||||||
|
mountPath: /health
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: redis-password
|
||||||
|
mountPath: /opt/bitnami/redis/secrets/
|
||||||
|
{{- end }}
|
||||||
|
- name: redis-data
|
||||||
|
mountPath: /data
|
||||||
|
{{- if .Values.replica.persistence.subPath }}
|
||||||
|
subPath: {{ .Values.replica.persistence.subPath }}
|
||||||
|
{{- else if .Values.replica.persistence.subPathExpr }}
|
||||||
|
subPathExpr: {{ .Values.replica.persistence.subPathExpr }}
|
||||||
|
{{- end }}
|
||||||
|
- name: config
|
||||||
|
mountPath: /opt/bitnami/redis/mounted-etc
|
||||||
|
- name: redis-tmp-conf
|
||||||
|
mountPath: /opt/bitnami/redis/etc
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: redis-certificates
|
||||||
|
mountPath: /opt/bitnami/redis/certs
|
||||||
|
readOnly: true
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.extraVolumeMounts }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.enabled }}
|
||||||
|
- name: metrics
|
||||||
|
image: {{ include "redis.metrics.image" . }}
|
||||||
|
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
|
||||||
|
{{- if .Values.metrics.containerSecurityContext.enabled }}
|
||||||
|
securityContext: {{- omit .Values.metrics.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.metrics.command }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.command "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
if [[ -f '/secrets/redis-password' ]]; then
|
||||||
|
export REDIS_PASSWORD=$(cat /secrets/redis-password)
|
||||||
|
fi
|
||||||
|
redis_exporter{{- range $key, $value := .Values.metrics.extraArgs }} --{{ $key }}={{ $value }}{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
env:
|
||||||
|
- name: REDIS_ALIAS
|
||||||
|
value: {{ template "common.names.fullname" . }}
|
||||||
|
- name: REDIS_EXPORTER_WEB_LISTEN_ADDRESS
|
||||||
|
value: {{ printf ":%v" .Values.metrics.containerPorts.http }}
|
||||||
|
{{- if .Values.auth.enabled }}
|
||||||
|
- name: REDIS_USER
|
||||||
|
value: default
|
||||||
|
{{- if (not .Values.auth.usePasswordFiles) }}
|
||||||
|
- name: REDIS_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ template "redis.secretName" . }}
|
||||||
|
key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: REDIS_ADDR
|
||||||
|
value: rediss://{{ .Values.metrics.redisTargetHost }}:{{ .Values.replica.containerPorts.redis }}
|
||||||
|
{{- if .Values.tls.authClients }}
|
||||||
|
- name: REDIS_EXPORTER_TLS_CLIENT_KEY_FILE
|
||||||
|
value: {{ template "redis.tlsCertKey" . }}
|
||||||
|
- name: REDIS_EXPORTER_TLS_CLIENT_CERT_FILE
|
||||||
|
value: {{ template "redis.tlsCert" . }}
|
||||||
|
{{- end }}
|
||||||
|
- name: REDIS_EXPORTER_TLS_CA_CERT_FILE
|
||||||
|
value: {{ template "redis.tlsCACert" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.extraEnvVars }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.extraEnvVars "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: metrics
|
||||||
|
containerPort: {{ .Values.metrics.containerPorts.http }}
|
||||||
|
{{- if not .Values.diagnosticMode.enabled }}
|
||||||
|
{{- if .Values.metrics.customStartupProbe }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.metrics.startupProbe.enabled }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
tcpSocket:
|
||||||
|
port: metrics
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.customLivenessProbe }}
|
||||||
|
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.metrics.livenessProbe.enabled }}
|
||||||
|
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
tcpSocket:
|
||||||
|
port: metrics
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.customReadinessProbe }}
|
||||||
|
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.metrics.readinessProbe.enabled }}
|
||||||
|
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: metrics
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.resources }}
|
||||||
|
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: redis-password
|
||||||
|
mountPath: /secrets/
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: redis-certificates
|
||||||
|
mountPath: /opt/bitnami/redis/certs
|
||||||
|
readOnly: true
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.extraVolumeMounts }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.sidecars }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.replica.sidecars "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $needsVolumePermissions := and .Values.volumePermissions.enabled .Values.replica.persistence.enabled .Values.replica.podSecurityContext.enabled .Values.replica.containerSecurityContext.enabled }}
|
||||||
|
{{- if or .Values.replica.initContainers $needsVolumePermissions .Values.sysctl.enabled }}
|
||||||
|
initContainers:
|
||||||
|
{{- if .Values.replica.initContainers }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.replica.initContainers "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $needsVolumePermissions }}
|
||||||
|
- name: volume-permissions
|
||||||
|
image: {{ include "redis.volumePermissions.image" . }}
|
||||||
|
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -ec
|
||||||
|
- |
|
||||||
|
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||||
|
chown -R `id -u`:`id -G | cut -d " " -f2` {{ .Values.replica.persistence.path }}
|
||||||
|
{{- else }}
|
||||||
|
chown -R {{ .Values.replica.containerSecurityContext.runAsUser }}:{{ .Values.replica.podSecurityContext.fsGroup }} {{ .Values.replica.persistence.path }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||||
|
securityContext: {{- omit .Values.volumePermissions.containerSecurityContext "runAsUser" | toYaml | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.volumePermissions.resources }}
|
||||||
|
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: redis-data
|
||||||
|
mountPath: {{ .Values.replica.persistence.path }}
|
||||||
|
{{- if .Values.replica.persistence.subPath }}
|
||||||
|
subPath: {{ .Values.replica.persistence.subPath }}
|
||||||
|
{{- else if .Values.replica.persistence.subPathExpr }}
|
||||||
|
subPathExpr: {{ .Values.replica.persistence.subPathExpr }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sysctl.enabled }}
|
||||||
|
- name: init-sysctl
|
||||||
|
image: {{ include "redis.sysctl.image" . }}
|
||||||
|
imagePullPolicy: {{ default "" .Values.sysctl.image.pullPolicy | quote }}
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
runAsUser: 0
|
||||||
|
{{- if .Values.sysctl.command }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.sysctl.command "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sysctl.resources }}
|
||||||
|
resources: {{- toYaml .Values.sysctl.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sysctl.mountHostSys }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: host-sys
|
||||||
|
mountPath: /host-sys
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
volumes:
|
||||||
|
- name: start-scripts
|
||||||
|
configMap:
|
||||||
|
name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
|
||||||
|
defaultMode: 0755
|
||||||
|
- name: health
|
||||||
|
configMap:
|
||||||
|
name: {{ printf "%s-health" (include "common.names.fullname" .) }}
|
||||||
|
defaultMode: 0755
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: redis-password
|
||||||
|
secret:
|
||||||
|
secretName: {{ template "redis.secretName" . }}
|
||||||
|
items:
|
||||||
|
- key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
path: redis-password
|
||||||
|
{{- end }}
|
||||||
|
- name: config
|
||||||
|
configMap:
|
||||||
|
name: {{ include "redis.configmapName" . }}
|
||||||
|
{{- if .Values.sysctl.mountHostSys }}
|
||||||
|
- name: host-sys
|
||||||
|
hostPath:
|
||||||
|
path: /sys
|
||||||
|
{{- end }}
|
||||||
|
- name: redis-tmp-conf
|
||||||
|
{{- if or .Values.replica.persistence.medium .Values.replica.persistence.sizeLimit }}
|
||||||
|
emptyDir:
|
||||||
|
{{- if .Values.replica.persistence.medium }}
|
||||||
|
medium: {{ .Values.replica.persistence.medium | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.persistence.sizeLimit }}
|
||||||
|
sizeLimit: {{ .Values.replica.persistence.sizeLimit | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
emptyDir: {}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: redis-certificates
|
||||||
|
secret:
|
||||||
|
secretName: {{ include "redis.tlsSecretName" . }}
|
||||||
|
defaultMode: 256
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.extraVolumes }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumes "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.extraVolumes }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumes "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if or (not .Values.replica.persistence.enabled) (not (eq .Values.replica.kind "StatefulSet")) }}
|
||||||
|
- name: redis-data
|
||||||
|
{{- if or .Values.replica.persistence.medium .Values.replica.persistence.sizeLimit }}
|
||||||
|
emptyDir:
|
||||||
|
{{- if .Values.replica.persistence.medium }}
|
||||||
|
medium: {{ .Values.replica.persistence.medium | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.persistence.sizeLimit }}
|
||||||
|
sizeLimit: {{ .Values.replica.persistence.sizeLimit | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
emptyDir: {}
|
||||||
|
{{- end }}
|
||||||
|
{{- else if .Values.replica.persistence.existingClaim }}
|
||||||
|
- name: redis-data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: {{ printf "%s" (tpl .Values.replica.persistence.existingClaim .) }}
|
||||||
|
{{- else }}
|
||||||
|
{{- if .Values.replica.persistentVolumeClaimRetentionPolicy.enabled }}
|
||||||
|
persistentVolumeClaimRetentionPolicy:
|
||||||
|
whenDeleted: {{ .Values.replica.persistentVolumeClaimRetentionPolicy.whenDeleted }}
|
||||||
|
whenScaled: {{ .Values.replica.persistentVolumeClaimRetentionPolicy.whenScaled }}
|
||||||
|
{{- end }}
|
||||||
|
volumeClaimTemplates:
|
||||||
|
- apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: redis-data
|
||||||
|
{{- $claimLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.master.persistence.labels .Values.commonLabels ) "context" . ) }}
|
||||||
|
labels: {{- include "common.labels.matchLabels" ( dict "customLabels" $claimLabels "context" $ ) | nindent 10 }}
|
||||||
|
app.kubernetes.io/component: replica
|
||||||
|
{{- if .Values.replica.persistence.annotations }}
|
||||||
|
annotations: {{- toYaml .Values.replica.persistence.annotations | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
{{- range .Values.replica.persistence.accessModes }}
|
||||||
|
- {{ . | quote }}
|
||||||
|
{{- end }}
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: {{ .Values.replica.persistence.size | quote }}
|
||||||
|
{{- if .Values.replica.persistence.selector }}
|
||||||
|
selector: {{- include "common.tplvalues.render" (dict "value" .Values.replica.persistence.selector "context" $) | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.persistence.dataSource }}
|
||||||
|
dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.replica.persistence.dataSource "context" $) | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- include "common.storage.class" (dict "persistence" .Values.replica.persistence "global" .Values.global) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
49
helm/redis/templates/replicas/hpa.yaml
Normal file
49
helm/redis/templates/replicas/hpa.yaml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and .Values.replica.autoscaling.enabled (not .Values.sentinel.enabled) }}
|
||||||
|
apiVersion: {{ include "common.capabilities.hpa.apiVersion" ( dict "context" $ ) }}
|
||||||
|
kind: HorizontalPodAutoscaler
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-replicas" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: replica
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
scaleTargetRef:
|
||||||
|
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
|
||||||
|
kind: StatefulSet
|
||||||
|
name: {{ printf "%s-replicas" (include "common.names.fullname" .) }}
|
||||||
|
minReplicas: {{ .Values.replica.autoscaling.minReplicas }}
|
||||||
|
maxReplicas: {{ .Values.replica.autoscaling.maxReplicas }}
|
||||||
|
metrics:
|
||||||
|
{{- if .Values.replica.autoscaling.targetCPU }}
|
||||||
|
- type: Resource
|
||||||
|
resource:
|
||||||
|
name: cpu
|
||||||
|
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
|
||||||
|
targetAverageUtilization: {{ .Values.replica.autoscaling.targetCPU }}
|
||||||
|
{{- else }}
|
||||||
|
target:
|
||||||
|
type: Utilization
|
||||||
|
averageUtilization: {{ .Values.replica.autoscaling.targetCPU }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.autoscaling.targetMemory }}
|
||||||
|
- type: Resource
|
||||||
|
resource:
|
||||||
|
name: memory
|
||||||
|
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
|
||||||
|
targetAverageUtilization: {{ .Values.replica.autoscaling.targetMemory }}
|
||||||
|
{{- else }}
|
||||||
|
target:
|
||||||
|
type: Utilization
|
||||||
|
averageUtilization: {{ .Values.replica.autoscaling.targetMemory }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
59
helm/redis/templates/replicas/service.yaml
Normal file
59
helm/redis/templates/replicas/service.yaml
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and (eq .Values.architecture "replication") (not .Values.sentinel.enabled) }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-replicas" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: replica
|
||||||
|
{{- if or .Values.replica.service.annotations .Values.commonAnnotations }}
|
||||||
|
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.replica.service.annotations .Values.commonAnnotations ) "context" . ) }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
type: {{ .Values.replica.service.type }}
|
||||||
|
{{- if or (eq .Values.replica.service.type "LoadBalancer") (eq .Values.replica.service.type "NodePort") }}
|
||||||
|
externalTrafficPolicy: {{ .Values.replica.service.externalTrafficPolicy | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if (semverCompare ">=1.22-0" (include "common.capabilities.kubeVersion" .)) }}
|
||||||
|
internalTrafficPolicy: {{ .Values.replica.service.internalTrafficPolicy }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.replica.service.type "LoadBalancer") (not (empty .Values.replica.service.loadBalancerIP)) }}
|
||||||
|
loadBalancerIP: {{ .Values.replica.service.loadBalancerIP }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.replica.service.type "LoadBalancer") .Values.replica.service.loadBalancerClass }}
|
||||||
|
loadBalancerClass: {{ .Values.replica.service.loadBalancerClass }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.replica.service.type "LoadBalancer") (not (empty .Values.replica.service.loadBalancerSourceRanges)) }}
|
||||||
|
loadBalancerSourceRanges: {{ toYaml .Values.replica.service.loadBalancerSourceRanges | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and .Values.replica.service.clusterIP (eq .Values.replica.service.type "ClusterIP") }}
|
||||||
|
clusterIP: {{ .Values.replica.service.clusterIP }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.service.sessionAffinity }}
|
||||||
|
sessionAffinity: {{ .Values.replica.service.sessionAffinity }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.service.sessionAffinityConfig }}
|
||||||
|
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.replica.service.sessionAffinityConfig "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: tcp-redis
|
||||||
|
port: {{ .Values.replica.service.ports.redis }}
|
||||||
|
targetPort: redis
|
||||||
|
{{- if and (or (eq .Values.replica.service.type "NodePort") (eq .Values.replica.service.type "LoadBalancer")) .Values.replica.service.nodePorts.redis}}
|
||||||
|
nodePort: {{ .Values.replica.service.nodePorts.redis}}
|
||||||
|
{{- else if eq .Values.replica.service.type "ClusterIP" }}
|
||||||
|
nodePort: null
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.service.extraPorts }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.replica.service.extraPorts "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.replica.podLabels .Values.commonLabels ) "context" . ) }}
|
||||||
|
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: replica
|
||||||
|
{{- end }}
|
||||||
18
helm/redis/templates/replicas/serviceaccount.yaml
Normal file
18
helm/redis/templates/replicas/serviceaccount.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and .Values.replica.serviceAccount.create (eq .Values.architecture "replication") (not .Values.sentinel.enabled) }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
automountServiceAccountToken: {{ .Values.replica.serviceAccount.automountServiceAccountToken }}
|
||||||
|
metadata:
|
||||||
|
name: {{ template "redis.replicaServiceAccountName" . }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if or .Values.replica.serviceAccount.annotations .Values.commonAnnotations }}
|
||||||
|
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.replica.serviceAccount.annotations .Values.commonAnnotations ) "context" . ) }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
29
helm/redis/templates/role.yaml
Normal file
29
helm/redis/templates/role.yaml
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if .Values.rbac.create }}
|
||||||
|
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
|
||||||
|
kind: Role
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
rules:
|
||||||
|
{{- if and (include "common.capabilities.psp.supported" .) .Values.podSecurityPolicy.enabled }}
|
||||||
|
- apiGroups:
|
||||||
|
- '{{ template "podSecurityPolicy.apiGroup" . }}'
|
||||||
|
resources:
|
||||||
|
- 'podsecuritypolicies'
|
||||||
|
verbs:
|
||||||
|
- 'use'
|
||||||
|
resourceNames: [{{ printf "%s-master" (include "common.names.fullname" .) }}]
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.rbac.rules }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.rbac.rules "context" $ ) | nindent 2 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
23
helm/redis/templates/rolebinding.yaml
Normal file
23
helm/redis/templates/rolebinding.yaml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if .Values.rbac.create }}
|
||||||
|
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
|
||||||
|
kind: RoleBinding
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
roleRef:
|
||||||
|
apiGroup: rbac.authorization.k8s.io
|
||||||
|
kind: Role
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
subjects:
|
||||||
|
- kind: ServiceAccount
|
||||||
|
name: {{ template "redis.serviceAccountName" . }}
|
||||||
|
{{- end }}
|
||||||
757
helm/redis/templates/scripts-configmap.yaml
Normal file
757
helm/redis/templates/scripts-configmap.yaml
Normal file
@ -0,0 +1,757 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
data:
|
||||||
|
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled }}
|
||||||
|
start-node.sh: |
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. /opt/bitnami/scripts/libos.sh
|
||||||
|
. /opt/bitnami/scripts/liblog.sh
|
||||||
|
. /opt/bitnami/scripts/libvalidations.sh
|
||||||
|
|
||||||
|
get_port() {
|
||||||
|
hostname="$1"
|
||||||
|
type="$2"
|
||||||
|
|
||||||
|
port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
|
||||||
|
port=${!port_var}
|
||||||
|
|
||||||
|
if [ -z "$port" ]; then
|
||||||
|
case $type in
|
||||||
|
"SENTINEL")
|
||||||
|
echo {{ .Values.sentinel.containerPorts.sentinel }}
|
||||||
|
;;
|
||||||
|
"REDIS")
|
||||||
|
echo {{ .Values.master.containerPorts.redis }}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo $port
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_full_hostname() {
|
||||||
|
hostname="$1"
|
||||||
|
|
||||||
|
{{- if .Values.useExternalDNS.enabled }}
|
||||||
|
full_hostname="${hostname}.{{- include "redis.externalDNS.suffix" . }}"
|
||||||
|
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||||
|
full_hostname="${hostname}.{{- include "common.names.namespace" . }}"
|
||||||
|
{{- else }}
|
||||||
|
full_hostname="${hostname}.${HEADLESS_SERVICE}"
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if .Values.useHostnames }}
|
||||||
|
echo "${full_hostname}"
|
||||||
|
{{- else }}
|
||||||
|
retry_count=0
|
||||||
|
until getent hosts "${full_hostname}" | awk '{ print $1; exit }' | grep .; do
|
||||||
|
if [[ $retry_count -lt {{ .Values.nameResolutionThreshold }} ]]; then
|
||||||
|
sleep {{ .Values.nameResolutionTimeout }}
|
||||||
|
else
|
||||||
|
error "IP address for ${full_hostname} not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
((retry_count++))
|
||||||
|
done
|
||||||
|
{{- end }}
|
||||||
|
}
|
||||||
|
|
||||||
|
REDISPORT=$(get_port "$HOSTNAME" "REDIS")
|
||||||
|
|
||||||
|
HEADLESS_SERVICE="{{ template "common.names.fullname" . }}-headless.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||||
|
|
||||||
|
if [ -n "$REDIS_EXTERNAL_MASTER_HOST" ]; then
|
||||||
|
REDIS_SERVICE="$REDIS_EXTERNAL_MASTER_HOST"
|
||||||
|
else
|
||||||
|
REDIS_SERVICE="{{ template "common.names.fullname" . }}.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
SENTINEL_SERVICE_PORT=$(get_port "{{ include "common.names.fullname" . }}" "SENTINEL")
|
||||||
|
validate_quorum() {
|
||||||
|
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
|
||||||
|
quorum_info_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel master {{ .Values.sentinel.masterSet }}"
|
||||||
|
else
|
||||||
|
quorum_info_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel master {{ .Values.sentinel.masterSet }}"
|
||||||
|
fi
|
||||||
|
info "about to run the command: $quorum_info_command"
|
||||||
|
eval $quorum_info_command | grep -Fq "s_down"
|
||||||
|
}
|
||||||
|
|
||||||
|
trigger_manual_failover() {
|
||||||
|
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
|
||||||
|
failover_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel failover {{ .Values.sentinel.masterSet }}"
|
||||||
|
else
|
||||||
|
failover_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel failover {{ .Values.sentinel.masterSet }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "about to run the command: $failover_command"
|
||||||
|
eval $failover_command
|
||||||
|
}
|
||||||
|
|
||||||
|
get_sentinel_master_info() {
|
||||||
|
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
|
||||||
|
sentinel_info_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}timeout {{ .Values.sentinel.getMasterTimeout }} redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_TLS_CERT_FILE} --key ${REDIS_TLS_KEY_FILE} --cacert ${REDIS_TLS_CA_FILE} sentinel get-master-addr-by-name {{ .Values.sentinel.masterSet }}"
|
||||||
|
else
|
||||||
|
sentinel_info_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}timeout {{ .Values.sentinel.getMasterTimeout }} redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name {{ .Values.sentinel.masterSet }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
info "about to run the command: $sentinel_info_command"
|
||||||
|
retry_while "eval $sentinel_info_command" 2 5
|
||||||
|
}
|
||||||
|
|
||||||
|
{{- if and .Values.replica.containerSecurityContext.runAsUser (eq (.Values.replica.containerSecurityContext.runAsUser | int) 0) }}
|
||||||
|
useradd redis
|
||||||
|
chown -R redis {{ .Values.replica.persistence.path }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||||
|
[[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
|
||||||
|
|
||||||
|
# check if there is a master
|
||||||
|
master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
|
||||||
|
master_port_in_persisted_conf="$REDIS_MASTER_PORT_NUMBER"
|
||||||
|
master_in_sentinel="$(get_sentinel_master_info)"
|
||||||
|
redisRetVal=$?
|
||||||
|
|
||||||
|
{{- if .Values.sentinel.persistence.enabled }}
|
||||||
|
if [[ -f /opt/bitnami/redis-sentinel/etc/sentinel.conf ]]; then
|
||||||
|
master_in_persisted_conf="$(awk '/monitor/ {print $4}' /opt/bitnami/redis-sentinel/etc/sentinel.conf)"
|
||||||
|
master_port_in_persisted_conf="$(awk '/monitor/ {print $5}' /opt/bitnami/redis-sentinel/etc/sentinel.conf)"
|
||||||
|
info "Found previous master ${master_in_persisted_conf}:${master_port_in_persisted_conf} in /opt/bitnami/redis-sentinel/etc/sentinel.conf"
|
||||||
|
debug "$(cat /opt/bitnami/redis-sentinel/etc/sentinel.conf | grep monitor)"
|
||||||
|
touch /opt/bitnami/redis-sentinel/etc/.node_read
|
||||||
|
fi
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
if [[ $redisRetVal -ne 0 ]]; then
|
||||||
|
if [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
|
||||||
|
# Case 1: No active sentinel and in previous sentinel.conf we were the master --> MASTER
|
||||||
|
info "Configuring the node as master"
|
||||||
|
export REDIS_REPLICATION_MODE="master"
|
||||||
|
else
|
||||||
|
# Case 2: No active sentinel and in previous sentinel.conf we were not master --> REPLICA
|
||||||
|
info "Configuring the node as replica"
|
||||||
|
export REDIS_REPLICATION_MODE="replica"
|
||||||
|
REDIS_MASTER_HOST=${master_in_persisted_conf}
|
||||||
|
REDIS_MASTER_PORT_NUMBER=${master_port_in_persisted_conf}
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# Fetches current master's host and port
|
||||||
|
REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
|
||||||
|
info "Current master: REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
|
||||||
|
REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
|
||||||
|
REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
|
||||||
|
|
||||||
|
if [[ "$REDIS_MASTER_HOST" == "$(get_full_hostname "$HOSTNAME")" ]]; then
|
||||||
|
# Case 3: Active sentinel and master it is this node --> MASTER
|
||||||
|
info "Configuring the node as master"
|
||||||
|
export REDIS_REPLICATION_MODE="master"
|
||||||
|
else
|
||||||
|
# Case 4: Active sentinel and master is not this node --> REPLICA
|
||||||
|
info "Configuring the node as replica"
|
||||||
|
export REDIS_REPLICATION_MODE="replica"
|
||||||
|
|
||||||
|
{{- if and .Values.sentinel.automateClusterRecovery (le (int .Values.sentinel.downAfterMilliseconds) 2000) }}
|
||||||
|
retry_count=1
|
||||||
|
while validate_quorum
|
||||||
|
do
|
||||||
|
info "sleeping, waiting for Redis master to come up"
|
||||||
|
sleep 1s
|
||||||
|
if ! ((retry_count % 11)); then
|
||||||
|
info "Trying to manually failover"
|
||||||
|
failover_result=$(trigger_manual_failover)
|
||||||
|
|
||||||
|
debug "Failover result: $failover_result"
|
||||||
|
fi
|
||||||
|
|
||||||
|
((retry_count+=1))
|
||||||
|
done
|
||||||
|
info "Redis master is up now"
|
||||||
|
{{- end }}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
|
||||||
|
REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
|
||||||
|
REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f /opt/bitnami/redis/mounted-etc/replica.conf ]];then
|
||||||
|
cp /opt/bitnami/redis/mounted-etc/replica.conf /opt/bitnami/redis/etc/replica.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -f /opt/bitnami/redis/mounted-etc/redis.conf ]];then
|
||||||
|
cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "" >> /opt/bitnami/redis/etc/replica.conf
|
||||||
|
echo "replica-announce-port $REDISPORT" >> /opt/bitnami/redis/etc/replica.conf
|
||||||
|
echo "replica-announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis/etc/replica.conf
|
||||||
|
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
ARGS=("--port" "0")
|
||||||
|
ARGS+=("--tls-port" "${REDIS_TLS_PORT}")
|
||||||
|
ARGS+=("--tls-cert-file" "${REDIS_TLS_CERT_FILE}")
|
||||||
|
ARGS+=("--tls-key-file" "${REDIS_TLS_KEY_FILE}")
|
||||||
|
ARGS+=("--tls-ca-cert-file" "${REDIS_TLS_CA_FILE}")
|
||||||
|
ARGS+=("--tls-auth-clients" "${REDIS_TLS_AUTH_CLIENTS}")
|
||||||
|
ARGS+=("--tls-replication" "yes")
|
||||||
|
{{- if .Values.tls.dhParamsFilename }}
|
||||||
|
ARGS+=("--tls-dh-params-file" "${REDIS_TLS_DH_PARAMS_FILE}")
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
ARGS=("--port" "${REDIS_PORT}")
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
if [[ "$REDIS_REPLICATION_MODE" = "slave" ]] || [[ "$REDIS_REPLICATION_MODE" = "replica" ]]; then
|
||||||
|
ARGS+=("--replicaof" "${REDIS_MASTER_HOST}" "${REDIS_MASTER_PORT_NUMBER}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
{{- if .Values.auth.enabled }}
|
||||||
|
ARGS+=("--requirepass" "${REDIS_PASSWORD}")
|
||||||
|
ARGS+=("--masterauth" "${REDIS_MASTER_PASSWORD}")
|
||||||
|
{{- else }}
|
||||||
|
ARGS+=("--protected-mode" "no")
|
||||||
|
{{- end }}
|
||||||
|
ARGS+=("--include" "/opt/bitnami/redis/etc/replica.conf")
|
||||||
|
ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
|
||||||
|
{{- if .Values.replica.extraFlags }}
|
||||||
|
{{- range .Values.replica.extraFlags }}
|
||||||
|
ARGS+=({{ . | quote }})
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if .Values.replica.preExecCmds }}
|
||||||
|
{{- .Values.replica.preExecCmds | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if .Values.replica.command }}
|
||||||
|
exec {{ .Values.replica.command }} "${ARGS[@]}"
|
||||||
|
{{- else }}
|
||||||
|
exec redis-server "${ARGS[@]}"
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
start-sentinel.sh: |
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. /opt/bitnami/scripts/libos.sh
|
||||||
|
. /opt/bitnami/scripts/libvalidations.sh
|
||||||
|
. /opt/bitnami/scripts/libfile.sh
|
||||||
|
|
||||||
|
HEADLESS_SERVICE="{{ template "common.names.fullname" . }}-headless.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||||
|
REDIS_SERVICE="{{ template "common.names.fullname" . }}.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||||
|
|
||||||
|
get_port() {
|
||||||
|
hostname="$1"
|
||||||
|
type="$2"
|
||||||
|
|
||||||
|
port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
|
||||||
|
port=${!port_var}
|
||||||
|
|
||||||
|
if [ -z "$port" ]; then
|
||||||
|
case $type in
|
||||||
|
"SENTINEL")
|
||||||
|
echo {{ .Values.sentinel.containerPorts.sentinel }}
|
||||||
|
;;
|
||||||
|
"REDIS")
|
||||||
|
echo {{ .Values.master.containerPorts.redis }}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo $port
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_full_hostname() {
|
||||||
|
hostname="$1"
|
||||||
|
|
||||||
|
{{- if .Values.useExternalDNS.enabled }}
|
||||||
|
full_hostname="${hostname}.{{- include "redis.externalDNS.suffix" . }}"
|
||||||
|
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||||
|
full_hostname="${hostname}.{{- include "common.names.namespace" . }}"
|
||||||
|
{{- else }}
|
||||||
|
full_hostname="${hostname}.${HEADLESS_SERVICE}"
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if .Values.useHostnames }}
|
||||||
|
echo "${full_hostname}"
|
||||||
|
{{- else }}
|
||||||
|
retry_count=0
|
||||||
|
until getent hosts "${full_hostname}" | awk '{ print $1; exit }' | grep .; do
|
||||||
|
if [[ $retry_count -lt {{ .Values.nameResolutionThreshold }} ]]; then
|
||||||
|
sleep {{ .Values.nameResolutionTimeout }}
|
||||||
|
else
|
||||||
|
error "IP address for ${full_hostname} not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
((retry_count++))
|
||||||
|
done
|
||||||
|
{{- end }}
|
||||||
|
}
|
||||||
|
|
||||||
|
SERVPORT=$(get_port "$HOSTNAME" "SENTINEL")
|
||||||
|
REDISPORT=$(get_port "$HOSTNAME" "REDIS")
|
||||||
|
SENTINEL_SERVICE_PORT=$(get_port "{{ include "common.names.fullname" . }}" "SENTINEL")
|
||||||
|
|
||||||
|
sentinel_conf_set() {
|
||||||
|
local -r key="${1:?missing key}"
|
||||||
|
local value="${2:-}"
|
||||||
|
|
||||||
|
# Sanitize inputs
|
||||||
|
value="${value//\\/\\\\}"
|
||||||
|
value="${value//&/\\&}"
|
||||||
|
value="${value//\?/\\?}"
|
||||||
|
[[ "$value" = "" ]] && value="\"$value\""
|
||||||
|
|
||||||
|
replace_in_file "/opt/bitnami/redis-sentinel/etc/sentinel.conf" "^#*\s*${key} .*" "${key} ${value}" false
|
||||||
|
}
|
||||||
|
sentinel_conf_add() {
|
||||||
|
echo $'\n'"$@" >> "/opt/bitnami/redis-sentinel/etc/sentinel.conf"
|
||||||
|
}
|
||||||
|
host_id() {
|
||||||
|
echo "$1" | openssl sha1 | awk '{print $2}'
|
||||||
|
}
|
||||||
|
get_sentinel_master_info() {
|
||||||
|
if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
|
||||||
|
sentinel_info_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}timeout {{ .Values.sentinel.getMasterTimeout }} redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT --tls --cert ${REDIS_SENTINEL_TLS_CERT_FILE} --key ${REDIS_SENTINEL_TLS_KEY_FILE} --cacert ${REDIS_SENTINEL_TLS_CA_FILE} sentinel get-master-addr-by-name {{ .Values.sentinel.masterSet }}"
|
||||||
|
else
|
||||||
|
sentinel_info_command="{{- if and .Values.auth.enabled .Values.auth.sentinel }}REDISCLI_AUTH="\$REDIS_PASSWORD" {{ end }}timeout {{ .Values.sentinel.getMasterTimeout }} redis-cli -h $REDIS_SERVICE -p $SENTINEL_SERVICE_PORT sentinel get-master-addr-by-name {{ .Values.sentinel.masterSet }}"
|
||||||
|
fi
|
||||||
|
info "about to run the command: $sentinel_info_command"
|
||||||
|
retry_while "eval $sentinel_info_command" 2 5
|
||||||
|
}
|
||||||
|
|
||||||
|
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||||
|
|
||||||
|
master_in_persisted_conf="$(get_full_hostname "$HOSTNAME")"
|
||||||
|
|
||||||
|
{{- if .Values.sentinel.persistence.enabled }}
|
||||||
|
if [[ -f /opt/bitnami/redis-sentinel/etc/sentinel.conf ]]; then
|
||||||
|
check_lock_file() {
|
||||||
|
[[ -f /opt/bitnami/redis-sentinel/etc/.node_read ]]
|
||||||
|
}
|
||||||
|
retry_while "check_lock_file"
|
||||||
|
rm -f /opt/bitnami/redis-sentinel/etc/.node_read
|
||||||
|
master_in_persisted_conf="$(awk '/monitor/ {print $4}' /opt/bitnami/redis-sentinel/etc/sentinel.conf)"
|
||||||
|
info "Found previous master $master_in_persisted_conf in /opt/bitnami/redis-sentinel/etc/sentinel.conf"
|
||||||
|
debug "$(cat /opt/bitnami/redis-sentinel/etc/sentinel.conf | grep monitor)"
|
||||||
|
fi
|
||||||
|
{{- end }}
|
||||||
|
if ! get_sentinel_master_info && [[ "$master_in_persisted_conf" == "$(get_full_hostname "$HOSTNAME")" ]]; then
|
||||||
|
# No master found, lets create a master node
|
||||||
|
export REDIS_REPLICATION_MODE="master"
|
||||||
|
|
||||||
|
REDIS_MASTER_HOST=$(get_full_hostname "$HOSTNAME")
|
||||||
|
REDIS_MASTER_PORT_NUMBER="$REDISPORT"
|
||||||
|
else
|
||||||
|
export REDIS_REPLICATION_MODE="replica"
|
||||||
|
|
||||||
|
# Fetches current master's host and port
|
||||||
|
REDIS_SENTINEL_INFO=($(get_sentinel_master_info))
|
||||||
|
info "printing REDIS_SENTINEL_INFO=(${REDIS_SENTINEL_INFO[0]},${REDIS_SENTINEL_INFO[1]})"
|
||||||
|
REDIS_MASTER_HOST=${REDIS_SENTINEL_INFO[0]}
|
||||||
|
REDIS_MASTER_PORT_NUMBER=${REDIS_SENTINEL_INFO[1]}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$REDIS_EXTERNAL_MASTER_HOST" ]]; then
|
||||||
|
REDIS_MASTER_HOST="$REDIS_EXTERNAL_MASTER_HOST"
|
||||||
|
REDIS_MASTER_PORT_NUMBER="${REDIS_EXTERNAL_MASTER_PORT}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cp /opt/bitnami/redis-sentinel/mounted-etc/sentinel.conf /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||||
|
{{- if .Values.auth.enabled }}
|
||||||
|
printf "\nsentinel auth-pass %s %s" "{{ .Values.sentinel.masterSet }}" "$REDIS_PASSWORD" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||||
|
{{- if and .Values.auth.enabled .Values.auth.sentinel }}
|
||||||
|
printf "\nrequirepass %s" "$REDIS_PASSWORD" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
printf "\nsentinel myid %s" "$(host_id "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||||
|
|
||||||
|
if [[ -z "$REDIS_MASTER_HOST" ]] || [[ -z "$REDIS_MASTER_PORT_NUMBER" ]]
|
||||||
|
then
|
||||||
|
# Prevent incorrect configuration to be written to sentinel.conf
|
||||||
|
error "Redis master host is configured incorrectly (host: $REDIS_MASTER_HOST, port: $REDIS_MASTER_PORT_NUMBER)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
sentinel_conf_set "sentinel monitor" "{{ .Values.sentinel.masterSet }} "$REDIS_MASTER_HOST" "$REDIS_MASTER_PORT_NUMBER" {{ .Values.sentinel.quorum }}"
|
||||||
|
|
||||||
|
add_known_sentinel() {
|
||||||
|
hostname="$1"
|
||||||
|
ip="$2"
|
||||||
|
|
||||||
|
if [[ -n "$hostname" && -n "$ip" && "$hostname" != "$HOSTNAME" ]]; then
|
||||||
|
sentinel_conf_add "sentinel known-sentinel {{ .Values.sentinel.masterSet }} $(get_full_hostname "$hostname") $(get_port "$hostname" "SENTINEL") $(host_id "$hostname")"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
add_known_replica() {
|
||||||
|
hostname="$1"
|
||||||
|
ip="$2"
|
||||||
|
|
||||||
|
if [[ -n "$ip" && "$(get_full_hostname "$hostname")" != "$REDIS_MASTER_HOST" ]]; then
|
||||||
|
sentinel_conf_add "sentinel known-replica {{ .Values.sentinel.masterSet }} $(get_full_hostname "$hostname") $(get_port "$hostname" "REDIS")"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add available hosts on the network as known replicas & sentinels
|
||||||
|
for node in $(seq 0 $(({{ .Values.replica.replicaCount }}-1))); do
|
||||||
|
hostname="{{ template "common.names.fullname" . }}-node-$node"
|
||||||
|
ip="$(getent hosts "$hostname.$HEADLESS_SERVICE" | awk '{ print $1 }')"
|
||||||
|
add_known_sentinel "$hostname" "$ip"
|
||||||
|
add_known_replica "$hostname" "$ip"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||||
|
{{- if not (contains "sentinel announce-hostnames" .Values.sentinel.configuration) }}
|
||||||
|
echo "sentinel announce-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||||
|
{{- end }}
|
||||||
|
{{- if not (contains "sentinel resolve-hostnames" .Values.sentinel.configuration) }}
|
||||||
|
echo "sentinel resolve-hostnames yes" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||||
|
{{- end }}
|
||||||
|
{{- if not (contains "sentinel announce-port" .Values.sentinel.configuration) }}
|
||||||
|
echo "sentinel announce-port $SERVPORT" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||||
|
{{- end }}
|
||||||
|
{{- if not (contains "sentinel announce-ip" .Values.sentinel.configuration) }}
|
||||||
|
echo "sentinel announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis-sentinel/etc/sentinel.conf
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
ARGS=("--port" "0")
|
||||||
|
ARGS+=("--tls-port" "${REDIS_SENTINEL_TLS_PORT_NUMBER}")
|
||||||
|
ARGS+=("--tls-cert-file" "${REDIS_SENTINEL_TLS_CERT_FILE}")
|
||||||
|
ARGS+=("--tls-key-file" "${REDIS_SENTINEL_TLS_KEY_FILE}")
|
||||||
|
ARGS+=("--tls-ca-cert-file" "${REDIS_SENTINEL_TLS_CA_FILE}")
|
||||||
|
ARGS+=("--tls-replication" "yes")
|
||||||
|
ARGS+=("--tls-auth-clients" "${REDIS_SENTINEL_TLS_AUTH_CLIENTS}")
|
||||||
|
{{- if .Values.tls.dhParamsFilename }}
|
||||||
|
ARGS+=("--tls-dh-params-file" "${REDIS_SENTINEL_TLS_DH_PARAMS_FILE}")
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.preExecCmds }}
|
||||||
|
{{ .Values.sentinel.preExecCmds | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
exec redis-server /opt/bitnami/redis-sentinel/etc/sentinel.conf {{- if .Values.tls.enabled }} "${ARGS[@]}" {{- end }} --sentinel
|
||||||
|
prestop-sentinel.sh: |
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. /opt/bitnami/scripts/libvalidations.sh
|
||||||
|
. /opt/bitnami/scripts/libos.sh
|
||||||
|
|
||||||
|
HEADLESS_SERVICE="{{ template "common.names.fullname" . }}-headless.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||||
|
|
||||||
|
get_full_hostname() {
|
||||||
|
hostname="$1"
|
||||||
|
|
||||||
|
{{- if .Values.useExternalDNS.enabled }}
|
||||||
|
full_hostname="${hostname}.{{- include "redis.externalDNS.suffix" . }}"
|
||||||
|
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||||
|
full_hostname="${hostname}.{{- include "common.names.namespace" . }}"
|
||||||
|
{{- else }}
|
||||||
|
full_hostname="${hostname}.${HEADLESS_SERVICE}"
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if .Values.useHostnames }}
|
||||||
|
echo "${full_hostname}"
|
||||||
|
{{- else }}
|
||||||
|
retry_count=0
|
||||||
|
until getent hosts "${full_hostname}" | awk '{ print $1; exit }' | grep .; do
|
||||||
|
if [[ $retry_count -lt {{ .Values.nameResolutionThreshold }} ]]; then
|
||||||
|
sleep {{ .Values.nameResolutionTimeout }}
|
||||||
|
else
|
||||||
|
error "IP address for ${full_hostname} not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
((retry_count++))
|
||||||
|
done
|
||||||
|
{{- end }}
|
||||||
|
}
|
||||||
|
|
||||||
|
run_sentinel_command() {
|
||||||
|
if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
|
||||||
|
redis-cli -h "$REDIS_SERVICE" -p "$REDIS_SENTINEL_PORT" --tls --cert "$REDIS_SENTINEL_TLS_CERT_FILE" --key "$REDIS_SENTINEL_TLS_KEY_FILE" --cacert "$REDIS_SENTINEL_TLS_CA_FILE" sentinel "$@"
|
||||||
|
else
|
||||||
|
redis-cli -h "$REDIS_SERVICE" -p "$REDIS_SENTINEL_PORT" sentinel "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
sentinel_failover_finished() {
|
||||||
|
REDIS_SENTINEL_INFO=($(run_sentinel_command get-master-addr-by-name "{{ .Values.sentinel.masterSet }}"))
|
||||||
|
REDIS_MASTER_HOST="${REDIS_SENTINEL_INFO[0]}"
|
||||||
|
[[ "$REDIS_MASTER_HOST" != "$(get_full_hostname $HOSTNAME)" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
REDIS_SERVICE="{{ include "common.names.fullname" . }}.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||||
|
|
||||||
|
{{ if .Values.auth.sentinel -}}
|
||||||
|
# redis-cli automatically consumes credentials from the REDISCLI_AUTH variable
|
||||||
|
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
|
||||||
|
[[ -f "$REDIS_PASSWORD_FILE" ]] && export REDISCLI_AUTH="$(< "${REDIS_PASSWORD_FILE}")"
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
if ! sentinel_failover_finished; then
|
||||||
|
echo "I am the master pod and you are stopping me. Starting sentinel failover"
|
||||||
|
if retry_while "sentinel_failover_finished" "{{ sub .Values.sentinel.terminationGracePeriodSeconds 10 }}" 1; then
|
||||||
|
echo "Master has been successfuly failed over to a different pod."
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Master failover failed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
prestop-redis.sh: |
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. /opt/bitnami/scripts/libvalidations.sh
|
||||||
|
. /opt/bitnami/scripts/libos.sh
|
||||||
|
|
||||||
|
run_redis_command() {
|
||||||
|
if is_boolean_yes "$REDIS_TLS_ENABLED"; then
|
||||||
|
redis-cli -h 127.0.0.1 -p "$REDIS_TLS_PORT" --tls --cert "$REDIS_TLS_CERT_FILE" --key "$REDIS_TLS_KEY_FILE" --cacert "$REDIS_TLS_CA_FILE" "$@"
|
||||||
|
else
|
||||||
|
redis-cli -h 127.0.0.1 -p "$REDIS_PORT" "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
is_master() {
|
||||||
|
REDIS_ROLE=$(run_redis_command role | head -1)
|
||||||
|
[[ "$REDIS_ROLE" == "master" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
HEADLESS_SERVICE="{{ template "common.names.fullname" . }}-headless.{{- include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||||
|
|
||||||
|
get_full_hostname() {
|
||||||
|
hostname="$1"
|
||||||
|
|
||||||
|
{{- if .Values.useExternalDNS.enabled }}
|
||||||
|
full_hostname="${hostname}.{{- include "redis.externalDNS.suffix" . }}"
|
||||||
|
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||||
|
full_hostname="${hostname}.{{- include "common.names.namespace" . }}"
|
||||||
|
{{- else }}
|
||||||
|
full_hostname="${hostname}.${HEADLESS_SERVICE}"
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if .Values.useHostnames }}
|
||||||
|
echo "${full_hostname}"
|
||||||
|
{{- else }}
|
||||||
|
retry_count=0
|
||||||
|
until getent hosts "${full_hostname}" | awk '{ print $1; exit }' | grep .; do
|
||||||
|
if [[ $retry_count -lt {{ .Values.nameResolutionThreshold }} ]]; then
|
||||||
|
sleep {{ .Values.nameResolutionTimeout }}
|
||||||
|
else
|
||||||
|
error "IP address for ${full_hostname} not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
((retry_count++))
|
||||||
|
done
|
||||||
|
{{- end }}
|
||||||
|
}
|
||||||
|
|
||||||
|
run_sentinel_command() {
|
||||||
|
if is_boolean_yes "$REDIS_SENTINEL_TLS_ENABLED"; then
|
||||||
|
{{ .Values.auth.sentinel | ternary "" "env -u REDISCLI_AUTH " -}} redis-cli -h "$REDIS_SERVICE" -p "$REDIS_SENTINEL_PORT" --tls --cert "$REDIS_SENTINEL_TLS_CERT_FILE" --key "$REDIS_SENTINEL_TLS_KEY_FILE" --cacert "$REDIS_SENTINEL_TLS_CA_FILE" sentinel "$@"
|
||||||
|
else
|
||||||
|
{{ .Values.auth.sentinel | ternary "" "env -u REDISCLI_AUTH " -}} redis-cli -h "$REDIS_SERVICE" -p "$REDIS_SENTINEL_PORT" sentinel "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
sentinel_failover_finished() {
|
||||||
|
REDIS_SENTINEL_INFO=($(run_sentinel_command get-master-addr-by-name "{{ .Values.sentinel.masterSet }}"))
|
||||||
|
REDIS_MASTER_HOST="${REDIS_SENTINEL_INFO[0]}"
|
||||||
|
[[ "$REDIS_MASTER_HOST" != "$(get_full_hostname $HOSTNAME)" ]]
|
||||||
|
}
|
||||||
|
|
||||||
|
REDIS_SERVICE="{{ include "common.names.fullname" . }}.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||||
|
|
||||||
|
# redis-cli automatically consumes credentials from the REDISCLI_AUTH variable
|
||||||
|
[[ -n "$REDIS_PASSWORD" ]] && export REDISCLI_AUTH="$REDIS_PASSWORD"
|
||||||
|
[[ -f "$REDIS_PASSWORD_FILE" ]] && export REDISCLI_AUTH="$(< "${REDIS_PASSWORD_FILE}")"
|
||||||
|
|
||||||
|
|
||||||
|
if is_master && ! sentinel_failover_finished; then
|
||||||
|
echo "I am the master pod and you are stopping me. Pausing client connections."
|
||||||
|
# Pausing client write connections to avoid data loss
|
||||||
|
run_redis_command CLIENT PAUSE "{{ mul (add 2 (sub .Values.sentinel.terminationGracePeriodSeconds 10)) 1000 }}" WRITE
|
||||||
|
|
||||||
|
echo "Issuing failover"
|
||||||
|
# if I am the master, issue a command to failover once
|
||||||
|
run_sentinel_command failover "{{ .Values.sentinel.masterSet }}"
|
||||||
|
|
||||||
|
{{- if .Values.sentinel.redisShutdownWaitFailover }}
|
||||||
|
echo "Waiting for sentinel to complete failover for up to {{ sub .Values.sentinel.terminationGracePeriodSeconds 10 }}s"
|
||||||
|
retry_while "sentinel_failover_finished" "{{ sub .Values.sentinel.terminationGracePeriodSeconds 10 }}" 1
|
||||||
|
{{- end }}
|
||||||
|
else
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
{{- else }}
|
||||||
|
start-master.sh: |
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||||
|
{{- if and .Values.master.containerSecurityContext.runAsUser (eq (.Values.master.containerSecurityContext.runAsUser | int) 0) }}
|
||||||
|
useradd redis
|
||||||
|
chown -R redis {{ .Values.master.persistence.path }}
|
||||||
|
{{- end }}
|
||||||
|
if [[ -f /opt/bitnami/redis/mounted-etc/master.conf ]];then
|
||||||
|
cp /opt/bitnami/redis/mounted-etc/master.conf /opt/bitnami/redis/etc/master.conf
|
||||||
|
fi
|
||||||
|
if [[ -f /opt/bitnami/redis/mounted-etc/redis.conf ]];then
|
||||||
|
cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
|
||||||
|
fi
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
ARGS=("--port" "0")
|
||||||
|
ARGS+=("--tls-port" "${REDIS_TLS_PORT}")
|
||||||
|
ARGS+=("--tls-cert-file" "${REDIS_TLS_CERT_FILE}")
|
||||||
|
ARGS+=("--tls-key-file" "${REDIS_TLS_KEY_FILE}")
|
||||||
|
ARGS+=("--tls-ca-cert-file" "${REDIS_TLS_CA_FILE}")
|
||||||
|
ARGS+=("--tls-auth-clients" "${REDIS_TLS_AUTH_CLIENTS}")
|
||||||
|
{{- if .Values.tls.dhParamsFilename }}
|
||||||
|
ARGS+=("--tls-dh-params-file" "${REDIS_TLS_DH_PARAMS_FILE}")
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
ARGS=("--port" "${REDIS_PORT}")
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.auth.enabled }}
|
||||||
|
ARGS+=("--requirepass" "${REDIS_PASSWORD}")
|
||||||
|
ARGS+=("--masterauth" "${REDIS_PASSWORD}")
|
||||||
|
{{- else }}
|
||||||
|
ARGS+=("--protected-mode" "no")
|
||||||
|
{{- end }}
|
||||||
|
ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
|
||||||
|
ARGS+=("--include" "/opt/bitnami/redis/etc/master.conf")
|
||||||
|
{{- if .Values.master.extraFlags }}
|
||||||
|
{{- range .Values.master.extraFlags }}
|
||||||
|
ARGS+=({{ . | quote }})
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.preExecCmds }}
|
||||||
|
{{ .Values.master.preExecCmds | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.master.command }}
|
||||||
|
exec {{ .Values.master.command }} "${ARGS[@]}"
|
||||||
|
{{- else }}
|
||||||
|
exec redis-server "${ARGS[@]}"
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq .Values.architecture "replication" }}
|
||||||
|
start-replica.sh: |
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
get_port() {
|
||||||
|
hostname="$1"
|
||||||
|
type="$2"
|
||||||
|
|
||||||
|
port_var=$(echo "${hostname^^}_SERVICE_PORT_$type" | sed "s/-/_/g")
|
||||||
|
port=${!port_var}
|
||||||
|
|
||||||
|
if [ -z "$port" ]; then
|
||||||
|
case $type in
|
||||||
|
"SENTINEL")
|
||||||
|
echo {{ .Values.sentinel.containerPorts.sentinel }}
|
||||||
|
;;
|
||||||
|
"REDIS")
|
||||||
|
echo {{ .Values.master.containerPorts.redis }}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo $port
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
get_full_hostname() {
|
||||||
|
hostname="$1"
|
||||||
|
|
||||||
|
{{- if .Values.useExternalDNS.enabled }}
|
||||||
|
full_hostname="${hostname}.{{- include "redis.externalDNS.suffix" . }}"
|
||||||
|
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||||
|
full_hostname="${hostname}.{{- include "common.names.namespace" . }}"
|
||||||
|
{{- else }}
|
||||||
|
full_hostname="${hostname}.${HEADLESS_SERVICE}"
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- if .Values.useHostnames }}
|
||||||
|
echo "${full_hostname}"
|
||||||
|
{{- else }}
|
||||||
|
retry_count=0
|
||||||
|
until getent hosts "${full_hostname}" | awk '{ print $1; exit }' | grep .; do
|
||||||
|
if [[ $retry_count -lt {{ .Values.nameResolutionThreshold }} ]]; then
|
||||||
|
sleep {{ .Values.nameResolutionTimeout }}
|
||||||
|
else
|
||||||
|
error "IP address for ${full_hostname} not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
((retry_count++))
|
||||||
|
done
|
||||||
|
{{- end }}
|
||||||
|
}
|
||||||
|
|
||||||
|
REDISPORT=$(get_port "$HOSTNAME" "REDIS")
|
||||||
|
HEADLESS_SERVICE="{{ template "common.names.fullname" . }}-headless.{{ include "common.names.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||||
|
|
||||||
|
[[ -f $REDIS_PASSWORD_FILE ]] && export REDIS_PASSWORD="$(< "${REDIS_PASSWORD_FILE}")"
|
||||||
|
[[ -f $REDIS_MASTER_PASSWORD_FILE ]] && export REDIS_MASTER_PASSWORD="$(< "${REDIS_MASTER_PASSWORD_FILE}")"
|
||||||
|
{{- if and .Values.replica.containerSecurityContext.runAsUser (eq (.Values.replica.containerSecurityContext.runAsUser | int) 0) }}
|
||||||
|
useradd redis
|
||||||
|
chown -R redis {{ .Values.replica.persistence.path }}
|
||||||
|
{{- end }}
|
||||||
|
if [[ -f /opt/bitnami/redis/mounted-etc/replica.conf ]];then
|
||||||
|
cp /opt/bitnami/redis/mounted-etc/replica.conf /opt/bitnami/redis/etc/replica.conf
|
||||||
|
fi
|
||||||
|
if [[ -f /opt/bitnami/redis/mounted-etc/redis.conf ]];then
|
||||||
|
cp /opt/bitnami/redis/mounted-etc/redis.conf /opt/bitnami/redis/etc/redis.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "" >> /opt/bitnami/redis/etc/replica.conf
|
||||||
|
echo "replica-announce-port $REDISPORT" >> /opt/bitnami/redis/etc/replica.conf
|
||||||
|
echo "replica-announce-ip $(get_full_hostname "$HOSTNAME")" >> /opt/bitnami/redis/etc/replica.conf
|
||||||
|
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
ARGS=("--port" "0")
|
||||||
|
ARGS+=("--tls-port" "${REDIS_TLS_PORT}")
|
||||||
|
ARGS+=("--tls-cert-file" "${REDIS_TLS_CERT_FILE}")
|
||||||
|
ARGS+=("--tls-key-file" "${REDIS_TLS_KEY_FILE}")
|
||||||
|
ARGS+=("--tls-ca-cert-file" "${REDIS_TLS_CA_FILE}")
|
||||||
|
ARGS+=("--tls-auth-clients" "${REDIS_TLS_AUTH_CLIENTS}")
|
||||||
|
ARGS+=("--tls-replication" "yes")
|
||||||
|
{{- if .Values.tls.dhParamsFilename }}
|
||||||
|
ARGS+=("--tls-dh-params-file" "${REDIS_TLS_DH_PARAMS_FILE}")
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
ARGS=("--port" "${REDIS_PORT}")
|
||||||
|
{{- end }}
|
||||||
|
ARGS+=("--replicaof" "${REDIS_MASTER_HOST}" "${REDIS_MASTER_PORT_NUMBER}")
|
||||||
|
{{- if .Values.auth.enabled }}
|
||||||
|
ARGS+=("--requirepass" "${REDIS_PASSWORD}")
|
||||||
|
ARGS+=("--masterauth" "${REDIS_MASTER_PASSWORD}")
|
||||||
|
{{- else }}
|
||||||
|
ARGS+=("--protected-mode" "no")
|
||||||
|
{{- end }}
|
||||||
|
ARGS+=("--include" "/opt/bitnami/redis/etc/redis.conf")
|
||||||
|
ARGS+=("--include" "/opt/bitnami/redis/etc/replica.conf")
|
||||||
|
{{- if .Values.replica.extraFlags }}
|
||||||
|
{{- range .Values.replica.extraFlags }}
|
||||||
|
ARGS+=({{ . | quote }})
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.preExecCmds }}
|
||||||
|
{{ .Values.replica.preExecCmds | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.command }}
|
||||||
|
exec {{ .Values.replica.command }} "${ARGS[@]}"
|
||||||
|
{{- else }}
|
||||||
|
exec redis-server "${ARGS[@]}"
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
37
helm/redis/templates/secret-svcbind.yaml
Normal file
37
helm/redis/templates/secret-svcbind.yaml
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if .Values.serviceBindings.enabled }}
|
||||||
|
{{- $host := include "common.names.fullname" . }}
|
||||||
|
{{- if not .Values.sentinel.enabled }}
|
||||||
|
{{- $host = printf "%s-master" (include "common.names.fullname" .) }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $port := print .Values.master.service.ports.redis }}
|
||||||
|
{{- if .Values.sentinel.enabled }}
|
||||||
|
{{- $port = print .Values.sentinel.service.ports.redis }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $password := include "redis.password" . }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: {{ include "common.names.fullname" . }}-svcbind
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
type: servicebinding.io/redis
|
||||||
|
data:
|
||||||
|
provider: {{ print "bitnami" | b64enc | quote }}
|
||||||
|
type: {{ print "redis" | b64enc | quote }}
|
||||||
|
host: {{ print $host | b64enc | quote }}
|
||||||
|
port: {{ print $port | b64enc | quote }}
|
||||||
|
password: {{ print $password | b64enc | quote }}
|
||||||
|
{{- if $password }}
|
||||||
|
uri: {{ printf "redis://:%s@%s:%s" $password $host $port | b64enc | quote }}
|
||||||
|
{{- else }}
|
||||||
|
uri: {{ printf "redis://%s:%s" $host $port | b64enc | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
25
helm/redis/templates/secret.yaml
Normal file
25
helm/redis/templates/secret.yaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and .Values.auth.enabled (not .Values.auth.existingSecret) -}}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if or .Values.secretAnnotations .Values.commonAnnotations }}
|
||||||
|
annotations:
|
||||||
|
{{- if .Values.secretAnnotations }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.secretAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
type: Opaque
|
||||||
|
data:
|
||||||
|
redis-password: {{ include "redis.password" . | b64enc | quote }}
|
||||||
|
{{- end -}}
|
||||||
49
helm/redis/templates/sentinel/hpa.yaml
Normal file
49
helm/redis/templates/sentinel/hpa.yaml
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and .Values.replica.autoscaling.enabled .Values.sentinel.enabled }}
|
||||||
|
apiVersion: {{ include "common.capabilities.hpa.apiVersion" ( dict "context" $ ) }}
|
||||||
|
kind: HorizontalPodAutoscaler
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-node" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: replica
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
scaleTargetRef:
|
||||||
|
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
|
||||||
|
kind: StatefulSet
|
||||||
|
name: {{ printf "%s-node" (include "common.names.fullname" .) }}
|
||||||
|
minReplicas: {{ .Values.replica.autoscaling.minReplicas }}
|
||||||
|
maxReplicas: {{ .Values.replica.autoscaling.maxReplicas }}
|
||||||
|
metrics:
|
||||||
|
{{- if .Values.replica.autoscaling.targetMemory }}
|
||||||
|
- type: Resource
|
||||||
|
resource:
|
||||||
|
name: memory
|
||||||
|
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
|
||||||
|
targetAverageUtilization: {{ .Values.replica.autoscaling.targetMemory }}
|
||||||
|
{{- else }}
|
||||||
|
target:
|
||||||
|
type: Utilization
|
||||||
|
averageUtilization: {{ .Values.replica.autoscaling.targetMemory }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.autoscaling.targetCPU }}
|
||||||
|
- type: Resource
|
||||||
|
resource:
|
||||||
|
name: cpu
|
||||||
|
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .) }}
|
||||||
|
targetAverageUtilization: {{ .Values.replica.autoscaling.targetCPU }}
|
||||||
|
{{- else }}
|
||||||
|
target:
|
||||||
|
type: Utilization
|
||||||
|
averageUtilization: {{ .Values.replica.autoscaling.targetCPU }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
67
helm/redis/templates/sentinel/node-services.yaml
Normal file
67
helm/redis/templates/sentinel/node-services.yaml
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled (eq .Values.sentinel.service.type "NodePort") (or .Release.IsUpgrade .Values.sentinel.service.nodePorts.redis ) }}
|
||||||
|
|
||||||
|
{{- range $i := until (int .Values.replica.replicaCount) }}
|
||||||
|
|
||||||
|
{{ $portsmap := (lookup "v1" "ConfigMap" (include "common.names.namespace" $) (printf "%s-%s" ( include "common.names.fullname" $ ) "ports-configmap")).data }}
|
||||||
|
|
||||||
|
{{ $sentinelport := 0}}
|
||||||
|
{{ $redisport := 0}}
|
||||||
|
{{- if $portsmap }}
|
||||||
|
{{ $sentinelport = index $portsmap (printf "%s-node-%s-%s" (include "common.names.fullname" $) (toString $i) "sentinel") }}
|
||||||
|
{{ $redisport = index $portsmap (printf "%s-node-%s-%s" (include "common.names.fullname" $) (toString $i) "redis") }}
|
||||||
|
{{- else }}
|
||||||
|
{{- end }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" $ }}-node-{{ $i }}
|
||||||
|
namespace: {{ include "common.names.namespace" $ | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" $.Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: node
|
||||||
|
{{- if or $.Values.commonAnnotations $.Values.sentinel.service.annotations }}
|
||||||
|
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list $.Values.sentinel.service.annotations $.Values.commonAnnotations ) "context" $ ) }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
type: NodePort
|
||||||
|
ports:
|
||||||
|
- name: sentinel
|
||||||
|
{{- if $.Values.sentinel.service.nodePorts.sentinel }}
|
||||||
|
nodePort: {{ (add $.Values.sentinel.service.nodePorts.sentinel $i 1) }}
|
||||||
|
port: {{ (add $.Values.sentinel.service.nodePorts.sentinel $i 1) }}
|
||||||
|
{{- else }}
|
||||||
|
nodePort: {{ $sentinelport }}
|
||||||
|
port: {{ $sentinelport }}
|
||||||
|
{{- end }}
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: {{ $.Values.sentinel.containerPorts.sentinel }}
|
||||||
|
- name: redis
|
||||||
|
{{- if $.Values.sentinel.service.nodePorts.redis }}
|
||||||
|
nodePort: {{ (add $.Values.sentinel.service.nodePorts.redis $i 1) }}
|
||||||
|
port: {{ (add $.Values.sentinel.service.nodePorts.redis $i 1) }}
|
||||||
|
{{- else }}
|
||||||
|
nodePort: {{ $redisport }}
|
||||||
|
port: {{ $redisport }}
|
||||||
|
{{- end }}
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: {{ $.Values.replica.containerPorts.redis }}
|
||||||
|
- name: sentinel-internal
|
||||||
|
nodePort: null
|
||||||
|
port: {{ $.Values.sentinel.containerPorts.sentinel }}
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: {{ $.Values.sentinel.containerPorts.sentinel }}
|
||||||
|
- name: redis-internal
|
||||||
|
nodePort: null
|
||||||
|
port: {{ $.Values.replica.containerPorts.redis }}
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: {{ $.Values.replica.containerPorts.redis }}
|
||||||
|
selector:
|
||||||
|
statefulset.kubernetes.io/pod-name: {{ template "common.names.fullname" $ }}-node-{{ $i }}
|
||||||
|
---
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
102
helm/redis/templates/sentinel/ports-configmap.yaml
Normal file
102
helm/redis/templates/sentinel/ports-configmap.yaml
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled (eq .Values.sentinel.service.type "NodePort") (not .Values.sentinel.service.nodePorts.redis ) }}
|
||||||
|
{{- /* create a list to keep track of ports we choose to use */}}
|
||||||
|
{{ $chosenports := (list ) }}
|
||||||
|
|
||||||
|
{{- /* Get list of all used nodeports */}}
|
||||||
|
{{ $usedports := (list ) }}
|
||||||
|
{{- range $index, $service := (lookup "v1" "Service" "" "").items }}
|
||||||
|
{{- range.spec.ports }}
|
||||||
|
{{- if .nodePort }}
|
||||||
|
{{- $usedports = (append $usedports .nodePort) }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- /*
|
||||||
|
comments that start with # are rendered in the output when you debug, so you can less and search for them
|
||||||
|
Vars in the comment will be rendered out, so you can check their value this way.
|
||||||
|
https://helm.sh/docs/chart_best_practices/templates/#comments-yaml-comments-vs-template-comments
|
||||||
|
|
||||||
|
remove the template comments and leave the yaml comments to help debug
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- /* Sort the list */}}
|
||||||
|
{{ $usedports = $usedports | sortAlpha }}
|
||||||
|
#usedports {{ $usedports }}
|
||||||
|
|
||||||
|
{{- /* How many nodeports per service do we want to create, except for the main service which is always two */}}
|
||||||
|
{{ $numberofPortsPerNodeService := 2 }}
|
||||||
|
|
||||||
|
{{- /* for every nodeport we want, loop though the used ports to get an unused port */}}
|
||||||
|
{{- range $j := until (int (add (mul (int .Values.replica.replicaCount) $numberofPortsPerNodeService) 2)) }}
|
||||||
|
{{- /* #j={{ $j }} */}}
|
||||||
|
{{- $nodeport := (add $j 30000) }}
|
||||||
|
{{- $nodeportfound := false }}
|
||||||
|
{{- range $i := $usedports }}
|
||||||
|
{{- /* #i={{ $i }}
|
||||||
|
#nodeport={{ $nodeport }}
|
||||||
|
#usedports={{ $usedports }} */}}
|
||||||
|
{{- if and (has (toString $nodeport) $usedports) (eq $nodeportfound false) }}
|
||||||
|
{{- /* nodeport conflicts with in use */}}
|
||||||
|
{{- $nodeport = (add $nodeport 1) }}
|
||||||
|
{{- else if and ( has $nodeport $chosenports) (eq $nodeportfound false) }}
|
||||||
|
{{- /* nodeport already chosen, try another */}}
|
||||||
|
{{- $nodeport = (add $nodeport 1) }}
|
||||||
|
{{- else if (eq $nodeportfound false) }}
|
||||||
|
{{- /* nodeport free to use: not already claimed and not in use */}}
|
||||||
|
{{- /* select nodeport, and place into usedports */}}
|
||||||
|
{{- $chosenports = (append $chosenports $nodeport) }}
|
||||||
|
{{- $nodeportfound = true }}
|
||||||
|
{{- else }}
|
||||||
|
{{- /* nodeport has already been chosen and locked in, just work through the rest of the list to get to the next nodeport selection */}}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if (eq $nodeportfound false) }}
|
||||||
|
{{- $chosenports = (append $chosenports $nodeport) }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- /* print the usedports and chosenports for debugging */}}
|
||||||
|
#usedports {{ $usedports }}
|
||||||
|
#chosenports {{ $chosenports }}}}
|
||||||
|
|
||||||
|
---
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ConfigMap
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" . }}-ports-configmap
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations:
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
data:
|
||||||
|
{{ $portsmap := (lookup "v1" "ConfigMap" (include "common.names.namespace" .) (printf "%s-%s" ( include "common.names.fullname" . ) "ports-configmap")).data }}
|
||||||
|
{{- if $portsmap }}
|
||||||
|
{{- /* configmap already exists, do not install again */ -}}
|
||||||
|
{{- range $name, $value := $portsmap }}
|
||||||
|
"{{ $name }}": "{{ $value }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
{{- /* configmap being set for first time */ -}}
|
||||||
|
{{- range $index, $port := $chosenports }}
|
||||||
|
{{- $nodenumber := (floor (div $index 2)) }}
|
||||||
|
{{- if (eq $index 0) }}
|
||||||
|
"{{ template "common.names.fullname" $ }}-sentinel": "{{ $port }}"
|
||||||
|
{{- else if (eq $index 1) }}
|
||||||
|
"{{ template "common.names.fullname" $ }}-redis": "{{ $port }}"
|
||||||
|
{{- else if (eq (mod $index 2) 0) }}
|
||||||
|
"{{ template "common.names.fullname" $ }}-node-{{ (sub $nodenumber 1) }}-sentinel": "{{ $port }}"
|
||||||
|
{{- else if (eq (mod $index 2) 1) }}
|
||||||
|
"{{ template "common.names.fullname" $ }}-node-{{ (sub $nodenumber 1) }}-redis": "{{ $port }}"
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
104
helm/redis/templates/sentinel/service.yaml
Normal file
104
helm/redis/templates/sentinel/service.yaml
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if or .Release.IsUpgrade (ne .Values.sentinel.service.type "NodePort") .Values.sentinel.service.nodePorts.redis -}}
|
||||||
|
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled }}
|
||||||
|
{{ $portsmap := (lookup "v1" "ConfigMap" (include "common.names.namespace" .) (printf "%s-%s" ( include "common.names.fullname" . ) "ports-configmap")).data }}
|
||||||
|
|
||||||
|
{{ $sentinelport := 0}}
|
||||||
|
{{ $redisport := 0}}
|
||||||
|
{{- if $portsmap }}
|
||||||
|
{{ $sentinelport = index $portsmap (printf "%s-%s" (include "common.names.fullname" $) "sentinel") }}
|
||||||
|
{{ $redisport = index $portsmap (printf "%s-%s" (include "common.names.fullname" $) "redis") }}
|
||||||
|
{{- else }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Service
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: node
|
||||||
|
{{- if or .Values.sentinel.service.annotations .Values.commonAnnotations }}
|
||||||
|
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.sentinel.service.annotations .Values.commonAnnotations ) "context" . ) }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
type: {{ .Values.sentinel.service.type }}
|
||||||
|
{{- if or (eq .Values.sentinel.service.type "LoadBalancer") (eq .Values.sentinel.service.type "NodePort") }}
|
||||||
|
externalTrafficPolicy: {{ .Values.sentinel.service.externalTrafficPolicy | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.sentinel.service.type "LoadBalancer") (not (empty .Values.sentinel.service.loadBalancerIP)) }}
|
||||||
|
loadBalancerIP: {{ .Values.sentinel.service.loadBalancerIP }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.sentinel.service.type "LoadBalancer") .Values.sentinel.service.loadBalancerClass }}
|
||||||
|
loadBalancerClass: {{ .Values.sentinel.service.loadBalancerClass }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and (eq .Values.sentinel.service.type "LoadBalancer") (not (empty .Values.sentinel.service.loadBalancerSourceRanges)) }}
|
||||||
|
loadBalancerSourceRanges: {{ toYaml .Values.sentinel.service.loadBalancerSourceRanges | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and .Values.sentinel.service.clusterIP (eq .Values.sentinel.service.type "ClusterIP") }}
|
||||||
|
clusterIP: {{ .Values.sentinel.service.clusterIP }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.service.sessionAffinity }}
|
||||||
|
sessionAffinity: {{ .Values.sentinel.service.sessionAffinity }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.service.sessionAffinityConfig }}
|
||||||
|
sessionAffinityConfig: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.service.sessionAffinityConfig "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: tcp-redis
|
||||||
|
{{- if and (or (eq .Values.sentinel.service.type "NodePort") (eq .Values.sentinel.service.type "LoadBalancer")) .Values.sentinel.service.nodePorts.redis }}
|
||||||
|
port: {{ .Values.sentinel.service.nodePorts.redis }}
|
||||||
|
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||||
|
port: {{ $redisport }}
|
||||||
|
{{- else}}
|
||||||
|
port: {{ .Values.sentinel.service.ports.redis }}
|
||||||
|
{{- end }}
|
||||||
|
targetPort: {{ .Values.replica.containerPorts.redis }}
|
||||||
|
{{- if and (or (eq .Values.sentinel.service.type "NodePort") (eq .Values.sentinel.service.type "LoadBalancer")) .Values.sentinel.service.nodePorts.redis }}
|
||||||
|
nodePort: {{ .Values.sentinel.service.nodePorts.redis }}
|
||||||
|
{{- else if eq .Values.sentinel.service.type "ClusterIP" }}
|
||||||
|
nodePort: null
|
||||||
|
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||||
|
nodePort: {{ $redisport }}
|
||||||
|
{{- end }}
|
||||||
|
- name: tcp-sentinel
|
||||||
|
{{- if and (or (eq .Values.sentinel.service.type "NodePort") (eq .Values.sentinel.service.type "LoadBalancer")) .Values.sentinel.service.nodePorts.sentinel }}
|
||||||
|
port: {{ .Values.sentinel.service.nodePorts.sentinel }}
|
||||||
|
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||||
|
port: {{ $sentinelport }}
|
||||||
|
{{- else }}
|
||||||
|
port: {{ .Values.sentinel.service.ports.sentinel }}
|
||||||
|
{{- end }}
|
||||||
|
targetPort: {{ .Values.sentinel.containerPorts.sentinel }}
|
||||||
|
{{- if and (or (eq .Values.sentinel.service.type "NodePort") (eq .Values.sentinel.service.type "LoadBalancer")) .Values.sentinel.service.nodePorts.sentinel }}
|
||||||
|
nodePort: {{ .Values.sentinel.service.nodePorts.sentinel }}
|
||||||
|
{{- else if eq .Values.sentinel.service.type "ClusterIP" }}
|
||||||
|
nodePort: null
|
||||||
|
{{- else if eq .Values.sentinel.service.type "NodePort" }}
|
||||||
|
nodePort: {{ $sentinelport }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq .Values.sentinel.service.type "NodePort" }}
|
||||||
|
- name: sentinel-internal
|
||||||
|
nodePort: null
|
||||||
|
port: {{ .Values.sentinel.containerPorts.sentinel }}
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: {{ .Values.sentinel.containerPorts.sentinel }}
|
||||||
|
- name: redis-internal
|
||||||
|
nodePort: null
|
||||||
|
port: {{ .Values.replica.containerPorts.redis }}
|
||||||
|
protocol: TCP
|
||||||
|
targetPort: {{ .Values.replica.containerPorts.redis }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.service.extraPorts }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.sentinel.service.extraPorts "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.replica.podLabels .Values.commonLabels ) "context" . ) }}
|
||||||
|
selector: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: node
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
787
helm/redis/templates/sentinel/statefulset.yaml
Normal file
787
helm/redis/templates/sentinel/statefulset.yaml
Normal file
@ -0,0 +1,787 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if or .Release.IsUpgrade (ne .Values.sentinel.service.type "NodePort") .Values.sentinel.service.nodePorts.redis -}}
|
||||||
|
{{- if and (eq .Values.architecture "replication") .Values.sentinel.enabled }}
|
||||||
|
apiVersion: {{ include "common.capabilities.statefulset.apiVersion" . }}
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: {{ printf "%s-node" (include "common.names.fullname" .) }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: node
|
||||||
|
{{- if or .Values.commonAnnotations .Values.sentinel.annotations }}
|
||||||
|
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.sentinel.annotations .Values.commonAnnotations ) "context" . ) }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
replicas: {{ .Values.replica.replicaCount }}
|
||||||
|
{{- $podLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.replica.podLabels .Values.commonLabels ) "context" . ) }}
|
||||||
|
selector:
|
||||||
|
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
|
||||||
|
app.kubernetes.io/component: node
|
||||||
|
serviceName: {{ printf "%s-headless" (include "common.names.fullname" .) }}
|
||||||
|
{{- if .Values.replica.updateStrategy }}
|
||||||
|
updateStrategy: {{- toYaml .Values.replica.updateStrategy | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and .Values.replica.minReadySeconds (semverCompare ">= 1.23-0" (include "common.capabilities.kubeVersion" .)) }}
|
||||||
|
minReadySeconds: {{ .Values.replica.minReadySeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.podManagementPolicy }}
|
||||||
|
podManagementPolicy: {{ .Values.replica.podManagementPolicy | quote }}
|
||||||
|
{{- end }}
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" $podLabels "context" $ ) | nindent 8 }}
|
||||||
|
app.kubernetes.io/component: node
|
||||||
|
{{- if and .Values.metrics.enabled .Values.metrics.podLabels }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podLabels "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
annotations:
|
||||||
|
{{- if (include "redis.createConfigmap" .) }}
|
||||||
|
checksum/configmap: {{ pick ( include (print $.Template.BasePath "/configmap.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
{{- end }}
|
||||||
|
checksum/health: {{ pick ( include (print $.Template.BasePath "/health-configmap.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
checksum/scripts: {{ pick ( include (print $.Template.BasePath "/scripts-configmap.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
checksum/secret: {{ pick ( include (print $.Template.BasePath "/secret.yaml") . | fromYaml ) "data" | toYaml | sha256sum }}
|
||||||
|
{{- if .Values.replica.podAnnotations }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.podAnnotations "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.podAnnotations "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
{{- include "redis.imagePullSecrets" . | nindent 6 }}
|
||||||
|
automountServiceAccountToken: {{ .Values.replica.automountServiceAccountToken }}
|
||||||
|
{{- if .Values.replica.hostAliases }}
|
||||||
|
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.replica.hostAliases "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.podSecurityContext.enabled }}
|
||||||
|
securityContext: {{- omit .Values.replica.podSecurityContext "enabled" | toYaml | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
serviceAccountName: {{ template "redis.serviceAccountName" . }}
|
||||||
|
{{- if .Values.replica.priorityClassName }}
|
||||||
|
priorityClassName: {{ .Values.replica.priorityClassName | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.affinity }}
|
||||||
|
affinity: {{- include "common.tplvalues.render" (dict "value" .Values.replica.affinity "context" $) | nindent 8 }}
|
||||||
|
{{- else }}
|
||||||
|
affinity:
|
||||||
|
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAffinityPreset "component" "node" "customLabels" $podLabels "context" $) | nindent 10 }}
|
||||||
|
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.replica.podAntiAffinityPreset "component" "node" "customLabels" $podLabels "context" $) | nindent 10 }}
|
||||||
|
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.replica.nodeAffinityPreset.type "key" .Values.replica.nodeAffinityPreset.key "values" .Values.replica.nodeAffinityPreset.values) | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.nodeSelector }}
|
||||||
|
nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.replica.nodeSelector "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.tolerations }}
|
||||||
|
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.replica.tolerations "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.topologySpreadConstraints }}
|
||||||
|
topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.replica.topologySpreadConstraints "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.shareProcessNamespace }}
|
||||||
|
shareProcessNamespace: {{ .Values.replica.shareProcessNamespace }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.schedulerName }}
|
||||||
|
schedulerName: {{ .Values.replica.schedulerName | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.dnsPolicy }}
|
||||||
|
dnsPolicy: {{ .Values.replica.dnsPolicy }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.dnsConfig }}
|
||||||
|
dnsConfig: {{- include "common.tplvalues.render" (dict "value" .Values.replica.dnsConfig "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
enableServiceLinks: {{ .Values.sentinel.enableServiceLinks }}
|
||||||
|
terminationGracePeriodSeconds: {{ .Values.sentinel.terminationGracePeriodSeconds }}
|
||||||
|
containers:
|
||||||
|
- name: redis
|
||||||
|
image: {{ template "redis.image" . }}
|
||||||
|
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
||||||
|
{{- if not .Values.diagnosticMode.enabled }}
|
||||||
|
{{- if .Values.replica.lifecycleHooks }}
|
||||||
|
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.replica.lifecycleHooks "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
lifecycle:
|
||||||
|
preStop:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- /opt/bitnami/scripts/start-scripts/prestop-redis.sh
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.containerSecurityContext.enabled }}
|
||||||
|
securityContext: {{- omit .Values.replica.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.replica.command }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.replica.command "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.replica.args }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.replica.args "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
args:
|
||||||
|
- -c
|
||||||
|
- /opt/bitnami/scripts/start-scripts/start-node.sh
|
||||||
|
{{- end }}
|
||||||
|
env:
|
||||||
|
- name: BITNAMI_DEBUG
|
||||||
|
value: {{ ternary "true" "false" (or .Values.image.debug .Values.diagnosticMode.enabled) | quote }}
|
||||||
|
- name: REDIS_MASTER_PORT_NUMBER
|
||||||
|
value: {{ .Values.replica.containerPorts.redis | quote }}
|
||||||
|
- name: ALLOW_EMPTY_PASSWORD
|
||||||
|
value: {{ ternary "no" "yes" .Values.auth.enabled | quote }}
|
||||||
|
{{- if .Values.auth.enabled }}
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: REDIS_PASSWORD_FILE
|
||||||
|
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||||
|
- name: REDIS_MASTER_PASSWORD_FILE
|
||||||
|
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||||
|
{{- else }}
|
||||||
|
- name: REDIS_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ template "redis.secretName" . }}
|
||||||
|
key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
- name: REDIS_MASTER_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ template "redis.secretName" . }}
|
||||||
|
key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
- name: REDIS_TLS_ENABLED
|
||||||
|
value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: REDIS_TLS_PORT
|
||||||
|
value: {{ .Values.replica.containerPorts.redis | quote }}
|
||||||
|
- name: REDIS_TLS_AUTH_CLIENTS
|
||||||
|
value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
|
||||||
|
- name: REDIS_TLS_CERT_FILE
|
||||||
|
value: {{ template "redis.tlsCert" . }}
|
||||||
|
- name: REDIS_TLS_KEY_FILE
|
||||||
|
value: {{ template "redis.tlsCertKey" . }}
|
||||||
|
- name: REDIS_TLS_CA_FILE
|
||||||
|
value: {{ template "redis.tlsCACert" . }}
|
||||||
|
{{- if .Values.tls.dhParamsFilename }}
|
||||||
|
- name: REDIS_TLS_DH_PARAMS_FILE
|
||||||
|
value: {{ template "redis.tlsDHParams" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
- name: REDIS_PORT
|
||||||
|
value: {{ .Values.replica.containerPorts.redis | quote }}
|
||||||
|
{{- end }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_ENABLED
|
||||||
|
value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_PORT_NUMBER
|
||||||
|
value: {{ .Values.sentinel.containerPorts.sentinel | quote }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_AUTH_CLIENTS
|
||||||
|
value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_CERT_FILE
|
||||||
|
value: {{ template "redis.tlsCert" . }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_KEY_FILE
|
||||||
|
value: {{ template "redis.tlsCertKey" . }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_CA_FILE
|
||||||
|
value: {{ template "redis.tlsCACert" . }}
|
||||||
|
{{- if .Values.tls.dhParamsFilename }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_DH_PARAMS_FILE
|
||||||
|
value: {{ template "redis.tlsDHParams" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
- name: REDIS_SENTINEL_PORT
|
||||||
|
value: {{ .Values.sentinel.containerPorts.sentinel | quote }}
|
||||||
|
{{- end }}
|
||||||
|
- name: REDIS_DATA_DIR
|
||||||
|
value: {{ .Values.replica.persistence.path }}
|
||||||
|
{{- if .Values.replica.externalMaster.enabled }}
|
||||||
|
- name: REDIS_EXTERNAL_MASTER_HOST
|
||||||
|
value: {{ .Values.replica.externalMaster.host | quote }}
|
||||||
|
- name: REDIS_EXTERNAL_MASTER_PORT
|
||||||
|
value: {{ .Values.replica.externalMaster.port | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.extraEnvVars }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraEnvVars "context" $ ) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if or .Values.replica.extraEnvVarsCM .Values.replica.extraEnvVarsSecret }}
|
||||||
|
envFrom:
|
||||||
|
{{- if .Values.replica.extraEnvVarsCM }}
|
||||||
|
- configMapRef:
|
||||||
|
name: {{ .Values.replica.extraEnvVarsCM }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.extraEnvVarsSecret }}
|
||||||
|
- secretRef:
|
||||||
|
name: {{ .Values.replica.extraEnvVarsSecret }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: redis
|
||||||
|
containerPort: {{ .Values.replica.containerPorts.redis }}
|
||||||
|
{{- if not .Values.diagnosticMode.enabled }}
|
||||||
|
{{- if .Values.replica.customStartupProbe }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customStartupProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.replica.startupProbe.enabled }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.replica.startupProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- /health/ping_liveness_local.sh {{ .Values.replica.livenessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.customLivenessProbe }}
|
||||||
|
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customLivenessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.replica.livenessProbe.enabled }}
|
||||||
|
livenessProbe:
|
||||||
|
initialDelaySeconds: {{ .Values.replica.livenessProbe.initialDelaySeconds }}
|
||||||
|
periodSeconds: {{ .Values.replica.livenessProbe.periodSeconds }}
|
||||||
|
timeoutSeconds: {{ .Values.replica.livenessProbe.timeoutSeconds }}
|
||||||
|
successThreshold: {{ .Values.replica.livenessProbe.successThreshold }}
|
||||||
|
failureThreshold: {{ .Values.replica.livenessProbe.failureThreshold }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- /health/ping_liveness_local.sh {{ .Values.replica.livenessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.customReadinessProbe }}
|
||||||
|
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.replica.customReadinessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.replica.readinessProbe.enabled }}
|
||||||
|
readinessProbe:
|
||||||
|
initialDelaySeconds: {{ .Values.replica.readinessProbe.initialDelaySeconds }}
|
||||||
|
periodSeconds: {{ .Values.replica.readinessProbe.periodSeconds }}
|
||||||
|
timeoutSeconds: {{ .Values.replica.readinessProbe.timeoutSeconds }}
|
||||||
|
successThreshold: {{ .Values.replica.readinessProbe.successThreshold }}
|
||||||
|
failureThreshold: {{ .Values.replica.readinessProbe.failureThreshold }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- /health/ping_readiness_local.sh {{ .Values.replica.readinessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.resources }}
|
||||||
|
resources: {{- toYaml .Values.replica.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: start-scripts
|
||||||
|
mountPath: /opt/bitnami/scripts/start-scripts
|
||||||
|
- name: health
|
||||||
|
mountPath: /health
|
||||||
|
{{- if .Values.sentinel.persistence.enabled }}
|
||||||
|
- name: sentinel-data
|
||||||
|
mountPath: /opt/bitnami/redis-sentinel/etc
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: redis-password
|
||||||
|
mountPath: /opt/bitnami/redis/secrets/
|
||||||
|
{{- end }}
|
||||||
|
- name: redis-data
|
||||||
|
mountPath: {{ .Values.replica.persistence.path }}
|
||||||
|
{{- if .Values.replica.persistence.subPath }}
|
||||||
|
subPath: {{ .Values.replica.persistence.subPath }}
|
||||||
|
{{- else if .Values.replica.persistence.subPathExpr }}
|
||||||
|
subPathExpr: {{ .Values.replica.persistence.subPathExpr }}
|
||||||
|
{{- end }}
|
||||||
|
- name: config
|
||||||
|
mountPath: /opt/bitnami/redis/mounted-etc
|
||||||
|
- name: redis-tmp-conf
|
||||||
|
mountPath: /opt/bitnami/redis/etc
|
||||||
|
- name: tmp
|
||||||
|
mountPath: /tmp
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: redis-certificates
|
||||||
|
mountPath: /opt/bitnami/redis/certs
|
||||||
|
readOnly: true
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.extraVolumeMounts }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
- name: sentinel
|
||||||
|
image: {{ template "redis.sentinel.image" . }}
|
||||||
|
imagePullPolicy: {{ .Values.sentinel.image.pullPolicy | quote }}
|
||||||
|
{{- if not .Values.diagnosticMode.enabled }}
|
||||||
|
{{- if .Values.sentinel.lifecycleHooks }}
|
||||||
|
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.lifecycleHooks "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
lifecycle:
|
||||||
|
preStop:
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- /opt/bitnami/scripts/start-scripts/prestop-sentinel.sh
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.containerSecurityContext.enabled }}
|
||||||
|
securityContext: {{- omit .Values.sentinel.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.sentinel.command }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.command "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.sentinel.args }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.args "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
args:
|
||||||
|
- -c
|
||||||
|
- /opt/bitnami/scripts/start-scripts/start-sentinel.sh
|
||||||
|
{{- end }}
|
||||||
|
env:
|
||||||
|
- name: BITNAMI_DEBUG
|
||||||
|
value: {{ ternary "true" "false" (or .Values.sentinel.image.debug .Values.diagnosticMode.enabled) | quote }}
|
||||||
|
{{- if .Values.auth.enabled }}
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: REDIS_PASSWORD_FILE
|
||||||
|
value: "/opt/bitnami/redis/secrets/redis-password"
|
||||||
|
{{- else }}
|
||||||
|
- name: REDIS_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ template "redis.secretName" . }}
|
||||||
|
key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
- name: ALLOW_EMPTY_PASSWORD
|
||||||
|
value: "yes"
|
||||||
|
{{- end }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_ENABLED
|
||||||
|
value: {{ ternary "yes" "no" .Values.tls.enabled | quote }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_PORT_NUMBER
|
||||||
|
value: {{ .Values.sentinel.containerPorts.sentinel | quote }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_AUTH_CLIENTS
|
||||||
|
value: {{ ternary "yes" "no" .Values.tls.authClients | quote }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_CERT_FILE
|
||||||
|
value: {{ template "redis.tlsCert" . }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_KEY_FILE
|
||||||
|
value: {{ template "redis.tlsCertKey" . }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_CA_FILE
|
||||||
|
value: {{ template "redis.tlsCACert" . }}
|
||||||
|
{{- if .Values.tls.dhParamsFilename }}
|
||||||
|
- name: REDIS_SENTINEL_TLS_DH_PARAMS_FILE
|
||||||
|
value: {{ template "redis.tlsDHParams" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
- name: REDIS_SENTINEL_PORT
|
||||||
|
value: {{ .Values.sentinel.containerPorts.sentinel | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.externalMaster.enabled }}
|
||||||
|
- name: REDIS_EXTERNAL_MASTER_HOST
|
||||||
|
value: {{ .Values.sentinel.externalMaster.host | quote }}
|
||||||
|
- name: REDIS_EXTERNAL_MASTER_PORT
|
||||||
|
value: {{ .Values.sentinel.externalMaster.port | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.extraEnvVars }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.extraEnvVars "context" $ ) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if or .Values.sentinel.extraEnvVarsCM .Values.sentinel.extraEnvVarsSecret }}
|
||||||
|
envFrom:
|
||||||
|
{{- if .Values.sentinel.extraEnvVarsCM }}
|
||||||
|
- configMapRef:
|
||||||
|
name: {{ .Values.sentinel.extraEnvVarsCM }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.extraEnvVarsSecret }}
|
||||||
|
- secretRef:
|
||||||
|
name: {{ .Values.sentinel.extraEnvVarsSecret }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: redis-sentinel
|
||||||
|
containerPort: {{ .Values.sentinel.containerPorts.sentinel }}
|
||||||
|
{{- if not .Values.diagnosticMode.enabled }}
|
||||||
|
{{- if .Values.sentinel.customStartupProbe }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.customStartupProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.sentinel.startupProbe.enabled }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.sentinel.startupProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- /health/ping_sentinel.sh {{ .Values.sentinel.livenessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.customLivenessProbe }}
|
||||||
|
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.customLivenessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.sentinel.livenessProbe.enabled }}
|
||||||
|
livenessProbe:
|
||||||
|
initialDelaySeconds: {{ .Values.sentinel.livenessProbe.initialDelaySeconds }}
|
||||||
|
periodSeconds: {{ .Values.sentinel.livenessProbe.periodSeconds }}
|
||||||
|
timeoutSeconds: {{ .Values.sentinel.livenessProbe.timeoutSeconds }}
|
||||||
|
successThreshold: {{ .Values.sentinel.livenessProbe.successThreshold }}
|
||||||
|
failureThreshold: {{ .Values.sentinel.livenessProbe.failureThreshold }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- /health/ping_sentinel.sh {{ .Values.sentinel.livenessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if not .Values.diagnosticMode.enabled }}
|
||||||
|
{{- if .Values.sentinel.customReadinessProbe }}
|
||||||
|
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.customReadinessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.sentinel.readinessProbe.enabled }}
|
||||||
|
readinessProbe:
|
||||||
|
initialDelaySeconds: {{ .Values.sentinel.readinessProbe.initialDelaySeconds }}
|
||||||
|
periodSeconds: {{ .Values.sentinel.readinessProbe.periodSeconds }}
|
||||||
|
timeoutSeconds: {{ .Values.sentinel.readinessProbe.timeoutSeconds }}
|
||||||
|
successThreshold: {{ .Values.sentinel.readinessProbe.successThreshold }}
|
||||||
|
failureThreshold: {{ .Values.sentinel.readinessProbe.failureThreshold }}
|
||||||
|
exec:
|
||||||
|
command:
|
||||||
|
- sh
|
||||||
|
- -c
|
||||||
|
- /health/ping_sentinel.sh {{ .Values.sentinel.readinessProbe.timeoutSeconds }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.resources }}
|
||||||
|
resources: {{- toYaml .Values.sentinel.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: start-scripts
|
||||||
|
mountPath: /opt/bitnami/scripts/start-scripts
|
||||||
|
- name: health
|
||||||
|
mountPath: /health
|
||||||
|
- name: sentinel-data
|
||||||
|
mountPath: /opt/bitnami/redis-sentinel/etc
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: redis-password
|
||||||
|
mountPath: /opt/bitnami/redis/secrets/
|
||||||
|
{{- end }}
|
||||||
|
- name: redis-data
|
||||||
|
mountPath: {{ .Values.replica.persistence.path }}
|
||||||
|
{{- if .Values.replica.persistence.subPath }}
|
||||||
|
subPath: {{ .Values.replica.persistence.subPath }}
|
||||||
|
{{- else if .Values.replica.persistence.subPathExpr }}
|
||||||
|
subPathExpr: {{ .Values.replica.persistence.subPathExpr }}
|
||||||
|
{{- end }}
|
||||||
|
- name: config
|
||||||
|
mountPath: /opt/bitnami/redis-sentinel/mounted-etc
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: redis-certificates
|
||||||
|
mountPath: /opt/bitnami/redis/certs
|
||||||
|
readOnly: true
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.extraVolumeMounts }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.enabled }}
|
||||||
|
- name: metrics
|
||||||
|
image: {{ template "redis.metrics.image" . }}
|
||||||
|
imagePullPolicy: {{ .Values.metrics.image.pullPolicy | quote }}
|
||||||
|
{{- if .Values.metrics.containerSecurityContext.enabled }}
|
||||||
|
securityContext: {{- omit .Values.metrics.containerSecurityContext "enabled" | toYaml | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.command "context" $) | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -c
|
||||||
|
- |
|
||||||
|
if [[ -f '/secrets/redis-password' ]]; then
|
||||||
|
export REDIS_PASSWORD=$(cat /secrets/redis-password)
|
||||||
|
fi
|
||||||
|
redis_exporter{{- range $key, $value := .Values.metrics.extraArgs }} --{{ $key }}={{ $value }}{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.diagnosticMode.enabled }}
|
||||||
|
args: {{- include "common.tplvalues.render" (dict "value" .Values.diagnosticMode.args "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
env:
|
||||||
|
- name: REDIS_ALIAS
|
||||||
|
value: {{ template "common.names.fullname" . }}
|
||||||
|
- name: REDIS_EXPORTER_WEB_LISTEN_ADDRESS
|
||||||
|
value: {{ printf ":%v" .Values.metrics.containerPorts.http }}
|
||||||
|
{{- if .Values.auth.enabled }}
|
||||||
|
- name: REDIS_USER
|
||||||
|
value: default
|
||||||
|
{{- if (not .Values.auth.usePasswordFiles) }}
|
||||||
|
- name: REDIS_PASSWORD
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ template "redis.secretName" . }}
|
||||||
|
key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: REDIS_ADDR
|
||||||
|
value: rediss://{{ .Values.metrics.redisTargetHost }}:{{ .Values.replica.containerPorts.redis }}
|
||||||
|
{{- if .Values.tls.authClients }}
|
||||||
|
- name: REDIS_EXPORTER_TLS_CLIENT_KEY_FILE
|
||||||
|
value: {{ template "redis.tlsCertKey" . }}
|
||||||
|
- name: REDIS_EXPORTER_TLS_CLIENT_CERT_FILE
|
||||||
|
value: {{ template "redis.tlsCert" . }}
|
||||||
|
{{- end }}
|
||||||
|
- name: REDIS_EXPORTER_TLS_CA_CERT_FILE
|
||||||
|
value: {{ template "redis.tlsCACert" . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.extraEnvVars }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.extraEnvVars "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
ports:
|
||||||
|
- name: metrics
|
||||||
|
containerPort: {{ .Values.metrics.containerPorts.http }}
|
||||||
|
{{- if not .Values.diagnosticMode.enabled }}
|
||||||
|
{{- if .Values.metrics.customStartupProbe }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customStartupProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.metrics.startupProbe.enabled }}
|
||||||
|
startupProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.startupProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
tcpSocket:
|
||||||
|
port: metrics
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.customLivenessProbe }}
|
||||||
|
livenessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customLivenessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.metrics.livenessProbe.enabled }}
|
||||||
|
livenessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.livenessProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
tcpSocket:
|
||||||
|
port: metrics
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.customReadinessProbe }}
|
||||||
|
readinessProbe: {{- include "common.tplvalues.render" (dict "value" .Values.metrics.customReadinessProbe "context" $) | nindent 12 }}
|
||||||
|
{{- else if .Values.metrics.readinessProbe.enabled }}
|
||||||
|
readinessProbe: {{- include "common.tplvalues.render" (dict "value" (omit .Values.metrics.readinessProbe "enabled") "context" $) | nindent 12 }}
|
||||||
|
httpGet:
|
||||||
|
path: /
|
||||||
|
port: metrics
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.resources }}
|
||||||
|
resources: {{- toYaml .Values.metrics.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: redis-password
|
||||||
|
mountPath: /secrets/
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: redis-certificates
|
||||||
|
mountPath: /opt/bitnami/redis/certs
|
||||||
|
readOnly: true
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.extraVolumeMounts }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumeMounts "context" $ ) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.sidecars }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.replica.sidecars "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- $needsVolumePermissions := and .Values.volumePermissions.enabled .Values.replica.persistence.enabled .Values.replica.podSecurityContext.enabled .Values.replica.containerSecurityContext.enabled }}
|
||||||
|
{{- if or .Values.replica.initContainers $needsVolumePermissions .Values.sysctl.enabled }}
|
||||||
|
initContainers:
|
||||||
|
{{- if .Values.replica.initContainers }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.replica.initContainers "context" $) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if $needsVolumePermissions }}
|
||||||
|
- name: volume-permissions
|
||||||
|
image: {{ include "redis.volumePermissions.image" . }}
|
||||||
|
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
|
||||||
|
command:
|
||||||
|
- /bin/bash
|
||||||
|
- -ec
|
||||||
|
- |
|
||||||
|
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||||
|
chown -R `id -u`:`id -G | cut -d " " -f2` {{ .Values.replica.persistence.path }}
|
||||||
|
{{- else }}
|
||||||
|
chown -R {{ .Values.replica.containerSecurityContext.runAsUser }}:{{ .Values.replica.podSecurityContext.fsGroup }} {{ .Values.replica.persistence.path }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if eq ( toString ( .Values.volumePermissions.containerSecurityContext.runAsUser )) "auto" }}
|
||||||
|
securityContext: {{- omit .Values.volumePermissions.containerSecurityContext "runAsUser" | toYaml | nindent 12 }}
|
||||||
|
{{- else }}
|
||||||
|
securityContext: {{- .Values.volumePermissions.containerSecurityContext | toYaml | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.volumePermissions.resources }}
|
||||||
|
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: redis-data
|
||||||
|
mountPath: {{ .Values.replica.persistence.path }}
|
||||||
|
{{- if .Values.replica.persistence.subPath }}
|
||||||
|
subPath: {{ .Values.replica.persistence.subPath }}
|
||||||
|
{{- else if .Values.replica.persistence.subPathExpr }}
|
||||||
|
subPathExpr: {{ .Values.replica.persistence.subPathExpr }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sysctl.enabled }}
|
||||||
|
- name: init-sysctl
|
||||||
|
image: {{ include "redis.sysctl.image" . }}
|
||||||
|
imagePullPolicy: {{ default "" .Values.sysctl.image.pullPolicy | quote }}
|
||||||
|
securityContext:
|
||||||
|
privileged: true
|
||||||
|
runAsUser: 0
|
||||||
|
{{- if .Values.sysctl.command }}
|
||||||
|
command: {{- include "common.tplvalues.render" (dict "value" .Values.sysctl.command "context" $) | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sysctl.resources }}
|
||||||
|
resources: {{- toYaml .Values.sysctl.resources | nindent 12 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sysctl.mountHostSys }}
|
||||||
|
volumeMounts:
|
||||||
|
- name: host-sys
|
||||||
|
mountPath: /host-sys
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
volumes:
|
||||||
|
- name: start-scripts
|
||||||
|
configMap:
|
||||||
|
name: {{ printf "%s-scripts" (include "common.names.fullname" .) }}
|
||||||
|
defaultMode: 0755
|
||||||
|
- name: health
|
||||||
|
configMap:
|
||||||
|
name: {{ printf "%s-health" (include "common.names.fullname" .) }}
|
||||||
|
defaultMode: 0755
|
||||||
|
{{- if .Values.auth.usePasswordFiles }}
|
||||||
|
- name: redis-password
|
||||||
|
secret:
|
||||||
|
secretName: {{ template "redis.secretName" . }}
|
||||||
|
items:
|
||||||
|
- key: {{ template "redis.secretPasswordKey" . }}
|
||||||
|
path: redis-password
|
||||||
|
{{- end }}
|
||||||
|
- name: config
|
||||||
|
configMap:
|
||||||
|
name: {{ include "redis.configmapName" . }}
|
||||||
|
{{- if .Values.sysctl.mountHostSys }}
|
||||||
|
- name: host-sys
|
||||||
|
hostPath:
|
||||||
|
path: /sys
|
||||||
|
{{- end }}
|
||||||
|
{{- if not .Values.sentinel.persistence.enabled }}
|
||||||
|
- name: sentinel-data
|
||||||
|
{{- if or .Values.sentinel.persistence.medium .Values.sentinel.persistence.sizeLimit }}
|
||||||
|
emptyDir:
|
||||||
|
{{- if .Values.sentinel.persistence.medium }}
|
||||||
|
medium: {{ .Values.sentinel.persistence.medium | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.persistence.sizeLimit }}
|
||||||
|
sizeLimit: {{ .Values.sentinel.persistence.sizeLimit | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
emptyDir: {}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
- name: redis-tmp-conf
|
||||||
|
{{- if or .Values.sentinel.persistence.medium .Values.sentinel.persistence.sizeLimit }}
|
||||||
|
emptyDir:
|
||||||
|
{{- if .Values.sentinel.persistence.medium }}
|
||||||
|
medium: {{ .Values.sentinel.persistence.medium | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.persistence.sizeLimit }}
|
||||||
|
sizeLimit: {{ .Values.sentinel.persistence.sizeLimit | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
emptyDir: {}
|
||||||
|
{{- end }}
|
||||||
|
- name: tmp
|
||||||
|
{{- if or .Values.sentinel.persistence.medium .Values.sentinel.persistence.sizeLimit }}
|
||||||
|
emptyDir:
|
||||||
|
{{- if .Values.sentinel.persistence.medium }}
|
||||||
|
medium: {{ .Values.sentinel.persistence.medium | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.persistence.sizeLimit }}
|
||||||
|
sizeLimit: {{ .Values.sentinel.persistence.sizeLimit | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
emptyDir: {}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.extraVolumes }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.replica.extraVolumes "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.extraVolumes }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.metrics.extraVolumes "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.extraVolumes }}
|
||||||
|
{{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.extraVolumes "context" $ ) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.tls.enabled }}
|
||||||
|
- name: redis-certificates
|
||||||
|
secret:
|
||||||
|
secretName: {{ include "redis.tlsSecretName" . }}
|
||||||
|
defaultMode: 256
|
||||||
|
{{- end }}
|
||||||
|
{{- if not .Values.replica.persistence.enabled }}
|
||||||
|
- name: redis-data
|
||||||
|
{{- if or .Values.replica.persistence.medium .Values.replica.persistence.sizeLimit }}
|
||||||
|
emptyDir:
|
||||||
|
{{- if .Values.replica.persistence.medium }}
|
||||||
|
medium: {{ .Values.replica.persistence.medium | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.replica.persistence.sizeLimit }}
|
||||||
|
sizeLimit: {{ .Values.replica.persistence.sizeLimit | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
|
emptyDir: {}
|
||||||
|
{{- end }}
|
||||||
|
{{- else if .Values.replica.persistence.existingClaim }}
|
||||||
|
- name: redis-data
|
||||||
|
persistentVolumeClaim:
|
||||||
|
claimName: {{ printf "%s" (tpl .Values.replica.persistence.existingClaim .) }}
|
||||||
|
{{- else }}
|
||||||
|
{{- if .Values.sentinel.persistentVolumeClaimRetentionPolicy.enabled }}
|
||||||
|
persistentVolumeClaimRetentionPolicy:
|
||||||
|
whenDeleted: {{ .Values.sentinel.persistentVolumeClaimRetentionPolicy.whenDeleted }}
|
||||||
|
whenScaled: {{ .Values.sentinel.persistentVolumeClaimRetentionPolicy.whenScaled }}
|
||||||
|
{{- end }}
|
||||||
|
volumeClaimTemplates:
|
||||||
|
- apiVersion: v1
|
||||||
|
kind: PersistentVolumeClaim
|
||||||
|
metadata:
|
||||||
|
name: redis-data
|
||||||
|
labels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 10 }}
|
||||||
|
app.kubernetes.io/component: node
|
||||||
|
{{- if .Values.replica.persistence.annotations }}
|
||||||
|
annotations: {{- toYaml .Values.replica.persistence.annotations | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
{{- range .Values.replica.persistence.accessModes }}
|
||||||
|
- {{ . | quote }}
|
||||||
|
{{- end }}
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: {{ .Values.replica.persistence.size | quote }}
|
||||||
|
{{- if .Values.replica.persistence.selector }}
|
||||||
|
selector: {{- include "common.tplvalues.render" ( dict "value" .Values.replica.persistence.selector "context" $) | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- include "common.storage.class" (dict "persistence" .Values.replica.persistence "global" .Values.global) | nindent 8 }}
|
||||||
|
{{- if .Values.sentinel.persistence.enabled }}
|
||||||
|
- metadata:
|
||||||
|
name: sentinel-data
|
||||||
|
{{- $claimLabels := include "common.tplvalues.merge" ( dict "values" ( list .Values.sentinel.persistence.labels .Values.commonLabels ) "context" . ) }}
|
||||||
|
labels: {{- include "common.labels.matchLabels" ( dict "customLabels" $claimLabels "context" $ ) | nindent 10 }}
|
||||||
|
app.kubernetes.io/component: node
|
||||||
|
{{- if .Values.sentinel.persistence.annotations }}
|
||||||
|
annotations: {{- toYaml .Values.sentinel.persistence.annotations | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
accessModes:
|
||||||
|
{{- range .Values.sentinel.persistence.accessModes }}
|
||||||
|
- {{ . | quote }}
|
||||||
|
{{- end }}
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
storage: {{ .Values.sentinel.persistence.size | quote }}
|
||||||
|
{{- if .Values.sentinel.persistence.selector }}
|
||||||
|
selector: {{- include "common.tplvalues.render" ( dict "value" .Values.sentinel.persistence.selector "context" $) | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.sentinel.persistence.dataSource }}
|
||||||
|
dataSource: {{- include "common.tplvalues.render" (dict "value" .Values.sentinel.persistence.dataSource "context" $) | nindent 10 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- include "common.storage.class" (dict "persistence" .Values.sentinel.persistence "global" .Values.global) | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
18
helm/redis/templates/serviceaccount.yaml
Normal file
18
helm/redis/templates/serviceaccount.yaml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and .Values.serviceAccount.create .Values.sentinel.enabled }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: ServiceAccount
|
||||||
|
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
|
||||||
|
metadata:
|
||||||
|
name: {{ template "redis.serviceAccountName" . }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if or .Values.commonAnnotations .Values.serviceAccount.annotations }}
|
||||||
|
{{- $annotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.serviceAccount.annotations .Values.commonAnnotations ) "context" . ) }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" $annotations "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
70
helm/redis/templates/servicemonitor.yaml
Normal file
70
helm/redis/templates/servicemonitor.yaml
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if and .Values.metrics.enabled .Values.metrics.serviceMonitor.enabled }}
|
||||||
|
apiVersion: monitoring.coreos.com/v1
|
||||||
|
kind: ServiceMonitor
|
||||||
|
metadata:
|
||||||
|
name: {{ template "common.names.fullname" . }}
|
||||||
|
namespace: {{ default (include "common.names.namespace" .) .Values.metrics.serviceMonitor.namespace | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.metrics.serviceMonitor.additionalLabels }}
|
||||||
|
{{- include "common.tplvalues.render" (dict "value" .Values.metrics.serviceMonitor.additionalLabels "context" $) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
spec:
|
||||||
|
endpoints:
|
||||||
|
- port: http-metrics
|
||||||
|
{{- if .Values.metrics.serviceMonitor.interval }}
|
||||||
|
interval: {{ .Values.metrics.serviceMonitor.interval }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.serviceMonitor.scrapeTimeout }}
|
||||||
|
scrapeTimeout: {{ .Values.metrics.serviceMonitor.scrapeTimeout }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.serviceMonitor.honorLabels }}
|
||||||
|
honorLabels: {{ .Values.metrics.serviceMonitor.honorLabels }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.serviceMonitor.relabellings }}
|
||||||
|
relabelings: {{- toYaml .Values.metrics.serviceMonitor.relabellings | nindent 6 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.serviceMonitor.metricRelabelings }}
|
||||||
|
metricRelabelings: {{- toYaml .Values.metrics.serviceMonitor.metricRelabelings | nindent 6 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- range .Values.metrics.serviceMonitor.additionalEndpoints }}
|
||||||
|
- port: {{ .port }}
|
||||||
|
{{- if .interval }}
|
||||||
|
interval: {{ .interval }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .path }}
|
||||||
|
path: {{ .path }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .params }}
|
||||||
|
params:
|
||||||
|
{{- range $key, $value := .params }}
|
||||||
|
{{ $key }}:
|
||||||
|
{{- range $value }}
|
||||||
|
- {{ . | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if .Values.metrics.serviceMonitor.podTargetLabels }}
|
||||||
|
podTargetLabels: {{- toYaml .Values.metrics.serviceMonitor.podTargetLabels | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.metrics.serviceMonitor.sampleLimit }}
|
||||||
|
sampleLimit: {{ . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with .Values.metrics.serviceMonitor.targetLimit }}
|
||||||
|
targetLimit: {{ . }}
|
||||||
|
{{- end }}
|
||||||
|
namespaceSelector:
|
||||||
|
matchNames:
|
||||||
|
- {{ include "common.names.namespace" . | quote }}
|
||||||
|
selector:
|
||||||
|
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 6 }}
|
||||||
|
app.kubernetes.io/component: metrics
|
||||||
|
{{- end }}
|
||||||
31
helm/redis/templates/tls-secret.yaml
Normal file
31
helm/redis/templates/tls-secret.yaml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
{{- /*
|
||||||
|
Copyright VMware, Inc.
|
||||||
|
SPDX-License-Identifier: APACHE-2.0
|
||||||
|
*/}}
|
||||||
|
|
||||||
|
{{- if (include "redis.createTlsSecret" .) }}
|
||||||
|
{{- $secretName := printf "%s-crt" (include "common.names.fullname" .) }}
|
||||||
|
{{- $ca := genCA "redis-ca" 365 }}
|
||||||
|
{{- $releaseNamespace := (include "common.names.namespace" .) }}
|
||||||
|
{{- $clusterDomain := .Values.clusterDomain }}
|
||||||
|
{{- $fullname := include "common.names.fullname" . }}
|
||||||
|
{{- $serviceName := include "common.names.fullname" . }}
|
||||||
|
{{- $headlessServiceName := printf "%s-headless" (include "common.names.fullname" .) }}
|
||||||
|
{{- $masterServiceName := printf "%s-master" (include "common.names.fullname" .) }}
|
||||||
|
{{- $altNames := list (printf "*.%s.%s.svc.%s" $serviceName $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $masterServiceName $releaseNamespace $clusterDomain) (printf "*.%s.%s.svc.%s" $masterServiceName $releaseNamespace $clusterDomain) (printf "*.%s.%s.svc.%s" $headlessServiceName $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $headlessServiceName $releaseNamespace $clusterDomain) "127.0.0.1" "localhost" $fullname }}
|
||||||
|
{{- $cert := genSignedCert $fullname nil $altNames 365 $ca }}
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Secret
|
||||||
|
metadata:
|
||||||
|
name: {{ $secretName }}
|
||||||
|
namespace: {{ include "common.names.namespace" . | quote }}
|
||||||
|
labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
|
||||||
|
{{- if .Values.commonAnnotations }}
|
||||||
|
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
|
||||||
|
{{- end }}
|
||||||
|
type: kubernetes.io/tls
|
||||||
|
data:
|
||||||
|
tls.crt: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "tls.crt" "defaultValue" $cert.Cert "context" $) }}
|
||||||
|
tls.key: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "tls.key" "defaultValue" $cert.Key "context" $) }}
|
||||||
|
ca.crt: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "ca.crt" "defaultValue" $ca.Cert "context" $) }}
|
||||||
|
{{- end }}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user