Skip to content

Commit

Permalink
test: add kcl run tests
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Sep 4, 2024
1 parent 6c5b656 commit 5042e5c
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 21 deletions.
11 changes: 2 additions & 9 deletions config/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,7 @@ spec:
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: kcl-operator
app.kubernetes.io/instance: controller-manager
app.kubernetes.io/managed-by: kustomize
app.kubernetes.io/name: serviceaccount
app.kubernetes.io/part-of: kcl-operator
name: controller-manager
name: webhook
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
Expand Down Expand Up @@ -115,7 +108,7 @@ roleRef:
name: webhook-role
subjects:
- kind: ServiceAccount
name: default
name: webhook
namespace: default
---
apiVersion: v1
Expand Down
4 changes: 2 additions & 2 deletions config/rbac/role_binding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ roleRef:
name: webhook-role
subjects:
- kind: ServiceAccount
name: default
namespace: system
name: webhook
namespace: default
11 changes: 2 additions & 9 deletions config/rbac/service_account.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
app.kubernetes.io/name: serviceaccount
app.kubernetes.io/instance: controller-manager
app.kubernetes.io/component: rbac
app.kubernetes.io/created-by: kcl-operator
app.kubernetes.io/part-of: kcl-operator
app.kubernetes.io/managed-by: kustomize
name: controller-manager
namespace: system
name: webhook
namespace: default
40 changes: 39 additions & 1 deletion scripts/deploy_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,46 @@ if [ $ROLLOUT_STATUS -ne 0 ]; then
echo -e "${YELLOW}Pod: $pod${NC}"
kubectl describe pod/$pod
echo -e "${YELLOW}Pod logs:${NC}"
kubectl logs $pod
kubectl logs $pod -c kcl-webhook-init
kubectl logs $pod -c kcl-webhook-server
done
else
echo -e "${GREEN}Deployment rollout successful.${NC}"
echo -e "${YELLOW}Deploying the KCL source...${NC}"
kubectl apply -f- << EOF
apiVersion: krm.kcl.dev/v1alpha1
kind: KCLRun
metadata:
name: set-annotation
spec:
params:
annotations:
managed-by: kcl-operator
source: |
items = [item | {
metadata.annotations: {"managed-by" = "kcl-operator"}
} for item in option("items")]
EOF
echo -e "${YELLOW}Validating the mutation result by creating a nginx Pod YAML...${NC}"
kubectl apply -f- << EOF
apiVersion: v1
kind: Pod
metadata:
name: nginx
annotations:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
EOF
echo -e "${YELLOW}Checking if the annotation 'managed-by: kcl-operator' is added to the pod...${NC}"
MANAGED_BY=$(kubectl get po nginx -o yaml | grep kcl-operator)
if [ -n "$MANAGED_BY" ]; then
echo -e "${GREEN}The annotation 'managed-by: kcl-operator' is added to the pod.${NC}"
else
echo -e "${RED}The annotation 'managed-by: kcl-operator' is not added to the pod.${NC}"
fi
fi

0 comments on commit 5042e5c

Please sign in to comment.