Skip to content

Commit 8cf050b

Browse files
authored
Fix src ranges (#371)
* only delete the deployment on ip range update * fix the allowed_ips update
1 parent f357e51 commit 8cf050b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

dist/bin/kctf-cluster

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ function kctf_cluster_ip_ranges {
393393
set_cloud_armor_policy "${RANGES}" || return
394394

395395
# stop the operator
396-
"${KCTF_BIN}/kubectl" delete -f "${KCTF_CTF_DIR}/kctf/resources/operator.yaml" || return
396+
"${KCTF_BIN}/yq" eval "select(.kind == \"Deployment\")" "${KCTF_CTF_DIR}/kctf/resources/operator.yaml" \
397+
| "${KCTF_BIN}/kubectl" delete -f - || return
397398

398399
start_operator_gce || return
399400
}
@@ -407,8 +408,8 @@ function start_operator_gce {
407408
SUFFIX=$(echo "${PROJECT}-${CLUSTER_NAME}-${ZONE}" | sha1sum)
408409
POLICY_NAME="kctf-policy-${SUFFIX:0:16}"
409410
# restart the operator with the new range
410-
"${KCTF_BIN}/yq" eval "(((.|select(has(\"spec\"))).spec|select(has(\"template\"))).template.spec.containers[0].env[] | select(.name == \"ALLOWED_IPS\")).value = \"${RANGES}\"" "${KCTF_CTF_DIR}/kctf/resources/operator.yaml" \
411-
| "${KCTF_BIN}/yq" eval "(((.|select(has(\"spec\"))).spec|select(has(\"template\"))).template.spec.containers[0].env[] | select(.name == \"SECURITY_POLICY\")).value = \"${POLICY_NAME}\"" - \
411+
"${KCTF_BIN}/yq" eval "(select(.kind == \"Deployment\").spec.template.spec.containers[] | select(.name == \"manager\").env[] | select(.name == \"ALLOWED_IPS\").value) |= \"${RANGES}\"" "${KCTF_CTF_DIR}/kctf/resources/operator.yaml" \
412+
| "${KCTF_BIN}/yq" eval "(select(.kind == \"Deployment\").spec.template.spec.containers[] | select(.name == \"manager\").env[] | select(.name == \"SECURITY_POLICY\").value) |= \"${POLICY_NAME}\"" - \
412413
| "${KCTF_BIN}/kubectl" apply -f - || return
413414
fi
414415
}

0 commit comments

Comments
 (0)