Connect to Cloud SQL for PosgreSQL from Cloud Composer
My question is about configure Google Cloud Composer to reach Google Cloud SQL using the same network configuration in the same Google Cloud project.
Cloud SQL configured with Private IP associated to a Default Network.
Cloud SQL configCloud Composer configured Network ID = Default
Cloud Composer config
Executing a DAG which uses a PostgresOperator configured with the Private IP and default port (5432) to connect, we always get the same connection error:
ERROR - could not connect to server: Connection timed ou Is the
server running on host "private_ip" and acceptin TCP/IP connections on
port 5432
We expect the connection should be established because we have configured the same network and we are using Private IP to reach the Cloud SQL server from Composer.
google-cloud-platform google-cloud-sql google-container-engine google-cloud-composer
add a comment |
My question is about configure Google Cloud Composer to reach Google Cloud SQL using the same network configuration in the same Google Cloud project.
Cloud SQL configured with Private IP associated to a Default Network.
Cloud SQL configCloud Composer configured Network ID = Default
Cloud Composer config
Executing a DAG which uses a PostgresOperator configured with the Private IP and default port (5432) to connect, we always get the same connection error:
ERROR - could not connect to server: Connection timed ou Is the
server running on host "private_ip" and acceptin TCP/IP connections on
port 5432
We expect the connection should be established because we have configured the same network and we are using Private IP to reach the Cloud SQL server from Composer.
google-cloud-platform google-cloud-sql google-container-engine google-cloud-composer
add a comment |
My question is about configure Google Cloud Composer to reach Google Cloud SQL using the same network configuration in the same Google Cloud project.
Cloud SQL configured with Private IP associated to a Default Network.
Cloud SQL configCloud Composer configured Network ID = Default
Cloud Composer config
Executing a DAG which uses a PostgresOperator configured with the Private IP and default port (5432) to connect, we always get the same connection error:
ERROR - could not connect to server: Connection timed ou Is the
server running on host "private_ip" and acceptin TCP/IP connections on
port 5432
We expect the connection should be established because we have configured the same network and we are using Private IP to reach the Cloud SQL server from Composer.
google-cloud-platform google-cloud-sql google-container-engine google-cloud-composer
My question is about configure Google Cloud Composer to reach Google Cloud SQL using the same network configuration in the same Google Cloud project.
Cloud SQL configured with Private IP associated to a Default Network.
Cloud SQL configCloud Composer configured Network ID = Default
Cloud Composer config
Executing a DAG which uses a PostgresOperator configured with the Private IP and default port (5432) to connect, we always get the same connection error:
ERROR - could not connect to server: Connection timed ou Is the
server running on host "private_ip" and acceptin TCP/IP connections on
port 5432
We expect the connection should be established because we have configured the same network and we are using Private IP to reach the Cloud SQL server from Composer.
google-cloud-platform google-cloud-sql google-container-engine google-cloud-composer
google-cloud-platform google-cloud-sql google-container-engine google-cloud-composer
edited Nov 15 '18 at 17:42
Oscar Pérez
asked Nov 15 '18 at 16:06
Oscar PérezOscar Pérez
1817
1817
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
according to Introducing private networking connection for Cloud SQL these are still two separate network segments (see the visual scheme there). therefore VPC network peering is required, in order to get a route-able private IP. see the code lab, which has also this scenario covered.
Makes sense because Kubernes workers are created on behalf of Composer. We'll try it and comment on the results. Thanks.
– Oscar Pérez
Nov 16 '18 at 9:48
add a comment |
The request from Composer comes from the pod's IP address which is non-routable outside the VPC. Therefore it has to be masqueraded to the IP of the interface of the node which is in 10.0.0.0/8 (when using the default network).
If you configured your CloudSQL instance to use an auto-generated IP range when setting the Private IP connection, it is likely the IP is also in 10.0.0.0/8, but it is not inside the same VPC.
If it the connection is to 10.0.0.0/8 and is not in the VPC, it can't be routed. As a workaround you can create a custom address range, for example 192.168.X.X:
gcloud beta compute addresses create [RESERVED_RANGE_NAME]
--global
--purpose=VPC_PEERING
--addresses=192.168.0.0
--prefix-length=16
--description=[DESCRIPTION]
--network=[VPC_NETWORK]
And configure your Cloud SQL instance's private IP to be within that range.
You can also regularly check the Composer's release notes for updates on VPC-native clusters being available for Composer.
– ch_mike
Nov 21 '18 at 22:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323450%2fconnect-to-cloud-sql-for-posgresql-from-cloud-composer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
according to Introducing private networking connection for Cloud SQL these are still two separate network segments (see the visual scheme there). therefore VPC network peering is required, in order to get a route-able private IP. see the code lab, which has also this scenario covered.
Makes sense because Kubernes workers are created on behalf of Composer. We'll try it and comment on the results. Thanks.
– Oscar Pérez
Nov 16 '18 at 9:48
add a comment |
according to Introducing private networking connection for Cloud SQL these are still two separate network segments (see the visual scheme there). therefore VPC network peering is required, in order to get a route-able private IP. see the code lab, which has also this scenario covered.
Makes sense because Kubernes workers are created on behalf of Composer. We'll try it and comment on the results. Thanks.
– Oscar Pérez
Nov 16 '18 at 9:48
add a comment |
according to Introducing private networking connection for Cloud SQL these are still two separate network segments (see the visual scheme there). therefore VPC network peering is required, in order to get a route-able private IP. see the code lab, which has also this scenario covered.
according to Introducing private networking connection for Cloud SQL these are still two separate network segments (see the visual scheme there). therefore VPC network peering is required, in order to get a route-able private IP. see the code lab, which has also this scenario covered.
answered Nov 15 '18 at 17:55
Martin ZeitlerMartin Zeitler
19.2k34373
19.2k34373
Makes sense because Kubernes workers are created on behalf of Composer. We'll try it and comment on the results. Thanks.
– Oscar Pérez
Nov 16 '18 at 9:48
add a comment |
Makes sense because Kubernes workers are created on behalf of Composer. We'll try it and comment on the results. Thanks.
– Oscar Pérez
Nov 16 '18 at 9:48
Makes sense because Kubernes workers are created on behalf of Composer. We'll try it and comment on the results. Thanks.
– Oscar Pérez
Nov 16 '18 at 9:48
Makes sense because Kubernes workers are created on behalf of Composer. We'll try it and comment on the results. Thanks.
– Oscar Pérez
Nov 16 '18 at 9:48
add a comment |
The request from Composer comes from the pod's IP address which is non-routable outside the VPC. Therefore it has to be masqueraded to the IP of the interface of the node which is in 10.0.0.0/8 (when using the default network).
If you configured your CloudSQL instance to use an auto-generated IP range when setting the Private IP connection, it is likely the IP is also in 10.0.0.0/8, but it is not inside the same VPC.
If it the connection is to 10.0.0.0/8 and is not in the VPC, it can't be routed. As a workaround you can create a custom address range, for example 192.168.X.X:
gcloud beta compute addresses create [RESERVED_RANGE_NAME]
--global
--purpose=VPC_PEERING
--addresses=192.168.0.0
--prefix-length=16
--description=[DESCRIPTION]
--network=[VPC_NETWORK]
And configure your Cloud SQL instance's private IP to be within that range.
You can also regularly check the Composer's release notes for updates on VPC-native clusters being available for Composer.
– ch_mike
Nov 21 '18 at 22:59
add a comment |
The request from Composer comes from the pod's IP address which is non-routable outside the VPC. Therefore it has to be masqueraded to the IP of the interface of the node which is in 10.0.0.0/8 (when using the default network).
If you configured your CloudSQL instance to use an auto-generated IP range when setting the Private IP connection, it is likely the IP is also in 10.0.0.0/8, but it is not inside the same VPC.
If it the connection is to 10.0.0.0/8 and is not in the VPC, it can't be routed. As a workaround you can create a custom address range, for example 192.168.X.X:
gcloud beta compute addresses create [RESERVED_RANGE_NAME]
--global
--purpose=VPC_PEERING
--addresses=192.168.0.0
--prefix-length=16
--description=[DESCRIPTION]
--network=[VPC_NETWORK]
And configure your Cloud SQL instance's private IP to be within that range.
You can also regularly check the Composer's release notes for updates on VPC-native clusters being available for Composer.
– ch_mike
Nov 21 '18 at 22:59
add a comment |
The request from Composer comes from the pod's IP address which is non-routable outside the VPC. Therefore it has to be masqueraded to the IP of the interface of the node which is in 10.0.0.0/8 (when using the default network).
If you configured your CloudSQL instance to use an auto-generated IP range when setting the Private IP connection, it is likely the IP is also in 10.0.0.0/8, but it is not inside the same VPC.
If it the connection is to 10.0.0.0/8 and is not in the VPC, it can't be routed. As a workaround you can create a custom address range, for example 192.168.X.X:
gcloud beta compute addresses create [RESERVED_RANGE_NAME]
--global
--purpose=VPC_PEERING
--addresses=192.168.0.0
--prefix-length=16
--description=[DESCRIPTION]
--network=[VPC_NETWORK]
And configure your Cloud SQL instance's private IP to be within that range.
The request from Composer comes from the pod's IP address which is non-routable outside the VPC. Therefore it has to be masqueraded to the IP of the interface of the node which is in 10.0.0.0/8 (when using the default network).
If you configured your CloudSQL instance to use an auto-generated IP range when setting the Private IP connection, it is likely the IP is also in 10.0.0.0/8, but it is not inside the same VPC.
If it the connection is to 10.0.0.0/8 and is not in the VPC, it can't be routed. As a workaround you can create a custom address range, for example 192.168.X.X:
gcloud beta compute addresses create [RESERVED_RANGE_NAME]
--global
--purpose=VPC_PEERING
--addresses=192.168.0.0
--prefix-length=16
--description=[DESCRIPTION]
--network=[VPC_NETWORK]
And configure your Cloud SQL instance's private IP to be within that range.
answered Nov 21 '18 at 22:54
ch_mikech_mike
73918
73918
You can also regularly check the Composer's release notes for updates on VPC-native clusters being available for Composer.
– ch_mike
Nov 21 '18 at 22:59
add a comment |
You can also regularly check the Composer's release notes for updates on VPC-native clusters being available for Composer.
– ch_mike
Nov 21 '18 at 22:59
You can also regularly check the Composer's release notes for updates on VPC-native clusters being available for Composer.
– ch_mike
Nov 21 '18 at 22:59
You can also regularly check the Composer's release notes for updates on VPC-native clusters being available for Composer.
– ch_mike
Nov 21 '18 at 22:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323450%2fconnect-to-cloud-sql-for-posgresql-from-cloud-composer%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown