Skip to content

Commit

Permalink
Merge branch 'master' into bump-automation-flavors-versions-pr-206
Browse files Browse the repository at this point in the history
  • Loading branch information
davdhacs committed Jun 13, 2024
2 parents b40a28b + 86c0a53 commit 2b96af1
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 18 deletions.
10 changes: 5 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -257,23 +257,23 @@ bounce-argo-pods:
## Secrets ##
#############
.PHONY: secrets-download
secrets-download: pre-check
secrets-download:
@./scripts/deploy/secrets.sh download_secrets $(ENVIRONMENT)

.PHONY: secrets-upload
secrets-upload: pre-check
secrets-upload:
@./scripts/deploy/secrets.sh upload_secrets $(ENVIRONMENT) $(SECRET_VERSION)

.PHONY: secrets-show
secrets-show: pre-check
secrets-show:
@./scripts/deploy/secrets.sh show $(ENVIRONMENT) $(SECRET_VERSION)

.PHONY: secrets-edit
secrets-edit: pre-check
secrets-edit:
@./scripts/deploy/secrets.sh edit $(ENVIRONMENT) $(SECRET_VERSION)

.PHONY: secrets-revert
secrets-revert: pre-check
secrets-revert:
@./scripts/deploy/secrets.sh revert $(ENVIRONMENT) $(SECRET_VERSION)

##################
Expand Down
2 changes: 1 addition & 1 deletion chart/infra-server/static/flavors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@

- name: machine-type
description: node machine type
value: e2-standard-4
value: e2-standard-8
kind: optional

- name: k8s-version
Expand Down
13 changes: 1 addition & 12 deletions scripts/deploy/secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,7 @@ TASK="$1"
ENVIRONMENT="$2"
SECRET_VERSION="${3:-latest}"

PROJECT="stackrox-infra"

check_not_empty() {
for V in "$@"; do
typeset -n VAR="$V"
if [ -z "${VAR:-}" ]; then
echo "ERROR: Variable $V is not set or empty"
exit 1
fi
done
}
PROJECT="${INFRA_GCP_PROJECT:-acs-team-automation}"

# Downloads secrets files for an ENVIRONMENT.
download_secrets() {
Expand Down Expand Up @@ -96,5 +86,4 @@ revert() {
upload_secrets
}

check_not_empty TASK ENVIRONMENT
eval "$TASK"
56 changes: 56 additions & 0 deletions scripts/orphan-clusters/gke-destroyer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/bin/bash

set -euo pipefail

if [[ "$#" -lt "2" ]]; then
>&2 echo "Usage: gke-destroyer.sh <prefix> <workflow>"
exit 6
fi

PREFIX="${1}"
WORKFLOW_NAME="${2}"
CLUSTER_NAME="$(kubectl get workflow "${WORKFLOW_NAME}" -o yaml | yq '.metadata.labels["infra.stackrox.com/cluster-id"]')"

TIMESTAMP=$(date +%s)
RUNNER_NAME="${PREFIX}-${CLUSTER_NAME}-destroyer-${TIMESTAMP}"
AUTOMATION_FLAVORS_TAG=$(yq '.annotations.automationFlavorsVersion' chart/infra-server/Chart.yaml)

manifest=$(cat <<EOF
apiVersion: v1
kind: Pod
metadata:
name: ${RUNNER_NAME}
spec:
containers:
- name: destroy
image: quay.io/stackrox-io/ci:automation-flavors-gke-default-${AUTOMATION_FLAVORS_TAG}
imagePullPolicy: Always
command:
- /usr/bin/entrypoint
args:
- destroy
- --name=${CLUSTER_NAME}
- --gcp-project=acs-team-temp-dev
env:
- name: GOOGLE_CREDENTIALS
valueFrom:
secretKeyRef:
name: google-credentials
key: google-credentials.json
volumeMounts:
- mountPath: /tmp
name: credentials
volumes:
- name: credentials
secret:
defaultMode: 420
secretName: google-credentials
restartPolicy: Never
EOF
)

echo "${manifest}" | kubectl apply -f -

sleep 20

kubectl logs -f "${RUNNER_NAME}"

0 comments on commit 2b96af1

Please sign in to comment.