-
Notifications
You must be signed in to change notification settings - Fork 14
150 lines (125 loc) · 4.51 KB
/
Copy pathhelm-validate.yml
File metadata and controls
150 lines (125 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: Helm Validate
on:
pull_request:
paths:
- apollo-service/**
- apollo-portal/**
- .github/workflows/helm-validate.yml
push:
branches:
- main
paths:
- apollo-service/**
- apollo-portal/**
- .github/workflows/helm-validate.yml
workflow_dispatch:
permissions:
contents: read
jobs:
verify:
name: Validate Charts
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Helm
uses: azure/setup-helm@v4
with:
version: v3.15.2
- name: Install kubeconform
run: |
KUBECONFORM_VERSION=v0.6.7
curl -sSL "https://github.com/yannh/kubeconform/releases/download/${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz" \
| tar -xz kubeconform
sudo mv kubeconform /usr/local/bin/kubeconform
- name: Prepare validation values
run: |
VALUES_DIR="${RUNNER_TEMP}/apollo-values"
mkdir -p "${VALUES_DIR}"
cat > "${VALUES_DIR}/apollo-service-values-dev.yaml" <<'EOF'
configdb:
host: apollodb-mysql.mysql
dbName: DevApolloConfigDB
userName: root
password: test
connectionStringProperties: characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
configService:
replicaCount: 1
config:
contextPath: /config
ingress:
enabled: true
hosts:
- paths:
- /config
adminService:
replicaCount: 1
config:
contextPath: /admin
ingress:
enabled: true
hosts:
- paths:
- /admin
EOF
cat > "${VALUES_DIR}/apollo-service-values-pro.yaml" <<'EOF'
configdb:
host: apollodb-mysql.mysql
dbName: ProApolloConfigDB
userName: root
password: test
connectionStringProperties: characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
configService:
replicaCount: 1
adminService:
replicaCount: 1
EOF
cat > "${VALUES_DIR}/apollo-portal-values.yaml" <<'EOF'
portaldb:
host: apollodb-mysql.mysql
userName: root
password: test
connectionStringProperties: characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
replicaCount: 1
ingress:
enabled: true
hosts:
- paths:
- /apollo
config:
envs: dev,pro
contextPath: /apollo
metaServers:
dev: http://apollo-service-dev-apollo-configservice:8080/config
pro: http://apollo-service-pro-apollo-configservice:8080
EOF
echo "VALUES_DIR=${VALUES_DIR}" >> "${GITHUB_ENV}"
- name: Verify Helm charts
run: |
set -euo pipefail
OUTPUT_DIR="${RUNNER_TEMP}/helm-rendered"
rm -rf "${OUTPUT_DIR}"
mkdir -p "${OUTPUT_DIR}"
echo "[1/3] Lint charts"
helm lint "${GITHUB_WORKSPACE}/apollo-service" -f "${VALUES_DIR}/apollo-service-values-dev.yaml"
helm lint "${GITHUB_WORKSPACE}/apollo-service" -f "${VALUES_DIR}/apollo-service-values-pro.yaml"
helm lint "${GITHUB_WORKSPACE}/apollo-portal" -f "${VALUES_DIR}/apollo-portal-values.yaml"
echo "[2/3] Render manifests"
helm template apollo-service-dev "${GITHUB_WORKSPACE}/apollo-service" \
--namespace apollo \
-f "${VALUES_DIR}/apollo-service-values-dev.yaml" \
> "${OUTPUT_DIR}/apollo-service-dev.yaml"
helm template apollo-service-pro "${GITHUB_WORKSPACE}/apollo-service" \
--namespace apollo \
-f "${VALUES_DIR}/apollo-service-values-pro.yaml" \
> "${OUTPUT_DIR}/apollo-service-pro.yaml"
helm template apollo-portal "${GITHUB_WORKSPACE}/apollo-portal" \
--namespace apollo \
-f "${VALUES_DIR}/apollo-portal-values.yaml" \
> "${OUTPUT_DIR}/apollo-portal.yaml"
echo "[3/3] Validate manifests with kubeconform"
kubeconform -strict -ignore-missing-schemas \
"${OUTPUT_DIR}/apollo-service-dev.yaml" \
"${OUTPUT_DIR}/apollo-service-pro.yaml" \
"${OUTPUT_DIR}/apollo-portal.yaml"