Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes test app verify for running with KinD on a MacOS #118

Merged
merged 1 commit into from
Oct 27, 2020

Conversation

diverdane
Copy link
Contributor

@diverdane diverdane commented Oct 26, 2020

When the Kubernetes Conjur demo scripts are run on a Kubernetes-in-Docker cluster
that is running on MacOS, then the demo script verification that the demo API
endpoints are reachable (check-url function) currently fails:

curl: (28) Connection timed out after 3003 milliseconds
'check_urls' Retry 5/150 exited 28, retrying in 2 seconds...

The problem is that using Node-IP:NodePort does not work for KinD on MacOS
because Docker on MacOS runs Docker containers inside a VM, so there is no
direct way to connect from the MacOS host to Kubernetes containers.

The fix is to add the creation of a test-curl pod in the test application namespace
that is capable of running curl from within the KinD cluster, and then using this
to verify applications using their internal service address.

This change also replaces the test environment variable TEST_APP_NODEPORT_SVCS
(defaults to false) with TEST_APP_LOADBALANCER_SVCS (defaults to true)
because that more accurately reflects what needs to be distinguished
(i.e. if there aren't any load balancers, the test application service type could
be either NodePort or clusterIP, since the test app verification is now
agnostic of NodePort vs clusterIP services.

Addresses Issue #117

@diverdane diverdane self-assigned this Oct 26, 2020
Copy link

@BradleyBoutcher BradleyBoutcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks for fixing this!

) > /dev/null
}

bl_retry_constant "${RETRIES}" "${RETRY_WAIT}" check_urls

echo -e "\nAdding entry to the init app\n"
curl \
$curl_cmd \
Copy link

@BradleyBoutcher BradleyBoutcher Oct 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be in favor of using a loop here for building the URL and subsequently querying all the containers, but I think that's out of the scope for this issue.

i.e. we could retrieve all the relevant URLs with

applications=$(kubectl get services -n ${TEST_APP_NAMESPACE_NAME} \
                        --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' \
                        | grep -p init )

or

applications=$(kubectl get services -n ${TEST_APP_NAMESPACE_NAME} \
                        --template '{{range .items}}{{.metadata.name}}{{"\n"}}{{end}}' \
                        | grep -p test-app )

Then perform a loop like this:

for app in $applications; do 
    APPLICATION_URL="http://${app}.${TEST_APP_NAMESPACE_NAME}.svc.cluster.local:8080"
done

@diverdane diverdane merged commit 0b61f3a into master Oct 27, 2020
@diverdane diverdane deleted the fix-kind-on-mac-demo branch October 27, 2020 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants