Skip to content

Commit

Permalink
Test PostCreateHook
Browse files Browse the repository at this point in the history
Signed-off-by: Jun Duan <[email protected]>
  • Loading branch information
waltforme committed Mar 5, 2024
1 parent 58d6b23 commit 3737ea7
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 2 deletions.
9 changes: 9 additions & 0 deletions test/e2e/manage-type-k8s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,15 @@ kubectl --context kind-kubeflex -n cp1-system wait --for=condition=Available dep
kubectl --context cp1 create ns e2e
kubectl --context cp1 wait --for=jsonpath='{.status.phase}'=Active ns/e2e

:
: -------------------------------------------------------------------------
: Specify a PostCreateHook for cp1, then wait for the PostCreateHook to
: take effect, with default timeout which is 30 seconds
:
kubectl --context kind-kubeflex patch cp/cp1 --type=merge --patch '{"spec":{"postCreateHook":"synthetic-crd"}}'
wait-for-cmd 'kubectl --context kind-kubeflex get crd cr1s.synthetic-crd.com'
kubectl --context kind-kubeflex wait --for=condition=Established crd cr1s.synthetic-crd.com

:
: -------------------------------------------------------------------------
: Delete ControlPlane cp1
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/manage-type-vcluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ set -e # exit on error

:
: -------------------------------------------------------------------------
: Wait for the running component of ControlPlane cp2 to be ready
: Wait for the running component of ControlPlane cp2 to be ready/completed
:
kubectl --context kind-kubeflex -n cp2-system wait --for=jsonpath='{.status.availableReplicas}'=1 statefulset/vcluster
kubectl --context kind-kubeflex -n cp2-system wait --for=condition=Complete job/update-cluster-info --timeout=60s

:
: -------------------------------------------------------------------------
: Create a deployment in ControlPlane cp2, then wait for the deployment
: Create a Deployment in ControlPlane cp2, then wait for the Deployment
: to become available, with default timeout which is 30 seconds
:
kubectl --context cp2 create deployment my-nginx --image nginx
Expand Down
51 changes: 51 additions & 0 deletions test/e2e/setup-kubeflex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,54 @@ make build
: the kubeflex operator
:
./bin/kflex init --create-kind --chatty-status=false

:
: -------------------------------------------------------------------------
: Create a PostCreateHook
:
kubectl --context kind-kubeflex apply -f - <<EOF
apiVersion: tenancy.kflex.kubestellar.org/v1alpha1
kind: PostCreateHook
metadata:
name: synthetic-crd
spec:
templates:
- apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: cr1s.synthetic-crd.com
spec:
group: synthetic-crd.com
names:
kind: CR1
listKind: CR1List
plural: cr1s
singular: cr1
scope: Namespaced
versions:
- name: v1alpha1
served: true
storage: true
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
properties:
tier:
type: string
enum:
- Dedicated
- Shared
default: Shared
status:
type: object
properties:
phase:
type: string
required:
- spec
subresources:
status: {}
EOF

0 comments on commit 3737ea7

Please sign in to comment.