@leverege/build-tools 2.26.2 → 2.26.4
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
|
|
82
|
-
kubectl get sa -n $NAMESPACE $SVC_ACCT
|
|
81
|
+
printf "\nChecking for the $NAMESPACE/$SVC_ACCT k8s SA\n"
|
|
82
|
+
kubectl get sa -n $NAMESPACE $SVC_ACCT &>/dev/null
|
|
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"
|
|
@@ -119,7 +119,26 @@ function bootstrapLocalSetup() {
|
|
|
119
119
|
SYSTEM_HUP="$SYSTEM_FILES/$SERVICE.hup"
|
|
120
120
|
[ ! -f "$SYSTEM_HUP" ] && errorExit "Missing $SERVICE helmup script => $(color y $SYSTEM_HUP)"
|
|
121
121
|
|
|
122
|
-
[ ! -d "$SERVICE" ]
|
|
122
|
+
if [ ! -d "$SERVICE" ];
|
|
123
|
+
then
|
|
124
|
+
mkdir $SERVICE
|
|
125
|
+
else
|
|
126
|
+
# If the service dir already exists but the helmup.plugin file is missing
|
|
127
|
+
# then this is most likely a legacy setup - for example, an older setup for
|
|
128
|
+
# elasticsearch that only had an es-values.yaml file. Note that we cannot
|
|
129
|
+
# get to this logic if the helmup.plugin file exists so no need to check
|
|
130
|
+
# for it again - just error.
|
|
131
|
+
cat<<MISSING_HELMUP_PLUGIN
|
|
132
|
+
|
|
133
|
+
$RED_ERROR Legacy setup detected for service `color y "$SERVICE"`
|
|
134
|
+
|
|
135
|
+
This looks like a legacy setup of the $SERVICE service. In order to
|
|
136
|
+
proceed, the existing $SERVICE subdirectory should be moved out of
|
|
137
|
+
way before attempting to rerun helmup for this service.
|
|
138
|
+
|
|
139
|
+
MISSING_HELMUP_PLUGIN
|
|
140
|
+
errorExit "Installaion of `color y $SERVICE` failed - exiting"
|
|
141
|
+
fi
|
|
123
142
|
|
|
124
143
|
if [ "$2" == "set-values-local" ];
|
|
125
144
|
then
|
|
@@ -147,30 +166,40 @@ function errorIfMissingSecret() {
|
|
|
147
166
|
|
|
148
167
|
function installStackdriverExporterEnvironment() {
|
|
149
168
|
showInstalling "Stackdriver Exporter Service Account Binding"
|
|
150
|
-
createNamespaceIfNeeded monitoring
|
|
151
169
|
|
|
152
170
|
# Add necessary helm repositories - note that stable is deprecated
|
|
153
171
|
addHelmRepo prometheus-community https://prometheus-community.github.io/helm-charts
|
|
154
172
|
|
|
155
|
-
local
|
|
173
|
+
local SDEXP_NS="monitoring"
|
|
174
|
+
local SDEXP_SA="stackdriver-exporter"
|
|
175
|
+
local SDEXP_EM="$SDEXP_SA@$GCP_PROJECT_ID.iam.gserviceaccount.com"
|
|
176
|
+
|
|
177
|
+
createNamespaceIfNeeded $SDEXP_NS
|
|
178
|
+
|
|
179
|
+
# guarantee any previous remnants of the exporter are gone
|
|
180
|
+
printf "\n*** Removing the previous $SDEXP_SA installation...\n"
|
|
181
|
+
helm uninstall -n $SDEXP_NS $SDEXP_SA &> /dev/null
|
|
182
|
+
kubectl delete serviceaccounts -n $SDEXP_NS $SDEXP_SA &> /dev/null
|
|
183
|
+
gcloud --quiet iam service-accounts delete $SDEXP_EM &> /dev/null
|
|
156
184
|
|
|
157
185
|
# NOTE: The k8s SA != GCP SA - the former is created by the helm chart
|
|
158
186
|
# that installs the stackdriver-exporter, the latter is handled here in
|
|
159
187
|
# order to provide the proper IAM permissions to the exporter.
|
|
160
188
|
|
|
161
189
|
# Create GCP SA and bind policies
|
|
162
|
-
printf "\n*** Creating GCP SA with
|
|
190
|
+
printf "\n*** Creating GCP SA with $SDEXP_NS/viewer ***\n"
|
|
163
191
|
gcloud iam service-accounts create $SDEXP_SA \
|
|
164
192
|
--project "$GCP_PROJECT_ID" \
|
|
165
193
|
--display-name "Prometheus Stackdriver Exporter" &>/dev/null
|
|
166
194
|
warnOnError $? "the GCP SA $SDEXP_SA may already exist"
|
|
167
195
|
|
|
168
|
-
printf "\n*** Binding IAM role of
|
|
196
|
+
printf "\n*** Binding IAM role of $SDEXP_NS viewer to $SDEXP_SA in $GCP_PROJECT_ID\n"
|
|
169
197
|
gcloud projects add-iam-policy-binding "$GCP_PROJECT_ID" \
|
|
170
|
-
--role "roles
|
|
171
|
-
--member "serviceAccount:$
|
|
198
|
+
--role "roles/$SDEXP_NS.viewer" \
|
|
199
|
+
--member "serviceAccount:$SDEXP_EM" &>/dev/null
|
|
200
|
+
sleep 2 # give the IAM binding a chance to complete before moving on
|
|
172
201
|
|
|
173
|
-
bindWorkloadIdentity $SDEXP_SA
|
|
202
|
+
bindWorkloadIdentity $SDEXP_SA $SDEXP_NS
|
|
174
203
|
|
|
175
204
|
removeHelmRepo prometheus-community
|
|
176
205
|
}
|
|
@@ -189,7 +218,7 @@ function installMonitoringEnvironment() {
|
|
|
189
218
|
## Installing ES exporter
|
|
190
219
|
helm upgrade --install elasticsearch-exporter prometheus-community/prometheus-elasticsearch-exporter \
|
|
191
220
|
--namespace monitoring \
|
|
192
|
-
--version
|
|
221
|
+
--version 5 \
|
|
193
222
|
-f - <<ELASTIC_EXPORTER_CHART_MOD
|
|
194
223
|
service:
|
|
195
224
|
annotations:
|
|
@@ -1,12 +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!
|
|
9
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
|
+
#
|
|
10
21
|
serviceAccount:
|
|
11
|
-
create : false
|
|
22
|
+
create : false # this is a flag to helm - so unquoted ... da F?!
|
|
12
23
|
name: "stackdriver-exporter"
|