Backing Australia’s forward thinkers

Every day, Australian nonprofits and social enterprises are finding new ways to address some of our most challenging social problems - from education and economic opportunity to inclusion.

We know that technology can be part of the solution. Big ideas, such as using machine learning to help health professionals detect cancer, highlight the transformative potential of technology. Many Australian nonprofits already use technology to tackle challenges and some have big ideas that need an extra boost, that’s why we’re launching the 2018 Google.org Impact Challenge.

Through the Google.org Impact Challenge, we’re backing Australia’s forward thinkers. This year, nonprofits and social enterprises can apply for a share of $5.5 million to support projects that use technology for good. Grants of up to $1 million will be available to the winners. We’re excited to announce that applications open today.



This is the third Google.org Impact Challenge in Australia. Previous winners include supporting Fred Hollows’ low-cost mobile camera to detect and prevent blindness caused by diabetes, investing in Infoxchange’s web app called Ask Izzy to connect people experiencing homelessness with social services, and supporting the Great Barrier Reef Foundation to develop autonomous underwater vehicles to help protect the reef.

Australia has a long history of innovating for impact, whether it’s the bionic ear or WiFi. Through the Google.org Impact Challenge we want to champion our emerging innovators.

Ten finalists will be announced in October, and then we want to hear from you! Australians will be invited to vote for your favourite idea - which will take out the $1 million People’s Choice prize.

If you know a nonprofit or social enterprise with a big idea to make a difference, encourage them to apply before 6 July 2018. Find out more at: g.co/australiachallenge and get behind Australia’s forward thinkers!

The High Five: Sip sip, hooray!

A High Five on the 25th day of the 5th month feels like it should mean something, but it doesn’t. Much like most of the internet. What does mean something is this beautiful long weekend we’ve got ahead of us, so, without further ado: I bring you this week’s top five search trends, with data from the Google News Lab.


Wine not?

Today is National Wine Day, so watch for your dinner companions to have too many sips of “frose” and turn in early. The denizens of DC, Kansas, and New York were the most keen to know when National Wine Day was taking place. When comparing "red," "rosé" and "white" wine over the last 30 days, red wine is searched nearly twice as much as white, with average interest at 68 percent compared to peak spikes the weekend of May 12-13. Fittingly, interest in rosé is sitting pretty, right in between.

Marking Memorial Day

Red, white, and blue too: This Monday is Memorial Day, so people across the country are looking up tips and tricks for their patriotic celebrations. Top three questions this week on Memorial day were 1) “What was Memorial Day originally called?” 2) “Is today Memorial Day?” And 3) ”When did Memorial Day become a holiday?” Number 2 is my favorite.


Voted off the tie-land

The tribe has spoken … A tribe of reality TV contest candidates and also lots of people who still watch this amazingly long-running show. (Oh how it SURVIVES!) This week’s “Survivor” finale came down to a tie for the first time in the show’s 36-season history and long-standing show fanatics were deep in their feelings about it. Queries like “Who won Survivor 2018 Ghost Island?” and “Survivor fan favorite 2018” spiked over 2,500 percent (!), proving that there are whole worlds out there I know nothing about.


Drawing sides on straws

It’s 2018, so naturally people are taking sides on straws. McDonald’s is under pressure to scrap drinking straws for environmental reasons. Critics claim straws suck for the environment; they’re also super fun to use to drink things. Search interest in “McDonald’s straw” spiked by 230 percent at one point, surpassing search interest in “McDonald’s McFlurry.” While the top two most searched questions this week relating to McDonalds were about straws, the third one, comfortingly, was: “When does McDonald’s breakfast end?”


A verdict in 280 characters

A Texas police officer, a New York comedy writer and a Nashville surgeon walk into a courtroom … And the three are among a group that brought a lawsuit against President Trump for blocking them on Twitter. A federal judge ruled Wednesday that Trump’s blocking users on Twitter violates the First Amendment. Searchers turned to Google to ask: “Who are the plaintiffs in the Trump Twitter lawsuit?” and “Who has Trump blocked on Twitter?”

We are many and one: Googlers mark AAPI Heritage Month

Tiffany’s mother was born in Hong Kong. Her father was born in Vietnam. She is proud to be Chinese, Asian, and American. 

Aerica’s mother is Japanese from Kyoto, Japan and her father is Black, from College Station, TX. She identifies as Black and Japanese. 

Together, we are the chairs of the Asian Google Network (AGN), whose mission is to support the diverse and multicultural Asian community at Google and beyond. Founded in 2007, AGN is open to all Googlers and provides an annual mentorship program, opportunities for civic and community engagement; leadership development; and curriculum to advance racial justice for all.

We celebrate Asian American Pacific Islander (AAPI) Heritage Month every year in service to that mission. And for the 40th anniversary of AAPI Heritage Month, it was important to us to convey the diversity of the Asian experience in America. For example, Asians at Google trace their roots to more than 20 countries, are multiracial, multiethnic, and speak dozens of languages. And when Asian ethnicities are disaggregated, the data shows that there are wide chasms in access to education, income, and representation. That means that issues that impact AAPIs are broad as well.

As part of this year’s AAPI celebrations, we created an internal curriculum for Googlers on Asian narratives called “We Are Many and One: Gathering Asian Narratives,” where participants share stories and find both common themes and differences within the Asian American Pacific Islander community at Google. Across the country, AGN chapters also put on events for their local communities, such as the exhibit organized by AGN Ann Arbor, which uses timelines, Supreme Court cases, poetry, and the stories of local Googlers to tell the history of Angel Island, the entry point for many Asian immigrants coming to the United States.

Angel Island Exhibit.jpg

AGN Ann Arbor members observing the Angel Island Exhibit

To recognize the AAPI community outside of Google, we partnered with Google Expeditions to feature tours of “Hokule'a's Worldwide Voyage” and “Kamehameha: Unification of the Hawaiian Islands.” YouTube created a playlist of AAPI artists. Google Assistant embedded 10 new AAPI facts activated by the question, “Hey Google, what’s up?” And just today, the Doodle team created a Doodle celebrating Chinese-American cinematographer James Wong Howe.

Doodle_-James-Wong-Howe.jpg

In the spirit of celebrating our diverse community, we also spoke with several members of AGN to hear about why they participate in AGN, what this means to them, and who inspires them.

Why does AGN matter to you?

agn_joshli.jpg

Josh Li, Founder of AGN

AGN provides a safe space where Googlers can share more about their own backgrounds, cultures, challenges they face, and help each other excel at Google and outside of Google.

agn_edwarddoan.jpg

Edward Doan, AGN Chapter Lead, Austin

As an American-born child of Vietnamese immigrants, I have the "neither-here-nor-there" feeling of straddling two cultures. I have learned to embrace this state, and it's wonderful to meet fellow Googlers who share the same feelings!


Tell us about your heritage. What makes you proud to be who you are?

agn_ashishsathe.jpg

Ashish Sathe, AGN Chapter Lead, Ann Arbor

I still remain connected with my family's roots in India and make it a point to visit every year. I’m proud that India is a country of many different cultures and people that came together to form an identity. From Bollywood movies and music to colorful curries, elements of Indian culture are becoming popular across the world, and I am proud to share this with people in America and around the world.

agn_lynmahinam.jpg

Lyn Mahina'okalani Mehe'ula, AGN Member

I am Native Hawaiian & Japanese, and I am incredibly proud to belong to an indigenous American culture. My father descends from Chief Kahekili, who was the last King of Mau'i until the Hawaiian Islands were unified in 1810. My mother's side brings in Japanese, as her grandparents migrated to Mau'i over 100 years ago for job opportunities following the Islands' agricultural boom.


Who in the AAPI community inspires you?

agn_amieninh.jpg

Amie Ninh, AGN Race Affairs Lead

I have a lot of heroes in the AAPI community—Yuri Kochiyama, Grace Lee Boggs, Helen Zia. They are activists who strived to build coalitions with other communities of color and also give visibility and voice to the issues impacting the AAPI community.

We hope you’ll join us this AAPI History Month in learning more about the AAPI community and working toward a more just and inclusive world. 

#teampixel rolls out the red carpet this week

You might be inspired to pour yourself a glass of merlot or nibble on a bowl of berries as you scroll through the crimson colors captured by #teampixel this week. 

Next time you shoot with your Pixel 2, see what rich pops of color your camera can bring to life. 

Don’t forget to tag your Pixel photos with #teampixel and you might see yourself featured on @google and The Keyword next!

All the (Android) Things at Google I/O

Melissa Daniels, Program Manager for Android Things

Android Things enables you to build and maintain IoT devices at scale. We recently released Android Things 1.0 with long-term support for production devices, so you can easily take an IoT device from prototype to commercial product.

We packed Google I/O this year with Android Things content to inspire and empower the developer community, from talks and codelabs to interactive demos and a scavenger hunt. Here's a closer look at the fun stuff we had on display that you won't see on the shelves of retail stores.

Demos

We introduced a handful of new interactive Android Things demos across I/O, showcasing the AI and ML capabilities of the platform, so if you didn't get an opportunity to attend this year, here's a few of our favorites-- perfect for exploring from wherever you are in the world!

Smart Flowers: Flos Mobilis

What do you get when you combine machine learning, Android Things and robotics? Flos Mobilis, a continuum robot where each flower is backed by an i.MX7D development board and a camera to run an embedded neural net model that controls the motion of the flower. This is all done offline with no data stored or transmitted.

Smart Flowers: Flos Affectus

What if a robot could respond to the way you feel? Flos Affectus is a cluster of robotic flowers that "bloom" and "un-bloom" depending on the expression detected on the user's face. The 4 broad expressions Flos Affectus is trained to detect are: happy, sad, angry, surprised. Using a camera embedded in the head of the alpha flower, the flower cluster is able to detect the user's face and infer the facial emotion. The flower cluster runs offline with no data stored or transmitted and demonstrates movement capabilities and on-device machine learning models.

Rosie the Android

Initially designed by a team of Google engineers for the annual Grace Hopper conference, Rosie the Android is a 5 foot selfie-taking Android, complete with machine-learning capabilities. Inspired by Rosie the Riveter, she's a fully controllable robot that can take photos, respond to commands, wheel around and interact with those around her.

Did you take a selfie with Rosie at I/O? Redeem your unique access code at g.co/rosie

Smart Projector

Smart Projector is built on Lantern, an Android Things project exploring the relationship between surfaces and content — augmenting real-world objects and environments with glanceable, meaningful data. It leverages the Google Experiments project known as Quick Draw, using the world's largest doodling data set that has been shared publicly to help with machine learning research.

To learn more about Lantern or to start building your own, start here.

3D Printer

This modified Printrbot Smalls 3D Printer uses a real-time subsystem that showcases the flexibility of Android Things-- a microcontroller does the low-latency motor control, while Android Things handles OpenGL rendering. By keeping most of the logic on a high-level platform like Android you make development and debugging much easier, thanks to Android's great tooling.

The future of 3D printing? Making real-time control as easy and portable as the rest of Android Things.

Codelabs

Phew! That was just the tip of the demo iceberg. With so many demos and so many ways to use Android Things, it's easy to start imagining all the things you can build! At I/O, we helped a lot of developers get started building their first Android Things device using the Android Things Starter Kit. We're making these codelabs available, so you can get to them whenever you need, or build your own.

Videos

Missed the I/O talks? Catch the recordings of each Android Things talk, so you can start, pause, and rewind at your own leisure. Or, just lean back and watch them all.

What's new in Android Things

Build effective OEM-level apps on Android Things

Build real consumer devices with Android Things

Electronic design for Android Things System on Modules

Women Techmakers panel: experiences developing on Android Things

Product design: how to build better products with Android Things

Device provisioning and authentication with Android Things

Update production devices in the field with the Android Things Console

Start building!

On top of all the resources we just mentioned, we have a corpus of information on our developer documentation, and our new community website where you can see more inspiring projects and even submit your own. So, what are you waiting for? Pick up an Android Things Starter Kit and start building something today!

Chrome Beta for Android Update

Ladies and gentlemen, behold!  Chrome Beta 67 (67.0.3396.59) for Android has been released and is available in Google Play.  A partial list of the changes in this build is available in the Git log. Details on new features is available on the Chromium blog, and developers should check out our updates related to the web platform here.

If you find a new issue, please let us know by filing a bug. More information about Chrome for Android is available on the Chrome site.

Estelle Yomba
Google Chrome

Stackdriver brings powerful alerting capabilities to the condition editor UI



If you use Stackdriver, you probably rely on our alerting stack to be informed when your applications are misbehaving or aren’t performing as expected. We know how important it is to receive notifications at the right time as well as in the right situation. Imprecisely specifying what situation you want to be alerted on can lead to too many alerts (false positives) or too few (false negatives). When defining a Stackdriver alerting policy, it’s imperative that conditions be made as specific as possible, which is part of the reason that we introduced the ability to manage alerting policies in the Stackdriver Monitoring API last month. This, for example, enables users to create alerting conditions for resources filtered by certain metadata so that they can assign different conditions to parts of their applications that use similar resources but perform different functions.

But what about users who want to specify similar filters and aggregations using the Stackdriver UI? How can you get a more precise way to define the behavior that a metric must exhibit for the condition to be met (for example, alerting on certain resources filtered by metadata), as well as a more visual way of finding the right metrics to alert on for your applications?

We’ve got you covered. We are excited to announce the beta version of our new alerting condition configuration UI. In addition to allowing you to define alerting conditions more precisely, this new UI provides an easier, more visual way to find the metrics to alert on. The new UI lets you use the same metrics selector as used in Stackdriver’s Metrics Explorer to define a broader set of conditions. Starting today, you can use that metrics selector to create and edit threshold conditions for alerting policies. The same UI that you use to select metrics for charts can now be used for defining alerting policy conditions. It’s a powerful and more complete method for identifying your time series and specific aggregations. You’ll be able to express more targeted, actionable alerts with fewer false alerts.

We’ve already seen some great use cases for this functionality. Here are some ways in which our users have used this UI during early testing:

1. Alerting on aggregations of custom metrics and logs-based metrics
The ability to alert on aggregations of custom metrics or logs-based metrics is a common request from our users. This was recently made possible with the introduction of support for alerting policy management in the Stackdriver Monitoring v3 API. However, until this beta launch, there was no visual equivalent. With the introduction of this new UI, you can now visually explore metrics and define their alerting conditions before committing to an alerting policy. This adds a useful visual representation so you’ll have choices when setting up alert policies.

For example, below is a screen recording that shows how to aggregate a sum across a custom metrics grouped by pod:

2. Filter metadata to alert on specific Kubernetes resources
With the recent introduction of Stackdriver Kubernetes Monitoring, you have more out-of-the-box observability into your Kubernetes clusters. Now, with the addition of this new threshold condition UI, you can set up alerts on specific resources defined by metadata fields, instead of having to include the entire cluster.

For example, below is a screen recording showing how to alert when Kubernetes resources with a specific service name (customers-service) cross a certain aggregated threshold of the bytes transmitted. Using the metrics selector, you can configure the specific filters, grouping and aggregations that you’re interested in:

3. Edit metric threshold conditions that were created via the API
Many Stackdriver users utilize both the API and the alerting UI to create and edit alerting conditions. With this release, you can edit directly in the new UI many conditions that were previously created using the API.

Getting started with the new Stackdriver condition editor UI
To use the new UI, you must first opt in. When adding a policy condition, go to the Select condition type page. At the top of this page is an invitation to try a new variant of the UI:

Note that the new condition editor does not support process-health and uptime-check conditions, which continue to use the existing UI. The new UI supports all other condition types.

If you prefer to go back to the current UI, you can do so at any time by opting out. We’re looking forward to hearing more from users about what you’re accomplishing with the new UI.

To learn more, check out some specifics here on using the alerting UI.

Please send us feedback either via the feedback widget (click on your avatar -> Send Feedback), or by emailing us.

Related content:
New ways to manage and automate your Stackdriver alerting policies
Extracting value from your logs with Stackdriver logs-based metrics
Announcing Stackdriver Kubernetes Monitoring: Comprehensive Kubernetes observability from the start

Stackdriver brings powerful alerting capabilities to the condition editor UI



If you use Stackdriver, you probably rely on our alerting stack to be informed when your applications are misbehaving or aren’t performing as expected. We know how important it is to receive notifications at the right time as well as in the right situation. Imprecisely specifying what situation you want to be alerted on can lead to too many alerts (false positives) or too few (false negatives). When defining a Stackdriver alerting policy, it’s imperative that conditions be made as specific as possible, which is part of the reason that we introduced the ability to manage alerting policies in the Stackdriver Monitoring API last month. This, for example, enables users to create alerting conditions for resources filtered by certain metadata so that they can assign different conditions to parts of their applications that use similar resources but perform different functions.

But what about users who want to specify similar filters and aggregations using the Stackdriver UI? How can you get a more precise way to define the behavior that a metric must exhibit for the condition to be met (for example, alerting on certain resources filtered by metadata), as well as a more visual way of finding the right metrics to alert on for your applications?

We’ve got you covered. We are excited to announce the beta version of our new alerting condition configuration UI. In addition to allowing you to define alerting conditions more precisely, this new UI provides an easier, more visual way to find the metrics to alert on. The new UI lets you use the same metrics selector as used in Stackdriver’s Metrics Explorer to define a broader set of conditions. Starting today, you can use that metrics selector to create and edit threshold conditions for alerting policies. The same UI that you use to select metrics for charts can now be used for defining alerting policy conditions. It’s a powerful and more complete method for identifying your time series and specific aggregations. You’ll be able to express more targeted, actionable alerts with fewer false alerts.

We’ve already seen some great use cases for this functionality. Here are some ways in which our users have used this UI during early testing:

1. Alerting on aggregations of custom metrics and logs-based metrics
The ability to alert on aggregations of custom metrics or logs-based metrics is a common request from our users. This was recently made possible with the introduction of support for alerting policy management in the Stackdriver Monitoring v3 API. However, until this beta launch, there was no visual equivalent. With the introduction of this new UI, you can now visually explore metrics and define their alerting conditions before committing to an alerting policy. This adds a useful visual representation so you’ll have choices when setting up alert policies.

For example, below is a screen recording that shows how to aggregate a sum across a custom metrics grouped by pod:

2. Filter metadata to alert on specific Kubernetes resources
With the recent introduction of Stackdriver Kubernetes Monitoring, you have more out-of-the-box observability into your Kubernetes clusters. Now, with the addition of this new threshold condition UI, you can set up alerts on specific resources defined by metadata fields, instead of having to include the entire cluster.

For example, below is a screen recording showing how to alert when Kubernetes resources with a specific service name (customers-service) cross a certain aggregated threshold of the bytes transmitted. Using the metrics selector, you can configure the specific filters, grouping and aggregations that you’re interested in:

3. Edit metric threshold conditions that were created via the API
Many Stackdriver users utilize both the API and the alerting UI to create and edit alerting conditions. With this release, you can edit directly in the new UI many conditions that were previously created using the API.

Getting started with the new Stackdriver condition editor UI
To use the new UI, you must first opt in. When adding a policy condition, go to the Select condition type page. At the top of this page is an invitation to try a new variant of the UI:

Note that the new condition editor does not support process-health and uptime-check conditions, which continue to use the existing UI. The new UI supports all other condition types.

If you prefer to go back to the current UI, you can do so at any time by opting out. We’re looking forward to hearing more from users about what you’re accomplishing with the new UI.

To learn more, check out some specifics here on using the alerting UI.

Please send us feedback either via the feedback widget (click on your avatar -> Send Feedback), or by emailing us.

Related content:
New ways to manage and automate your Stackdriver alerting policies
Extracting value from your logs with Stackdriver logs-based metrics
Announcing Stackdriver Kubernetes Monitoring: Comprehensive Kubernetes observability from the start

Changes to embedded content on classic Google Sites

We're upgrading how HTML boxes work on classic Sites. This will improve performance and security, but it may also change the look and feel of some embedded elements. Site editors may want to make some simple adjustments so embedded elements appear the way they want them to. Note that this only affects sites managed in classic Sites. Sites managed in new Sites are not affected.

Upgraded HTML boxes may change visual appearance 

When boxes are upgraded, you may notice some visual changes to the embedded element. Visual changes could include:

  • Improved appearance of rich embedded content (e.g. Twitter images, buttons, and more). 
  • Different display size of the embedded element. 
  • Different styling of the embedded element. 


Due to these changes, site editors may want to check embedded content still appears as desired. If needed, site editors can:

  • Adjust the height and width. Use the manual controls (pictured below) to make the box fit the embedded content better. 
  • Adjust the formatting. You may want to adjust the embed HTML to match your page style. If you got the code from a third party, check if there are formatting options there. 


If an editor wants to revert back to the legacy embedded element appearance, they can check the “Use legacy html embed” option. The embedded element will then appear the same as before until the automatic upgrade on June 30th (see below).

Two stages to the upgrade 

There will be two stages to these changes:

  • Stage 1: Starting immediately, we’ll upgrade HTML boxes when an editor opens an HTML box on a classic site.  
  • Stage 2: On June 30th, we’ll automatically upgrade all remaining legacy HTML boxes. 
HTML box adjustment options in classic Google Sites



Launch Details 
Release track:

  • Stage 1 (upgrades while content is being edited) launching to both Rapid Release and Scheduled Release on 5/25 
  • Stage 2 (automatic upgrades) launching to both Rapid Release and Scheduled Release on 6/30 


Editions:
Available to all G Suite editions

Rollout pace: 
Full rollout (1–3 days for feature visibility)

Impact: 
All end users

Action: 
Change management suggested/FYI


Launch release calendar
Launch detail categories
Get these product update alerts by email
Subscribe to the RSS feed of these updates

Kubernetes best practices: mapping external services



Editor’s note: Today is the sixth installment in a seven-part video and blog series from Google Developer Advocate Sandeep Dinesh on how to get the most out of your Kubernetes environment.

If you’re like most Kubernetes users, chances are you use services that live outside your cluster. For example, maybe you use the Twillio API to send text messages, or maybe the Google Cloud Vision API to do image analysis.

If your applications in your different environments connect to the same external endpoint, and have no plans to bring the external service into your Kubernetes cluster, it is perfectly fine to use the external service endpoint directly in your code. However, there are many scenarios where this is not the case.

A good example of this are databases. While some cloud-native databases such as Cloud Firestore or Cloud Spanner use a single endpoint for all access, most databases have separate endpoints for different instances.

At this point, you may be thinking that a good solution to finding the endpoint is to use ConfigMaps. Simply store the endpoint address in a ConfigMap, and use it in your code as an environment variable. While this solution works, there are a few downsides. You need to modify your deployment to include the ConfigMap and write additional code to read from the environment variables. But most importantly, if the endpoint address changes you may need to restart all running containers to get the updated endpoint address.

In this episode of “Kubernetes best practices”, let’s learn how to leverage Kubernetes’ built-in service discovery mechanisms for services running outside the cluster, just like you can for services inside the cluster! This gives you parity across your dev and prod environments, and if you eventually move the service inside the cluster, you don’t have to change your code at all.

Scenario 1: Database outside cluster with IP address

A very common scenario is when you are hosting your own database, but doing so outside the cluster, for example on a Google Compute Engine instance. This is very common if you run some services inside Kubernetes and some outside, or need more customization or control than Kubernetes allows.

Hopefully, at some point, you can move all services inside the cluster, but until then you are living in a hybrid world. Thankfully, you can use static Kubernetes services to ease some of the pain.

In this example, I created a MongoDB server using Cloud Launcher. Because it is created in the same network (or VPC) as the Kubernetes cluster, it can be accessed using the high performance internal IP address. In Google Cloud, this is the default setup, so there is nothing special you need to configure.

Now that we have the IP address, the first step is to create a service:
kind: Service
apiVersion: v1
metadata:
 name: mongo
Spec:
 type: ClusterIP
 ports:
 - port: 27017
   targetPort: 27017
You might notice there are no Pod selectors for this service. This creates a service, but it doesn’t know where to send the traffic. This allows you to manually create an Endpoints object that will receive traffic from this service.

kind: Endpoints
apiVersion: v1
metadata:
 name: mongo
subsets:
 - addresses:
     - ip: 10.240.0.4
   ports:
     - port: 27017
You can see that the Endpoints manually defines the IP address for the database, and it uses the same name as the service. Kubernetes uses all the IP addresses defined in the Endpoints as if they were regular Kubernetes Pods. Now you can access the database with a simple connection string:
mongodb://mongo
> No need to use IP addresses in your code at all! If the IP address changes in the future, you can update the Endpoint with the new IP address, and your applications won’t need to make any changes.

Scenario 2: Remotely hosted database with URI

If you are using a hosted database service from a third party, chances are they give you a unified resource identifier (URI) that you can use to connect to. If they give you an IP address, you can use the method in Scenario 1.

In this example, I have two MongoDB databases hosted on mLab. One of them is my dev database, and the other is production.

The connection strings for these databases are as follows:
mongodb://<dbuser>:<dbpassword>@ds149763.mlab.com:49763/dev
mongodb://<dbuser>:<dbpassword>@ds145868.mlab.com:45868/prod
mLab gives you a dynamic URI and a dynamic port, and you can see that they are both different. Let’s use Kubernetes to create an abstraction layer over these differences. In this example, let’s connect to the dev database.

You can create a “ExternalName” Kubernetes service, which gives you a static Kubernetes service that redirects traffic to the external service. This service does a simple CNAME redirection at the kernel level, so there is very minimal impact on your performance.

The YAML for the service looks like this:
kind: Service
apiVersion: v1
metadata:
 name: mongo
spec:
 type: ExternalName
 externalName: ds149763.mlab.com
Now, you can use a much more simplified connection string:
mongodb://<dbuser>:<dbpassword>@mongo:<port>/dev
Because “ExternalName” uses CNAME redirection, it can’t do port remapping. This might be okay for services with static ports, but unfortunately it falls short in this example, where the port is dynamic. mLab’s free tier gives you a dynamic port number and you cannot change it. This means you need a different connection string for dev and prod.

However, if you can get the IP address, then you can do port remapping as I will explain in the next section.

Scenario 3: Remotely hosted database with URI and port remapping

While the CNAME redirect works great for services with the same port for each environment, it falls short in scenarios where the different endpoints for each environment use different ports. Thankfully we can work around that using some basic tools.

The first step is to get the IP address from the URI.

If you run the nslookup, hostname, or ping command against the URI, you can get the IP address of the database.

You can now create a service that remaps the mLab port and an endpoint for this IP address.
kind: Service
apiVersion: v1
metadata:
 name: mongo
spec:
 ports:
 - port: 27017
   targetPort: 49763
---
kind: Endpoints
apiVersion: v1
metadata:
 name: mongo
subsets:
 - addresses:
     - ip: 35.188.8.12
   ports:
     - port: 49763
Note: A URI might use DNS to load-balance to multiple IP addresses, so this method can be risky if the IP addresses change! If you get multiple IP addresses from the above command, you can include all of them in the Endpoints YAML, and Kubernetes will load balance traffic to all the IP addresses.

With this, you can connect to the remote database without needing to specify the port. The Kubernetes service does the port remapping transparently!
mongodb://<dbuser>:<dbpassword>@mongo/dev

Conclusion

Mapping external services to internal ones gives you the flexibility to bring these services into the cluster in the future while minimizing refactoring efforts. Even if you don’t plan to bring them in today, you never know what tomorrow might bring! Additionally, it makes it easier to manage and understand which external services your organization is using.

If the external service has a valid domain name and you don’t need port remapping, then using the “ExternalName” service type is an easy and quick way to map the external service to an internal one. If you don’t have a domain name or need to do port remapping, simply add the IP addresses to an endpoint and use that instead.

Going to Google Cloud Next18? Stop by to meet me and other Kubernetes team members in the "Meet the Experts" zone! Hope to see you there!