-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
ACM: Wait for gatekeeper & Hub: expose module_depends_on #689
Merged
bharathkkb
merged 13 commits into
terraform-google-modules:master
from
CloudPharaoh:hub_depends_on
Oct 1, 2020
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9546ca9
wait for gatekeeper if policy controller is enabled
cloud-pharaoh 606b4dd
destroy command
cloud-pharaoh 851f366
forgot the var
cloud-pharaoh 318f6d7
use deployment ready
cloud-pharaoh aa1c7c9
add context
cloud-pharaoh cf12c71
more wait
cloud-pharaoh 937b7f3
webhook
cloud-pharaoh 0798f47
depends_on
cloud-pharaoh 3bdd33f
concat modules
cloud-pharaoh 82bbe29
depends on
cloud-pharaoh f4f3a3a
terraform format
cloud-pharaoh 690ac7f
update docs
cloud-pharaoh 561b9dc
shell check
cloud-pharaoh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
modules/k8s-operator-crd-support/scripts/wait_for_gatekeeper.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/bin/bash | ||
# Copyright 2018 Google LLC | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
is_deployment_ready() { | ||
kubectl --context "$1" -n "$2" get deploy "$3" &> /dev/null | ||
export exit_code=$? | ||
while [ ! " ${exit_code} " -eq 0 ] | ||
do | ||
sleep 5 | ||
echo -e "Waiting for deployment $3 in cluster $1 to be created..." | ||
kubectl --context "$1" -n "$2" get deploy "$3" &> /dev/null | ||
export exit_code=$? | ||
done | ||
echo -e "Deployment $3 in cluster $1 created." | ||
|
||
# Once deployment is created, check for deployment status.availableReplicas is greater than 0 | ||
availableReplicas=$(kubectl --context "$1" -n "$2" get deploy "$3" -o json | jq -r '.status.availableReplicas') | ||
while [[ " ${availableReplicas} " == " null " ]] | ||
do | ||
sleep 5 | ||
echo -e "Waiting for deployment $3 in cluster $1 to become ready..." | ||
availableReplicas=$(kubectl --context "$1" -n "$2" get deploy "$3" -o json | jq -r '.status.availableReplicas') | ||
done | ||
|
||
echo -e "$3 in cluster $1 is ready with replicas ${availableReplicas}." | ||
return "${availableReplicas}" | ||
} | ||
|
||
is_service_ready() { | ||
kubectl --context "$1" -n "$2" get service "$3" &> /dev/null | ||
export exit_code=$? | ||
while [ ! " ${exit_code} " -eq 0 ] | ||
do | ||
sleep 5 | ||
echo -e "Waiting for service $3 in cluster $1 to be created..." | ||
kubectl --context "$1" -n "$2" get service "$3" &> /dev/null | ||
export exit_code=$? | ||
done | ||
echo -e "Service $3 in cluster $1 created." | ||
|
||
# Once service is created, check endpoints is greater than 0 | ||
kubectl --context "$1" -n "$2" get endpoints "$3" | ||
export exit_code=$? | ||
|
||
while [ ! " ${exit_code} " -eq 0 ] | ||
do | ||
sleep 5 | ||
echo -e "Waiting for endpoints for service $3 in cluster $1 to become ready..." | ||
kubectl --context "$1" -n "$2" get endpoints "$3" | ||
export exit_code=$? | ||
done | ||
|
||
echo -e "Service $3 in cluster $1 is ready with endpoints." | ||
return | ||
} | ||
|
||
if [ "$#" -lt 3 ]; then | ||
>&2 echo "Not all expected arguments set." | ||
exit 1 | ||
fi | ||
|
||
PROJECT_ID=$1 | ||
CLUSTER_NAME=$2 | ||
CLUSTER_LOCATION=$3 | ||
|
||
# Gatekeeper causes issues if not ready | ||
is_deployment_ready gke_"${PROJECT_ID}"_"${CLUSTER_LOCATION}"_"${CLUSTER_NAME}" gatekeeper-system gatekeeper-controller-manager | ||
is_service_ready gke_"${PROJECT_ID}"_"${CLUSTER_LOCATION}"_"${CLUSTER_NAME}" gatekeeper-system gatekeeper-webhook-service |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we not just do
kubectl wait --for=condition=available --timeout=600s deployment/foo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested a few times with
kubectl wait
and it did not work. There were other issues as well so it might not have been the most scientific testing strategy :) I can go back and test it if you think it is cleaner.I ended up leaving it in as the service one required a "custom" check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should try for the native wait if possible, although not a blocker. Yeah unfortunately we cant do that for svc.