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

make healthchecks optional #33

Merged
merged 2 commits into from
Feb 12, 2020
Merged

make healthchecks optional #33

merged 2 commits into from
Feb 12, 2020

Conversation

sroettger
Copy link
Collaborator

a bunch of hacky changes to make it optional to deploy healthchecks
PTAL

@sroettger
Copy link
Collaborator Author

I removed the files from k8s/.base and autogenerate them now in .gen via the Makefiles.
The chain of kustomize files is then

  • k8s/deployment (written by the challenge creator)
  • .gen/k8s/deployment (generated by the makefile
  • ../kctf-conf/base/k8s/deployment-with-healthcheck (optional based on the generated one above)
  • ../kctf-conf/base/k8s/deployment

@@ -170,6 +172,18 @@ ${CLUSTER_GEN}/image-pushed: ${CLUSTER_GEN}/image-tagged
# LOCAL_DOCKER doesn't need to be pushed
touch $@

.maybe-healthcheck:
Copy link
Member

Choose a reason for hiding this comment

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

Since we know if HEALTHCHECK is true since the beginning, could we instead do:

ifeq ($(HEALTCHECK),true)
    .healtcheck-maybe: .healthcheck-enabled
else
    .healthcheck-maybe: .healthcheck-disabled
endif

https://ftp.gnu.org/old-gnu/Manuals/make-3.79.1/html_chapter/make_7.html

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

PTAL, I'm using ifeq everywhere now

echo "skipping deployment: DEPLOY=\"$${DEPLOY}\""
fi
endif

stop: .cluster-config
for resource_type in deployment service hpa; do
Copy link
Member

@sirdarckcat sirdarckcat Feb 12, 2020

Choose a reason for hiding this comment

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

FYI (since you removed the ifs and you only have for loops left):
instead of a bash for loop here, I think you could have a Makefile for loop.

$(foreach resource,deployment service hpa,kubectl get $(resource) && kubectl delete $(resource))

https://www.gnu.org/software/make/manual/html_node/Foreach-Function.html

You can make this more elegant (example) if readability was a concern.

Another option is to use xargs like this:

echo deployment service hpa | xargs echo "kubectl get {} && kubectl delete {}" | sh

And a few other ways. Not the most elegant, however, so up to you.

This and below would allow you to avoid bash mode.

@sroettger sroettger merged commit 9bc06f9 into master Feb 12, 2020
@sirdarckcat sirdarckcat deleted the optional-healthchecks branch February 12, 2020 16:42
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.

3 participants