Skip to content

Commit a0e169d

Browse files
authored
Merge pull request #106 from mhjacks/update_main
Update common to latest common/main for templated value files
2 parents 881d1f2 + 3fffa29 commit a0e169d

42 files changed

Lines changed: 1445 additions & 856 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

common/Changes.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changes
22

3+
## Sep 25, 2023
4+
5+
* Upgraded ESO to v0.9.5
6+
37
## Aug 17, 2023
48

59
* Introduced support for multisource applications via .chart + .chartVersion

common/Makefile

Lines changed: 55 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,13 @@ help: ## This help message
4444
show: ## show the starting template without installing it
4545
helm template common/operator-install/ --name-template $(NAME) $(HELM_OPTS)
4646

47-
# Only call helm install if the CRD is missing. If it already exists just
48-
# push the templated files.
49-
# The reason we have two helm template calls in the else branch is to avoid
50-
# warnings when the chart gets applied the first time, but the resources were
51-
# created first via the VP operator's UI
5247
.PHONY: operator-deploy
53-
operator-deploy operator-upgrade: validate-prereq validate-origin ## runs helm install
54-
@set -e; if ! oc get crds patterns.gitops.hybrid-cloud-patterns.io >/dev/null 2>&1; then \
55-
echo "Running helm:"; \
56-
helm upgrade --install $(NAME) common/operator-install/ $(HELM_OPTS); \
57-
else \
58-
echo "Reapplying helm chart:"; \
59-
helm template --name-template $(NAME) common/operator-install/ $(HELM_OPTS) | oc apply set-last-applied --create-annotation -f-; \
60-
helm template --name-template $(NAME) common/operator-install/ $(HELM_OPTS) | oc apply -f-; \
61-
fi
48+
operator-deploy operator-upgrade: validate-prereq validate-origin validate-cluster ## runs helm install
49+
@set -e -o pipefail
50+
# Retry five times because the CRD might not be fully installed yet
51+
for i in {1..5}; do \
52+
helm template --include-crds --name-template $(NAME) common/operator-install/ $(HELM_OPTS) | oc apply -f- && break || sleep 10; \
53+
done
6254

6355
.PHONY: uninstall
6456
uninstall: ## runs helm uninstall
@@ -98,6 +90,19 @@ validate-origin: ## verify the git origin is available
9890
echo "Running inside a container: Skipping git ssh checks";\
9991
fi
10092

93+
.PHONY: validate-cluster
94+
validate-cluster: ## Do some cluster validations before installing
95+
@echo "Checking cluster:"
96+
@echo -n " cluster-info: "
97+
@oc cluster-info >/dev/null && echo "OK" || (echo "Error"; exit 1)
98+
@echo -n " storageclass: "
99+
@if [ `oc get storageclass -o go-template='{{printf "%d\n" (len .items)}}'` -eq 0 ]; then\
100+
echo "None Found"; exit 1;\
101+
else\
102+
echo "OK";\
103+
fi
104+
105+
101106
.PHONY: validate-schema
102107
validate-schema: ## validates values files against schema in common/clustergroup
103108
$(eval VAL_PARAMS := $(shell for i in ./values-*.yaml; do echo -n "$${i} "; done))
@@ -117,14 +122,46 @@ validate-prereq: ## verify pre-requisites
117122
@if ! ansible-galaxy collection list | grep kubernetes.core > /dev/null 2>&1; then echo "Not found"; exit 1; fi
118123
@echo "OK"
119124

125+
.PHONY: argo-healthcheck
126+
argo-healthcheck: ## Checks if all argo applications are synced
127+
@echo "Checking argo applications"
128+
$(eval APPS := $(shell oc get applications -A -o jsonpath='{range .items[*]}{@.metadata.namespace}{","}{@.metadata.name}{"\n"}{end}'))
129+
@NOTOK=0; \
130+
for i in $(APPS); do\
131+
n=`echo "$${i}" | cut -f1 -d,`;\
132+
a=`echo "$${i}" | cut -f2 -d,`;\
133+
STATUS=`oc get -n "$${n}" application/"$${a}" -o jsonpath='{.status.sync.status}'`;\
134+
if [[ $$STATUS != "Synced" ]]; then\
135+
NOTOK=$$(( $${NOTOK} + 1));\
136+
fi;\
137+
HEALTH=`oc get -n "$${n}" application/"$${a}" -o jsonpath='{.status.health.status}'`;\
138+
if [[ $$HEALTH != "Healthy" ]]; then\
139+
NOTOK=$$(( $${NOTOK} + 1));\
140+
fi;\
141+
echo "$${n} $${a} -> Sync: $${STATUS} - Health: $${HEALTH}";\
142+
done;\
143+
if [ $${NOTOK} -gt 0 ]; then\
144+
echo "Some applications are not synced or are unhealthy";\
145+
exit 1;\
146+
fi
147+
148+
120149
##@ Test and Linters Tasks
121150

122151
CHARTS=$(shell find . -type f -iname 'Chart.yaml' -exec dirname "{}" \; | grep -v examples | sed -e 's/.\///')
123152
# Section related to tests and linting
124-
TEST_OPTS= -f values-global.yaml --set global.repoURL="https://github.com/pattern-clone/mypattern" \
125-
--set main.git.repoURL="https://github.com/pattern-clone/mypattern" --set main.git.revision=main --set global.pattern="mypattern" \
126-
--set global.namespace="pattern-namespace" --set global.hubClusterDomain=apps.hub.example.com --set global.localClusterDomain=apps.region.example.com --set global.clusterDomain=region.example.com\
127-
--set "clusterGroup.imperative.jobs[0].name"="test" --set "clusterGroup.imperative.jobs[0].playbook"="ansible/test.yml"
153+
TEST_OPTS= -f values-global.yaml \
154+
--set global.repoURL="https://github.com/pattern-clone/mypattern" \
155+
--set main.git.repoURL="https://github.com/pattern-clone/mypattern" \
156+
--set main.git.revision=main --set global.pattern="mypattern" \
157+
--set global.namespace="pattern-namespace" \
158+
--set global.hubClusterDomain=apps.hub.example.com \
159+
--set global.localClusterDomain=apps.region.example.com \
160+
--set global.clusterDomain=region.example.com \
161+
--set global.clusterVersion="4.12" \
162+
--set global.clusterPlatform=aws \
163+
--set "clusterGroup.imperative.jobs[0].name"="test" \
164+
--set "clusterGroup.imperative.jobs[0].playbook"="ansible/test.yml"
128165
PATTERN_OPTS=-f common/examples/values-example.yaml
129166
EXECUTABLES=git helm oc ansible
130167

common/ansible/roles/iib_ci/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ make load-iib
2626
# This will install the pattern using the gitops operator from the IIB
2727
```
2828

29+
***NOTE:*** When using an SNO without shared storage in a non-production environment, the enablement of the internal registry will fail. You need to run the following to enable it:
30+
31+
```sh
32+
oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"managementState":"Managed"}}'
33+
oc patch configs.imageregistry.operator.openshift.io cluster --type merge --patch '{"spec":{"storage":{"emptyDir":{}}}}'
34+
```
35+
2936
Then in case of the `openshift-gitops-operator` we would install with:
3037

3138
```sh

common/ansible/roles/iib_ci/tasks/setup-internal-registry.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
oc registry info --public=true
3535
register: registry_route_raw
3636
retries: 20
37-
delay: 10
37+
delay: 20
3838
until:
3939
- registry_route_raw is not failed
4040
- registry_route_raw.stdout | length > 0

common/clustergroup/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ description: A Helm chart to create per-clustergroup ArgoCD applications and any
33
keywords:
44
- pattern
55
name: clustergroup
6-
version: 0.0.2
6+
version: 0.0.4

common/clustergroup/templates/imperative/job.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- if not (eq .Values.enabled "plumbing") }}
22
{{/* Define this if needed (jobs defined */}}
3-
{{- if (gt (len $.Values.clusterGroup.imperative.jobs) 0) -}}
3+
{{- if (and $.Values.clusterGroup.imperative (gt (len $.Values.clusterGroup.imperative.jobs) 0)) -}}
44
---
55
apiVersion: batch/v1
66
kind: CronJob
@@ -66,4 +66,4 @@ spec:
6666
name: {{ $.Values.clusterGroup.imperative.valuesConfigMap }}-{{ $.Values.clusterGroup.name }}
6767
restartPolicy: Never
6868
{{- end }}
69-
{{- end }}
69+
{{- end }}

common/clustergroup/templates/plumbing/applications.yaml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ spec:
5959
ignoreMissingValueFiles: true
6060
valueFiles:
6161
{{- include "clustergroup.app.globalvalues.valuefiles" $ | nindent 12 }}
62-
{{- range .extraValueFiles }}
63-
- {{ . | quote }}
62+
{{- range $valueFile := $.Values.clusterGroup.sharedValueFiles }}
63+
- {{ tpl $valueFile $ | quote }}
64+
{{- end }}
65+
{{- range $valueFile := .extraValueFiles }}
66+
- {{ tpl $valueFile $ | quote }}
6467
{{- end }}
6568
{{- if .useGeneratorValues }}
6669
values: |-
@@ -121,6 +124,8 @@ kind: Application
121124
metadata:
122125
name: {{ .name }}
123126
namespace: {{ $namespace }}
127+
labels:
128+
validatedpatterns.io/pattern: {{ $.Values.global.pattern }}
124129
finalizers:
125130
- resources-finalizer.argocd.argoproj.io/foreground
126131
spec:
@@ -145,8 +150,11 @@ spec:
145150
ignoreMissingValueFiles: true
146151
valueFiles:
147152
{{- include "clustergroup.app.globalvalues.prefixedvaluefiles" $ | nindent 8 }}
153+
{{- range $valueFile := $.Values.clusterGroup.sharedValueFiles }}
154+
- {{ tpl $valueFile $ | quote }}
155+
{{- end }}
148156
{{- range $valueFile := .extraValueFiles }}
149-
- {{ $valueFile | quote }}
157+
- {{ tpl $valueFile $ | quote }}
150158
{{- end }}
151159
parameters:
152160
{{- include "clustergroup.app.globalvalues.helmparameters" $ | nindent 8 }}
@@ -209,8 +217,11 @@ spec:
209217
ignoreMissingValueFiles: true
210218
valueFiles:
211219
{{- include "clustergroup.app.globalvalues.valuefiles" $ | nindent 6 }}
220+
{{- range $valueFile := $.Values.clusterGroup.sharedValueFiles }}
221+
- {{ tpl $valueFile $ | quote }}
222+
{{- end }}
212223
{{- range $valueFile := .extraValueFiles }}
213-
- {{ $valueFile | quote }}
224+
- {{ tpl $valueFile $ | quote }}
214225
{{- end }}
215226
parameters:
216227
{{- include "clustergroup.app.globalvalues.helmparameters" $ | nindent 8 }}

common/clustergroup/templates/plumbing/argocd.yaml

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,27 @@ metadata:
1414
spec:
1515
# Adding health checks to argocd to prevent pvc resources
1616
# that aren't bound state from blocking deployments
17-
resourceCustomizations: |
18-
PersistentVolumeClaim:
19-
health.lua: |
20-
hs = {}
21-
if obj.status ~= nil then
22-
if obj.status.phase ~= nil then
23-
if obj.status.phase == "Pending" then
24-
hs.status = "Healthy"
25-
hs.message = obj.status.phase
26-
return hs
27-
elseif obj.status.phase == "Bound" then
28-
hs.status = "Healthy"
29-
hs.message = obj.status.phase
30-
return hs
31-
end
17+
resourceHealthChecks:
18+
- kind: PersistentVolumeClaim
19+
check: |
20+
hs = {}
21+
if obj.status ~= nil then
22+
if obj.status.phase ~= nil then
23+
if obj.status.phase == "Pending" then
24+
hs.status = "Healthy"
25+
hs.message = obj.status.phase
26+
return hs
27+
elseif obj.status.phase == "Bound" then
28+
hs.status = "Healthy"
29+
hs.message = obj.status.phase
30+
return hs
3231
end
3332
end
34-
hs.status = "Progressing"
35-
hs.message = "Waiting for PVC"
36-
return hs
33+
end
34+
hs.status = "Progressing"
35+
hs.message = "Waiting for PVC"
36+
return hs
37+
3738
applicationInstanceLabelKey: argocd.argoproj.io/instance
3839
# Not the greatest way to pass git/quay info to sub-applications, but it will do until
3940
# we can support helmChart with kustomize

common/clustergroup/values.schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@
234234
"type": "boolean",
235235
"description": "If set to true the values is used to identify whether this is the hub cluster or an edge/spoke cluster configuration."
236236
},
237+
"sharedValueFiles": {
238+
"type": "array",
239+
"description": "Templated value file paths."
240+
},
237241
"namespaces": {
238242
"type": "array",
239243
"description": "This is the array of namespaces that the VP framework will create. In addition, operator groups will also be created for each namespace.",

common/clustergroup/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ global:
88
installPlanApproval: Automatic
99
applicationRetryLimit: 20
1010

11+
1112
enabled: "all"
1213

1314
# Note that sometimes changing helm values might require a hard refresh (https://github.com/helm/helm/issues/3486)
1415
clusterGroup:
1516
name: example
1617
isHubCluster: true
1718
targetCluster: in-cluster
19+
sharedValueFiles: []
1820

1921
imperative:
2022
jobs: []

0 commit comments

Comments
 (0)