@leverege/build-tools 2.26.1 → 2.26.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/helmup
CHANGED
|
@@ -59,7 +59,7 @@ CATNAMI
|
|
|
59
59
|
|
|
60
60
|
function bindWorkloadIdentity() {
|
|
61
61
|
SVC_ACCT=$1
|
|
62
|
-
NAMESPACE=$2
|
|
62
|
+
NAMESPACE=${2:-default}
|
|
63
63
|
SVC_ACCT_EMAIL="${SVC_ACCT}@${GCP_PROJECT_ID}.iam.gserviceaccount.com"
|
|
64
64
|
|
|
65
65
|
cat<<WORKLOAD_ID
|
|
@@ -78,12 +78,12 @@ WORKLOAD_ID
|
|
|
78
78
|
warnOnError $? "gcloud workload identity binding may have failed"
|
|
79
79
|
|
|
80
80
|
# Verify the Kubernetes SA and create it if necessary
|
|
81
|
-
printf "\nChecking for the $NAMESPACE
|
|
81
|
+
printf "\nChecking for the $NAMESPACE/$SVC_ACCT k8s SA\n"
|
|
82
82
|
kubectl get sa -n $NAMESPACE $SVC_ACCT
|
|
83
83
|
if [[ $? -eq 1 ]];
|
|
84
84
|
then
|
|
85
|
-
printf "Creating the k8s SA $NAMESPACE
|
|
86
|
-
kubectl create sa -n $NAMESPACE
|
|
85
|
+
printf "Creating the k8s $SVC_ACCT SA in $NAMESPACE\n"
|
|
86
|
+
kubectl create sa $SVC_ACCT -n $NAMESPACE
|
|
87
87
|
fi
|
|
88
88
|
|
|
89
89
|
printf "\nAnnotating the k8s SA $NAMESPACE/@$SVC_ACCT\n"
|
|
@@ -147,30 +147,40 @@ function errorIfMissingSecret() {
|
|
|
147
147
|
|
|
148
148
|
function installStackdriverExporterEnvironment() {
|
|
149
149
|
showInstalling "Stackdriver Exporter Service Account Binding"
|
|
150
|
-
createNamespaceIfNeeded monitoring
|
|
151
150
|
|
|
152
151
|
# Add necessary helm repositories - note that stable is deprecated
|
|
153
152
|
addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
|
|
154
153
|
|
|
155
|
-
local
|
|
154
|
+
local SDEXP_NS="monitoring"
|
|
155
|
+
local SDEXP_SA="stackdriver-exporter"
|
|
156
|
+
local SDEXP_EM="$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com"
|
|
157
|
+
|
|
158
|
+
createNamespaceIfNeeded $SDEXP_NS
|
|
159
|
+
|
|
160
|
+
# guarantee any previous remnants of the exporter are gone
|
|
161
|
+
printf "\n*** Removing the previous $SDEXP_SA installation...\n"
|
|
162
|
+
helm uninstall -n $SDEXP_NS $SDEXP_SA &> /dev/null
|
|
163
|
+
kubectl delete serviceaccounts -n $SDEXP_NS $SDEXP_SA &> /dev/null
|
|
164
|
+
gcloud --quiet iam service-accounts delete $SDEXP_EM &> /dev/null
|
|
156
165
|
|
|
157
166
|
# NOTE: The k8s SA != GCP SA - the former is created by the helm chart
|
|
158
167
|
# that installs the stackdriver-exporter, the latter is handled here in
|
|
159
168
|
# order to provide the proper IAM permissions to the exporter.
|
|
160
169
|
|
|
161
170
|
# Create GCP SA and bind policies
|
|
162
|
-
printf "\n*** Creating GCP SA with
|
|
171
|
+
printf "\n*** Creating GCP SA with $SDEXP_NS/viewer ***\n"
|
|
163
172
|
gcloud iam service-accounts create $SDEXP_SA \
|
|
164
173
|
--project "$GCP_PROJECT_ID" \
|
|
165
174
|
--display-name "Prometheus Stackdriver Exporter" &>/dev/null
|
|
166
175
|
warnOnError $? "the GCP SA $SDEXP_SA may already exist"
|
|
167
176
|
|
|
168
|
-
printf "\n*** Binding IAM role of
|
|
177
|
+
printf "\n*** Binding IAM role of $SDEXP_NS viewer to $SDEXP_SA in $GCP_PROJECT_ID\n"
|
|
169
178
|
gcloud projects add-iam-policy-binding "$GCP_PROJECT_ID" \
|
|
170
|
-
--role "roles
|
|
171
|
-
--member "serviceAccount:$
|
|
179
|
+
--role "roles/$SDEXP_NS.viewer" \
|
|
180
|
+
--member "serviceAccount:$SDEXP_EM" &>/dev/null
|
|
181
|
+
sleep 2 # give the IAM binding a chance to complete before moving on
|
|
172
182
|
|
|
173
|
-
bindWorkloadIdentity $SDEXP_SA
|
|
183
|
+
bindWorkloadIdentity $SDEXP_SA $SDEXP_NS
|
|
174
184
|
|
|
175
185
|
removeHelmRepo prometheus-community
|
|
176
186
|
}
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
+
#
|
|
2
|
+
# to force a reinstall of this service simply remove or rename this
|
|
3
|
+
# stackdriver-exporter subdirectory and rerun helmup stackdriver-exporter
|
|
4
|
+
#
|
|
1
5
|
stackdriver:
|
|
2
6
|
projectId: "OVH:<PROJECT_NAME>"
|
|
3
7
|
metrics:
|
|
4
|
-
typePrefixes:
|
|
8
|
+
typePrefixes: "pubsub.googleapis.com/subscription/oldest_unacked_message_age,pubsub.googleapis.com/subscription/num_undelivered_messages,pubsub.googleapis.com/subscription/pull_ack_request_count,pubsub.googleapis.com/subscription/streaming_pull_ack_request_count,pubsub.googleapis.com/topic/message_sizes,pubsub.googleapis.com/topic/send_request_count,firebasedatabase.googleapis.com/io/database_load,firebasedatabase.googleapis.com/network/sent_bytes_count,firebasedatabase.googleapis.com/network/active_connections"
|
|
5
9
|
|
|
6
10
|
annotations:
|
|
7
11
|
prometheus.io/port: "9255"
|
|
8
|
-
prometheus.io/scrape: "true"
|
|
12
|
+
prometheus.io/scrape: "true" # this is a string annotation - so quoted!
|
|
13
|
+
|
|
14
|
+
# NOTE to future selves - the exporter's helm chart does not have a clue
|
|
15
|
+
# regarding workload identity, which means the gcloud and k8s service
|
|
16
|
+
# accounts have to be managed outside of the chart by helmup. In order to get
|
|
17
|
+
# the linkages from the SA to the service we specify the SA name here, but
|
|
18
|
+
# disable the creation of the SA since it will have already have been created
|
|
19
|
+
# and bound by the helmup installStackdriverExporterEnvironment function.
|
|
20
|
+
#
|
|
21
|
+
serviceAccount:
|
|
22
|
+
create : false # this is a flag to helm - so unquoted ... da F?!
|
|
23
|
+
name: "stackdriver-exporter"
|