mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-10-22 04:18:53 +00:00
Merge pull request #11865 from microsoft/danmihai1/nested-configmap-secret
tests: k8s-nested-configmap-secret policy
This commit is contained in:
@@ -15,18 +15,31 @@ setup() {
|
|||||||
get_pod_config_dir
|
get_pod_config_dir
|
||||||
|
|
||||||
pod_name="nested-configmap-secret-pod"
|
pod_name="nested-configmap-secret-pod"
|
||||||
|
yaml_file="${pod_config_dir}/pod-nested-configmap-secret.yaml"
|
||||||
|
|
||||||
|
# Add policy to yaml file
|
||||||
|
policy_settings_dir="$(create_tmp_policy_settings_dir "${pod_config_dir}")"
|
||||||
|
|
||||||
|
exec_command1=(cat /config/config_key)
|
||||||
|
add_exec_to_policy_settings "${policy_settings_dir}" "${exec_command1[@]}"
|
||||||
|
|
||||||
|
exec_command2=(cat /config/secret/secret_key)
|
||||||
|
add_exec_to_policy_settings "${policy_settings_dir}" "${exec_command2[@]}"
|
||||||
|
|
||||||
|
add_requests_to_policy_settings "${policy_settings_dir}" "ReadStreamRequest"
|
||||||
|
auto_generate_policy "${policy_settings_dir}" "${yaml_file}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "Nested mount of a secret volume in a configmap volume for a pod" {
|
@test "Nested mount of a secret volume in a configmap volume for a pod" {
|
||||||
# Creates a configmap, secret and pod that mounts the secret inside the configmap
|
# Creates a configmap, secret and pod that mounts the secret inside the configmap
|
||||||
kubectl create -f "${pod_config_dir}/pod-nested-configmap-secret.yaml"
|
kubectl create -f "${yaml_file}"
|
||||||
|
|
||||||
# Check pod creation
|
# Check pod creation
|
||||||
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
|
kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name"
|
||||||
|
|
||||||
# Check config/secret value are correct
|
# Check config/secret value are correct
|
||||||
[ "myconfig" == $(kubectl exec $pod_name -- cat /config/config_key) ]
|
[ "myconfig" == $(kubectl exec $pod_name -- "${exec_command1[@]}") ]
|
||||||
[ "mysecret" == $(kubectl exec $pod_name -- cat /config/secret/secret_key) ]
|
[ "mysecret" == $(kubectl exec $pod_name -- "${exec_command2[@]}") ]
|
||||||
}
|
}
|
||||||
|
|
||||||
teardown() {
|
teardown() {
|
||||||
@@ -37,5 +50,7 @@ teardown() {
|
|||||||
kubectl describe "pod/$pod_name"
|
kubectl describe "pod/$pod_name"
|
||||||
|
|
||||||
# Delete the configmap, secret, and pod used for testing
|
# Delete the configmap, secret, and pod used for testing
|
||||||
kubectl delete -f "${pod_config_dir}/pod-nested-configmap-secret.yaml"
|
kubectl delete -f "${yaml_file}"
|
||||||
|
|
||||||
|
delete_tmp_policy_settings_dir "${policy_settings_dir}"
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user