Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: configure prober in dev #1957

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/main/k8s/dev/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -497,3 +497,50 @@ cue_dump(
"//src/main/k8s:open_telemetry",
],
)

cue_library(
name = "measurement_system_prober_cue",
srcs = ["measurement_system_prober_gke.cue"],
deps = [
":config",
"//src/main/k8s:measurement_system_prober",
],
)

cue_dump(
name = "measurement_system_prober_gke",
srcs = ["measurement_system_prober_gke.cue"],
cue_tags = {
"mc_name": SIMULATOR_K8S_SETTINGS.mc_name,
"mc_api_key": SIMULATOR_K8S_SETTINGS.mc_api_key,
"container_registry": IMAGE_REPOSITORY_SETTINGS.container_registry,
"image_repo_prefix": IMAGE_REPOSITORY_SETTINGS.repository_prefix,
"image_tag": IMAGE_REPOSITORY_SETTINGS.image_tag,
"secret_name": SECRET_NAME,
"edp1_name": SIMULATOR_K8S_SETTINGS.edp1_name,
"edp2_name": SIMULATOR_K8S_SETTINGS.edp2_name,
},
tags = ["manual"],
deps = [
":measurement_system_prober_cue",
"//src/main/k8s:measurement_system_prober",
],
)

kustomization_dir(
name = "measurement_system_prober_secret",
srcs = ["measurement_system_prober_secret_kustomization.yaml"],
renames = {"measurement_system_prober_secret_kustomization.yaml": "kustomization.yaml"},
)

kustomization_dir(
name = "measurement_system_prober",
srcs = [
":measurement_system_prober_gke",
],
generate_kustomization = True,
tags = ["manual"],
deps = [
":measurement_system_prober_secret",
],
)
20 changes: 20 additions & 0 deletions src/main/k8s/dev/measurement_system_prober_gke.cue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package k8s

_secret_name: string @tag("secret_name")
_mc_resource_name: string @tag("mc_name")
_mc_api_key: string @tag("mc_api_key")
_edp1: string @tag("edp1_name")
_edp2: string @tag("edp2_name")

#KingdomPublicApiTarget: (#Target & {name: "v2alpha-public-api-server"}).target

objectSets: [ for objectSet in measurementSystemProber {objectSet}]

measurementSystemProber: #MeasurementSystemProber & {
_mcName: _mc_resource_name
_apiKey: _mc_api_key
_secretName: _secret_name
_verboseGrpcClientLogging: true
_edpResourceNames: [_edp1, _edp2]
_kingdomPublicApiTarget: #KingdomPublicApiTarget
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2024 The Cross-Media Measurement Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

secretGenerator:
- name: certs-and-configs
files:
- mc_cs_private.der
- mc_tls.pem
- mc_tls.key
- all_root_certs.pem
1 change: 0 additions & 1 deletion src/main/k8s/kingdom.cue
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,6 @@ import ("strings")
"pending-measurements-cancellation-app",
"exchanges-deletion-app",
"operational-metrics-app",
"measurement-system-prober-app",
]
_egresses: {
// Need to send external traffic to Spanner.
Expand Down
4 changes: 0 additions & 4 deletions src/main/k8s/local/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,6 @@ cue_dump(
"secret_name": SECRET_NAME,
"edp1_name": TEST_K8S_SETTINGS.edp1_name,
"edp2_name": TEST_K8S_SETTINGS.edp2_name,
"edp3_name": TEST_K8S_SETTINGS.edp3_name,
"edp4_name": TEST_K8S_SETTINGS.edp4_name,
"edp5_name": TEST_K8S_SETTINGS.edp5_name,
"edp6_name": TEST_K8S_SETTINGS.edp6_name,
},
tags = ["manual"],
deps = [
Expand Down
12 changes: 2 additions & 10 deletions src/main/k8s/local/measurement_system_prober.cue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ _mc_resource_name: string @tag("mc_name")
_mc_api_key: string @tag("mc_api_key")
_edp1: string @tag("edp1_name")
_edp2: string @tag("edp2_name")
_edp3: string @tag("edp3_name")
_edp4: string @tag("edp4_name")
_edp5: string @tag("edp5_name")
_edp6: string @tag("edp6_name")
_edp_resource_names: [_edp1, _edp2]

#KingdomPublicApiTarget: (#Target & {name: "v2alpha-public-api-server"}).target

Expand All @@ -19,11 +16,6 @@ measurementSystemProber: #MeasurementSystemProber & {
_apiKey: _mc_api_key
_secretName: _secret_name
_verboseGrpcClientLogging: true
_edp1Name: _edp1
_edp2Name: _edp2
_edp3Name: _edp3
_edp4Name: _edp4
_edp5Name: _edp5
_edp6Name: _edp6
_edpResourceNames: _edp_resource_names
_kingdomPublicApiTarget: #KingdomPublicApiTarget
}
33 changes: 19 additions & 14 deletions src/main/k8s/measurement_system_prober.cue
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@ import ("strings")
_mcName: string
_privateKeyDerFile: string
_apiKey: string
_edp1Name: string
_edp2Name: string
_edp3Name: string
_edp4Name: string
_edp5Name: string
_edp6Name: string
_edpResourceNames: [_edp1Name, _edp2Name, _edp3Name, _edp4Name, _edp5Name, _edp6Name]
_edpResourceNames: [...string]
_verboseGrpcClientLogging: bool | *false
_kingdomPublicApiTarget: string
_secretName: string
let SecretName = _secretName

_privateKeyDerFileFlag: "--private-key-der-file=/var/run/secrets/files/mc_cs_private.der"
_tlsCertFileFlag: "--tls-cert-file=/var/run/secrets/files/mc_tls.pem"
Expand Down Expand Up @@ -58,7 +53,7 @@ import ("strings")

cronJobs: [Name=_]: #CronJob & {
_name: strings.TrimSuffix(Name, "-cronjob")
_secretName: _secretName
_secretName: SecretName
_system: "kingdom"
_container: {
image: _images[_name]
Expand All @@ -78,14 +73,24 @@ import ("strings")
_kingdomPublicApiCertHostFlag,
"--measurement-lookback-duration=1d",
"--duration-between-measurements=1d",
"--data-provider=\(_edp1Name)",
"--data-provider=\(_edp2Name)",
"--data-provider=\(_edp3Name)",
"--data-provider=\(_edp4Name)",
"--data-provider=\(_edp5Name)",
"--data-provider=\(_edp6Name)",
for edp in _edpResourceNames {
"--data-provider=\(edp)"
},
]
spec: schedule: "* * * * *"
}
}

networkPolicies: [Name=_]: #NetworkPolicy & {
_name: Name
}

networkPolicies: {
"measurement-system-prober": {
_app_label: "measurement-system-prober-app"
_destinationMatchLabels: [
"v2alpha-public-api-server-app",
]
}
}
}