github.com/kata-containers/tests@v0.0.0-20240307153542-772105b56064/integration/kubernetes/k8s-configmap.bats (about) 1 #!/usr/bin/env bats 2 # 3 # Copyright (c) 2018 Intel Corporation 4 # 5 # SPDX-License-Identifier: Apache-2.0 6 # 7 8 load "${BATS_TEST_DIRNAME}/../../.ci/lib.sh" 9 load "${BATS_TEST_DIRNAME}/tests_common.sh" 10 11 setup() { 12 get_pod_config_dir 13 } 14 15 @test "ConfigMap for a pod" { 16 config_name="test-configmap" 17 pod_name="config-env-test-pod" 18 19 # Create ConfigMap 20 kubectl create -f "${pod_config_dir}/configmap.yaml" 21 22 # View the values of the keys 23 kubectl get configmaps $config_name -o yaml | grep -q "data-" 24 25 # Create a pod that consumes the ConfigMap 26 kubectl create -f "${pod_config_dir}/pod-configmap.yaml" 27 28 # Check pod creation 29 kubectl wait --for=condition=Ready --timeout=$timeout pod "$pod_name" 30 31 # Check env 32 cmd="env" 33 kubectl exec $pod_name -- sh -c $cmd | grep "KUBE_CONFIG_1=value-1" 34 kubectl exec $pod_name -- sh -c $cmd | grep "KUBE_CONFIG_2=value-2" 35 } 36 37 teardown() { 38 # Debugging information 39 kubectl describe "pod/$pod_name" 40 41 kubectl delete pod "$pod_name" 42 kubectl delete configmap "$config_name" 43 }