Tag: gke

在使用GCP的数据存储区时,如何区分代码是在模拟器中还是在GKE中运行

按照https://cloud.google.com/datastore/docs/tools/datastore-emulator中的说明,我不确定是否遗漏了任何内容 除非我使用DataStoreClient显式创建数据存储区,否则我无法连接到本地模拟器。 DatastoreDb db = DatastoreDb.Create(projectId, string.Empty, new DatastoreClientImpl( new Datastore.DatastoreClient( new Channel(“localhost”, 8081, ChannelCredentials.Insecure)), new DatastoreSettings())); 而不仅仅是DatastoreDb.Create(projectId); 如果我们在GKE中进行生产,我们需要连接到实际的数据存储而不是模拟器,我们如何区分具有相同代码库的两个版本。 有没有办法检查代码是否正在运行GKE,或者这是应该通过环境变量来完成的,以获得最佳结果。