-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Hasan Turken <[email protected]>
- Loading branch information
Showing
8 changed files
with
77 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Note: This example is for the alpha feature of server side apply. | ||
# It requires the provider to be started with the --enable-server-side-apply flag. | ||
apiVersion: kubernetes.crossplane.io/v1alpha2 | ||
kind: Object | ||
metadata: | ||
name: sample-service-owner | ||
annotations: | ||
uptest.upbound.io/pre-assert-hook: testhooks/enable-ssa.sh | ||
uptest.upbound.io/post-assert-hook: testhooks/validate-ssa.sh | ||
uptest.upbound.io/timeout: "60" | ||
# Note(turkenh): Import restarts Crossplane pod losing the cached provider package | ||
# hence preventing changes being redeployed with modified deployment runtime config. | ||
uptest.upbound.io/disable-import: "true" | ||
spec: | ||
forProvider: | ||
manifest: | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: sample-service | ||
namespace: default | ||
labels: | ||
some-key: some-value | ||
spec: | ||
selector: | ||
app.kubernetes.io/name: MyApp | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 9376 | ||
providerConfigRef: | ||
name: kubernetes-provider |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
set -aeuo pipefail | ||
|
||
echo "Enabling ssa feature for the provider" | ||
${KUBECTL} patch deploymentruntimeconfig runtimeconfig-provider-kubernetes --type='json' -p='[{"op":"replace","path":"/spec/deploymentTemplate/spec/template/spec/containers/0/args", "value":["--debug", "--enable-server-side-apply"]}]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env bash | ||
set -aeuo pipefail | ||
|
||
# This script is used to validate the ssa feature, triggered by the | ||
# uptest framework via `uptest.upbound.io/post-assert-hook`: https://github.com/crossplane/uptest/tree/e64457e2cce153ada54da686c8bf96143f3f6329?tab=readme-ov-file#hooks | ||
|
||
LABELER_OBJECT="examples/object/object-ssa-labeler.yaml" | ||
${KUBECTL} apply -f ${LABELER_OBJECT} | ||
${KUBECTL} wait -f ${LABELER_OBJECT} --for condition=ready --timeout=1m | ||
|
||
if ! ${KUBECTL} get service sample-service -o jsonpath='{.metadata.annotations}' | grep -v "last-applied-configuration"; then # This annotation should not be present when SSA is enabled | ||
echo "SSA validation failed! Annotation 'last-applied-configuration' should not exist when SSA is enabled!" | ||
#exit 1 | ||
fi | ||
if ! (${KUBECTL} get service sample-service -o jsonpath='{.metadata.labels.some-key}' | grep -q "some-value" && ${KUBECTL} get service sample-service -o jsonpath='{.metadata.labels.another-key}' | grep -q "another-value"); then | ||
echo "SSA validation failed! Labels 'some-key' and 'another-key' from both Objects should exist with values 'some-value' and 'another-value' respectively!" | ||
#exit 1 | ||
fi | ||
echo "Successfully validated the SSA feature!" | ||
|
||
${KUBECTL} delete -f ${LABELER_OBJECT} | ||
|
||
echo "Disabling SSA feature for the provider" | ||
${KUBECTL} patch deploymentruntimeconfig runtimeconfig-provider-kubernetes --type='json' -p='[{"op":"replace","path":"/spec/deploymentTemplate/spec/template/spec/containers/0/args", "value":["--debug"]}]' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters