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
#!/bin/bash | |
NAMESPACE=test | |
kubectl proxy & | |
kubectl get namespace $NAMESPACE -o json |jq '.spec = {"finalizers":[]}' >temp.json | |
curl -k -H "Content-Type: application/json" -X PUT --data-binary @temp.json 127.0.0.1:8001/api/v1/namespaces/$NAMESPACE/finalize | |
killall kubectl |
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
echo '{"my-field": "something"}' > example.json | |
cat example.json | jq '.my-field' # Incorrect | |
# jq: error: key/0 is not defined at <top-level>, line 1: .my-field | |
# jq: 1 compile error | |
cat example.json | jq '."my-field"' # Correct | |
# "something" |
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
#!/bin/bash | |
# Project in the form vcs-type/organisation-name/repository-name | |
PROJECT=github/magickatt/example | |
# First, get all the Pipeline IDs for this workflow (triggered by a Git tag from a new release) | |
PIPELINE_IDS=(`curl --silent GET https://circleci.com/api/v2/project/$PROJECT/pipeline \ | |
--header "Circle-Token: $CIRCLE_API_TOKEN" \ | |
| jq --raw-output '.items | map(select(.vcs.tag != null)) | .[].id'`) |
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
FROM python:3.9-buster | |
# Prevents issues with cloning private PIP packages from GitHub | |
RUN --mount=type=ssh mkdir -p ~/.ssh && ssh-keyscan -H github.com >> ~/.ssh/known_hosts | |
RUN pip install --upgrade pip | |
RUN pip install pipenv | |
COPY . . | |
# Use the forwarded SSH agent when installing pip packages |
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
- name: 'gcr.io/cloud-builders/git' | |
secretEnv: ['SSH_KEY'] | |
entrypoint: 'bash' | |
args: | |
- -c | |
- | | |
echo "$$SSH_KEY" >> /root/.ssh/id_rsa | |
chmod 400 /root/.ssh/id_rsa | |
volumes: | |
- name: 'ssh' |
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
#!/bin/bash | |
if [ "$#" -ne 1 ] | |
then | |
echo "Usage: restart_namespace \$NAMESPACE" | |
exit 1 | |
fi | |
NAMESPACE=$1 | |
echo "Restarting all deployments in $NAMESPACE..." |
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
#!/bin/bash | |
URI=https://www.yahoo.com | |
INTERVAL_IN_SECONDS=0.5 | |
RESULTS_PER_LINE=50 | |
echo "Checking $URI at ${INTERVAL_IN_SECONDS}s intervals..." | |
check_uri () { |
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
filebeat.autodiscover: | |
providers: | |
- type: kubernetes | |
hints.enabled: true | |
hints.default_config.enabled: false | |
add_resource_metadata: | |
namespace: | |
enabled: true | |
processors: | |
- add_kubernetes_metadata: |
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
#!/bin/bash | |
# Random number between 1 and 10 | |
WAIT=`shuf -i 1-10 -n 1` | |
# Subtract 1 from the random number, check if it is now 0 | |
is_random_number_zero () { | |
let WAIT=WAIT-1 | |
return $([[ "$WAIT" -eq "0" ]]) | |
} |
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
resource "google_compute_firewall" "allow_nodes_from_cloud_iap" { | |
name = "allow-gke-nodes-ssh-from-cloud-iap" | |
description = "Allow Cloud IAP to communicate with the the GKE nodes." | |
network = var.network | |
allow { | |
protocol = "tcp" | |
ports = ["22"] | |
} |