Skip to content

Commit ebb2924

Browse files
authored
Test for clean redeploys with kapp (vmware-tanzu#208)
* Test for clean redeploys with kapp A kapp deploy will attempt to make the resources on the api server match the resources defined locally. Because the manager will modify the resources we create at runtime, we should respect those mutations and avoid overwriting them. This is typically done with rebase rules in the kapp config resource. During the acceptance tests, we set the kapp-controller sync period for the package to 1 minute. If we see multiple changeset, the config is not stable. Signed-off-by: Scott Andrews <[email protected]> * try a 10s sync period Signed-off-by: Scott Andrews <[email protected]>
1 parent 234cdd9 commit ebb2924

6 files changed

+32
-7
lines changed

.github/workflows/ci.yaml

+20-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ jobs:
3939
with:
4040
go-version: 1.15.x
4141
- uses: vmware-tanzu/carvel-setup-action@v1
42-
with:
43-
imgpkg: v0.22.0
4442
- run: |
4543
imgpkg version
4644
kbld version
@@ -231,6 +229,7 @@ jobs:
231229
ytt -f config/carvel/package-install.yaml -f config/carvel/package-install.values.yaml \
232230
--data-value package_constraints=$(cat VERSION) \
233231
--data-value-yaml 'package_prerelease={}' \
232+
--data-value sync_period=10s \
234233
)
235234
- name: Deploy Spring Petclinic
236235
run: |
@@ -243,6 +242,8 @@ jobs:
243242
kapp deploy -a spring-petclinic -f samples/spring-petclinic/workload.yaml -y
244243
- name: Collect diagnostics
245244
run: |
245+
set +o errexit
246+
246247
echo "##[group]Describe nodes"
247248
kubectl describe nodes
248249
echo "##[endgroup]"
@@ -258,6 +259,12 @@ jobs:
258259
echo "##[group]Package Installs"
259260
kubectl get packageinstall -A -oyaml
260261
echo "##[endgroup]"
262+
echo "##[group]Kapp list apps"
263+
kapp list -A
264+
echo "##[endgroup]"
265+
echo "##[group]Package changesets"
266+
kapp app-change list -a service-bindings-ctrl
267+
echo "##[endgroup]"
261268
echo "##[group]Service Binding manager logs"
262269
kubectl logs -n service-bindings -l app=manager -c manager --tail 1000
263270
echo "##[endgroup]"
@@ -275,6 +282,17 @@ jobs:
275282
echo "##[endgroup]"
276283
if: always()
277284
continue-on-error: true
285+
- name: Fail for multiple kapp changes
286+
run: |
287+
set -o errexit
288+
set -o nounset
289+
set -o pipefail
290+
291+
deploys=$(kapp app-change list -a service-bindings-ctrl --json | jq '.Tables[0].Rows | length')
292+
if [ "$deploys" != "1" ]; then
293+
echo "Too many app changes for the service-binding package, expected 1 found ${deploys}"
294+
exit 1
295+
fi
278296
- name: Cleanup Spring Petclinic
279297
run: |
280298
set -o errexit

config/200-clusterrole.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ aggregationRule:
1414
# legacy support
1515
- matchLabels:
1616
service.binding/controller: "true"
17-
rules: [] # Rules are automatically filled in by the controller manager.
17+
# rules are automatically filled in at runtime.
1818
---
1919
kind: ClusterRole
2020
apiVersion: rbac.authorization.k8s.io/v1

config/400-webhook-configuration.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ metadata:
8484
namespace: service-bindings
8585
labels:
8686
bindings.labs.vmware.com/release: devel
87-
# The data is populated at install time.
87+
# data is populated at runtime.

config/carvel/package-install.values.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ package_prerelease: null
1212
service_account_name: service-binding-kc
1313
cluster_role_name: service-binding-kc
1414
cluster_role_binding_name: service-binding-kc
15+
sync_period: 10m

config/carvel/package-install.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ metadata:
1414
kapp.k14s.io/change-rule: "upsert after upserting service-bindings.labs.vmware.com/install-rbac"
1515
spec:
1616
serviceAccountName: #@ data.values.service_account_name
17+
syncPeriod: #@ data.values.sync_period
1718
packageRef:
1819
refName: #@ data.values.package_name
1920
versionSelection:

config/config-kapp.yaml

+8-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,19 @@ data:
1919
type: copy
2020
sources: [existing]
2121
resourceMatchers:
22-
- kindNamespaceNameMatcher: {kind: ClusterRole, namespace: "", name: service-binding-admin}
22+
- andMatcher:
23+
matchers:
24+
- apiVersionKindMatcher: {apiVersion: rbac.authorization.k8s.io/v1, kind: ClusterRole}
25+
- kindNamespaceNameMatcher: {kind: ClusterRole, name: service-binding-admin}
2326
- path: [data]
2427
type: copy
2528
sources: [existing]
2629
resourceMatchers:
27-
- kindNamespaceNameMatcher: {kind: Secret, namespace: service-bindings, name: webhook-certs}
30+
- andMatcher:
31+
matchers:
32+
- apiVersionKindMatcher: {apiVersion: v1, kind: Secret}
33+
- kindNamespaceNameMatcher: {kind: Secret, namespace: service-bindings, name: webhook-certs}
2834
- paths:
29-
- [metadata, annotations]
3035
- [webhooks, {allIndexes: true}, clientConfig, caBundle]
3136
- [webhooks, {allIndexes: true}, clientConfig, service, path]
3237
- [webhooks, {allIndexes: true}, clientConfig, service, port]

0 commit comments

Comments
 (0)