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

Add GOOGLE_INTERNAL_GSM_NAMESPACE and GOOGLE_INTERNAL_GSM_DEPLOYMENT to node metadata, #68

Closed
Closed
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
8 changes: 8 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ var (
gkePodName = flag.String("gke-pod-name-experimental", "", "GKE pod name to use, instead of reading it from $HOSTNAME or /etc/hostname file. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
gkeNamespace = flag.String("gke-namespace-experimental", "", "GKE namespace to use. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
gkeLocation = flag.String("gke-location-experimental", "", "the location (region/zone) of the GKE cluster, instead of retrieving it from the metadata server. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
gkeDeployment = flag.String("gke-deployment-experimental", "", "GKE deployment to use. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should we add more info to the usage text?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why "deployment"? What about bare pods, bare replica sets, and daemon sets? Are these not supported? Or is "deployment"? Or is this more abstract and not referring to the Kubernetes Deployment resource?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolved offline.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this behavior could be possible by passing in the k,v to --node-metadata

./td-grpc-bootstrap --node-metadata GOOGLE_INTERNAL_GSM_NAMESPACE=foo --node-metadata GOOGLE_INTERNAL_GSM_DEPLOYMENT=bar

it's worth mentioning that setting this flag will overwrite the value passed to --node-metadata

gceVM = flag.String("gce-vm-experimental", "", "GCE VM name to use, instead of reading it from the metadata server. This flag is EXPERIMENTAL and may be changed or removed in a later release.")
configMesh = flag.String("config-mesh", "", "Dictates which Mesh resource to use.")
generateMeshId = flag.Bool("generate-mesh-id", false, "When enabled, the CSM MeshID is generated. If config-mesh flag is specified, this flag would be ignored. Location and Cluster Name would be retrieved from the metadata server unless specified via gke-location and gke-cluster-name flags respectively.")
Expand Down Expand Up @@ -192,6 +193,13 @@ func main() {
os.Exit(1)
}

if *gkeNamespace != "" {
nodeMetadata["GOOGLE_INTERNAL_GSM_NAMESPACE"] = *gkeNamespace
}
if *gkeDeployment != "" {
nodeMetadata["GOOGLE_INTERNAL_GSM_DEPLOYMENT"] = *gkeDeployment
}

input := configInput{
xdsServerUri: *xdsServerUri,
gcpProjectNumber: *gcpProjectNumber,
Expand Down
19 changes: 13 additions & 6 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,17 @@ func TestGenerate(t *testing.T) {
{
desc: "Server feature for Trusted xds server",
input: configInput{
xdsServerUri: "example.com:443",
gcpProjectNumber: 123456789012345,
vpcNetworkName: "thedefault",
ip: "10.9.8.7",
zone: "uscentral-5",
metadataLabels: map[string]string{"k1": "v1", "k2": "v2"},
xdsServerUri: "example.com:443",
gcpProjectNumber: 123456789012345,
vpcNetworkName: "thedefault",
ip: "10.9.8.7",
zone: "uscentral-5",
metadataLabels: map[string]string{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functionality test for adding metadataLabels are already being tested. If you still would like to have another test that adds these exact labels, can we split them to another test?

"k1": "v1",
"k2": "v2",
"GOOGLE_INTERNAL_GSM_NAMESPACE": "test-ns",
"GOOGLE_INTERNAL_GSM_DEPLOYMENT": "test-deployment",
},
gitCommitHash: "7202b7c611ebd6d382b7b0240f50e9824200bffd",
isTrustedXdsServer: true,
},
Expand Down Expand Up @@ -231,6 +236,8 @@ func TestGenerate(t *testing.T) {
"id": "projects/123456789012345/networks/thedefault/nodes/52fdfc07-2182-454f-963f-5f0f9a621d72",
"cluster": "cluster",
"metadata": {
"GOOGLE_INTERNAL_GSM_DEPLOYMENT": "test-deployment",
"GOOGLE_INTERNAL_GSM_NAMESPACE": "test-ns",
"INSTANCE_IP": "10.9.8.7",
"TRAFFICDIRECTOR_GRPC_BOOTSTRAP_GENERATOR_SHA": "7202b7c611ebd6d382b7b0240f50e9824200bffd",
"k1": "v1",
Expand Down
Loading