Skip to content

Commit

Permalink
Label all spinnaker services and deployments.
Browse files Browse the repository at this point in the history
When new service components (e.g Fiat) were enabled they were not
being labeled by `deploy_application_manifest.sh`. This commit
resolves the issue by additionally querying the set of deployments and
services in the spinnaker namespace and then applying the
`app.kubernetes.io/name` with the Spinnaker instance name.

Fixes #248
  • Loading branch information
stewartmiles committed Mar 21, 2022
1 parent 26455a6 commit fcf5140
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions scripts/manage/deploy_application_manifest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,28 @@ cat $PARENT_DIR/spinnaker-for-gcp/templates/spinnaker_application_manifest_top.y
| envsubst | kubectl apply -f -

bold "Labeling resources as components of application $DEPLOYMENT_NAME..."
kubectl label service --overwrite -n spinnaker spin-clouddriver app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label service --overwrite -n spinnaker spin-deck app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label service --overwrite -n spinnaker spin-echo app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label service --overwrite -n spinnaker spin-front50 app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label service --overwrite -n spinnaker spin-gate app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label service --overwrite -n spinnaker spin-igor app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label service --overwrite -n spinnaker spin-kayenta app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label service --overwrite -n spinnaker spin-orca app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label service --overwrite -n spinnaker spin-rosco app.kubernetes.io/name=$DEPLOYMENT_NAME -o name

kubectl label deployment --overwrite -n spinnaker spin-clouddriver app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label deployment --overwrite -n spinnaker spin-deck app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label deployment --overwrite -n spinnaker spin-echo app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label deployment --overwrite -n spinnaker spin-front50 app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label deployment --overwrite -n spinnaker spin-gate app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label deployment --overwrite -n spinnaker spin-igor app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label deployment --overwrite -n spinnaker spin-kayenta app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label deployment --overwrite -n spinnaker spin-orca app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
kubectl label deployment --overwrite -n spinnaker spin-rosco app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
# List of expected Spinnaker components for a default deployment.
declare -r DEFAULT_COMPONENTS="\
spin-clouddriver
spin-deck
spin-echo
spin-front50
spin-gate
spin-igor
spin-kayenta
spin-orca
spin-rosco"

for object_type in services deployments; do
default_objects=$(echo "${DEFAULT_COMPONENTS}" | sed "s@^@${object_type}/&@")
for name in $(
(
echo "${default_objects}";
# Fold-in optional components if they've been added to the cluster.
kubectl get "${object_type}" -n spinnaker -o name | \
sed 's@^deployment[^/]*/@deployments/@;s@^service[^/]*/@services/@'
) | sort -u ); do
kubectl label --overwrite -n spinnaker "${name}" \
app.kubernetes.io/name=$DEPLOYMENT_NAME -o name
done
done

0 comments on commit fcf5140

Please sign in to comment.