Skip to content

Commit

Permalink
Test for clean redeploys with kapp
Browse files Browse the repository at this point in the history
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 <andrewssc@vmware.com>
  • Loading branch information
scothis committed Feb 4, 2022
1 parent b4584a8 commit ea6137c
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 7 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ jobs:
with:
go-version: 1.15.x
- uses: vmware-tanzu/carvel-setup-action@v1
with:
imgpkg: v0.22.0
- run: |
imgpkg version
kbld version
Expand Down Expand Up @@ -219,6 +217,7 @@ jobs:
ytt -f config/carvel/package-install.yaml -f config/carvel/package-install.values.yaml \
--data-value package_constraints=$(cat VERSION) \
--data-value-yaml 'package_prerelease={}' \
--data-value sync_period=1m \
)
- name: Deploy Spring Petclinic
run: |
Expand All @@ -231,6 +230,8 @@ jobs:
kapp deploy -a spring-petclinic -f samples/spring-petclinic/workload.yaml -y
- name: Collect diagnostics
run: |
set +o errexit
echo "##[group]Describe nodes"
kubectl describe nodes
echo "##[endgroup]"
Expand All @@ -246,6 +247,12 @@ jobs:
echo "##[group]Package Installs"
kubectl get packageinstall -A -oyaml
echo "##[endgroup]"
echo "##[group]Kapp list apps"
kapp list -A
echo "##[endgroup]"
echo "##[group]Package changesets"
kapp app-change list -a service-bindings-ctrl
echo "##[endgroup]"
echo "##[group]Service Binding manager logs"
kubectl logs -n service-bindings -l app=manager -c manager --tail 1000
echo "##[endgroup]"
Expand All @@ -263,6 +270,17 @@ jobs:
echo "##[endgroup]"
if: always()
continue-on-error: true
- name: Fail for multiple kapp changes
run: |
set -o errexit
set -o nounset
set -o pipefail
deploys=$(kapp app-change list -a service-bindings-ctrl --json | jq '.Tables[0].Rows | length')
if [ "$deploys" != "1" ]; then
echo "Too many app changes for the service-binding package, expected 1 found ${deploys}"
exit 1
fi
- name: Cleanup Spring Petclinic
run: |
set -o errexit
Expand Down
2 changes: 1 addition & 1 deletion config/200-clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ aggregationRule:
# legacy support
- matchLabels:
service.binding/controller: "true"
rules: [] # Rules are automatically filled in by the controller manager.
# rules are automatically filled in at runtime.
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
2 changes: 1 addition & 1 deletion config/400-webhook-configuration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ metadata:
namespace: service-bindings
labels:
bindings.labs.vmware.com/release: devel
# The data is populated at install time.
# data is populated at runtime.
1 change: 1 addition & 0 deletions config/carvel/package-install.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ package_prerelease: null
service_account_name: service-binding-kc
cluster_role_name: service-binding-kc
cluster_role_binding_name: service-binding-kc
sync_period: 10m
1 change: 1 addition & 0 deletions config/carvel/package-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ metadata:
kapp.k14s.io/change-rule: "upsert after upserting service-bindings.labs.vmware.com/install-rbac"
spec:
serviceAccountName: #@ data.values.service_account_name
syncPeriod: #@ data.values.sync_period
packageRef:
refName: #@ data.values.package_name
versionSelection:
Expand Down
11 changes: 8 additions & 3 deletions config/config-kapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ data:
type: copy
sources: [existing]
resourceMatchers:
- kindNamespaceNameMatcher: {kind: ClusterRole, namespace: "", name: service-binding-admin}
- andMatcher:
matchers:
- apiVersionKindMatcher: {apiVersion: rbac.authorization.k8s.io/v1, kind: ClusterRole}
- kindNamespaceNameMatcher: {kind: ClusterRole, name: service-binding-admin}
- path: [data]
type: copy
sources: [existing]
resourceMatchers:
- kindNamespaceNameMatcher: {kind: Secret, namespace: service-bindings, name: webhook-certs}
- andMatcher:
matchers:
- apiVersionKindMatcher: {apiVersion: v1, kind: Secret}
- kindNamespaceNameMatcher: {kind: Secret, namespace: service-bindings, name: webhook-certs}
- paths:
- [metadata, annotations]
- [webhooks, {allIndexes: true}, clientConfig, caBundle]
- [webhooks, {allIndexes: true}, clientConfig, service, path]
- [webhooks, {allIndexes: true}, clientConfig, service, port]
Expand Down

0 comments on commit ea6137c

Please sign in to comment.