无法从Kubernetes Engine连接到Google Cloud SQL

时间:2019-06-21 15:23:13

标签: google-cloud-platform google-kubernetes-engine google-cloud-sql

我有一个Google Cloud SQL第二代实例和一个Google Kubernetes Engine集群。问题是我无法使用私有IP连接到Cloud SQL。我已在Cloud SQL仪表板中启用了专用IP,并将其分配给我的VPC网络。但是,容器仍然无法连接。

这可能与对等路由有关吗?我需要创建一个吗?

PS。我遵循了本指南https://cloud.google.com/sql/docs/mysql/connect-kubernetes-engine

gcloud container clusters describe的结果:

$ gcloud container clusters describe sirodoht-32-fec8e2914780bf2c
addonsConfig:
  kubernetesDashboard:
    disabled: true
  networkPolicyConfig:
    disabled: true
clusterIpv4Cidr: 10.40.0.0/14
createTime: '2019-05-12T17:07:17+00:00'
currentMasterVersion: 1.12.7-gke.10
currentNodeCount: 6
currentNodeVersion: 1.11.8-gke.6
defaultMaxPodsConstraint:
  maxPodsPerNode: '110'
endpoint: <retracted ip>
initialClusterVersion: 1.11.8-gke.6
initialNodeCount: 1
instanceGroupUrls:
- https://www.googleapis.com/compute/v1/projects/sirodoht-32/zones/europe-west3-a/instanceGroupManagers/gke-sirodoht-32-fep8e29-pool-94e97802-grp
ipAllocationPolicy:
  clusterIpv4Cidr: 10.40.0.0/14
  clusterIpv4CidrBlock: 10.40.0.0/14
  clusterSecondaryRangeName: gke-sirodoht-32-fec8e2914780bf2c-pods-4439d109
  servicesIpv4Cidr: 10.170.0.0/20
  servicesIpv4CidrBlock: 10.170.0.0/20
  servicesSecondaryRangeName: gke-sirodoht-32-fec8e2914780bf2c-services-4439d109
  useIpAliases: true
labelFingerprint: a9dc16a7
legacyAbac: {}
location: europe-west3-a
locations:
- europe-west3-a
loggingService: logging.googleapis.com
maintenancePolicy:
  window:
    dailyMaintenanceWindow:
      duration: PT4H0M0S
      startTime: 00:00
masterAuth:
  clientCertificate: <retracted>
  clientKey: <retracted>
  clusterCaCertificate: <retracted>
monitoringService: monitoring.googleapis.com
name: sirodoht-32-fec8e2914780bf2c
network: compute-network-aaa8ff1ec6b52012
networkConfig:
  network: projects/sirodoht-32/global/networks/compute-network-aaa8ff1ec6b52012
  subnetwork: projects/sirodoht-32/regions/europe-west3/subnetworks/subnet-bb2c9eb79b29a825
nodeConfig:
  diskSizeGb: 100
  diskType: pd-standard
  imageType: COS
  machineType: n1-standard-4
  oauthScopes:
  - https://www.googleapis.com/auth/monitoring
  - https://www.googleapis.com/auth/devstorage.read_only
  - https://www.googleapis.com/auth/logging.write
  - https://www.googleapis.com/auth/service.management.readonly
  - https://www.googleapis.com/auth/servicecontrol
  - https://www.googleapis.com/auth/trace.append
  serviceAccount: default
nodePools:
- config:
    diskSizeGb: 100
    diskType: pd-standard
    imageType: COS
    machineType: n1-standard-4
    oauthScopes:
    - https://www.googleapis.com/auth/monitoring
    - https://www.googleapis.com/auth/devstorage.read_only
    - https://www.googleapis.com/auth/logging.write
    - https://www.googleapis.com/auth/service.management.readonly
    - https://www.googleapis.com/auth/servicecontrol
    - https://www.googleapis.com/auth/trace.append
    serviceAccount: default
  initialNodeCount: 6
  instanceGroupUrls:
  - https://www.googleapis.com/compute/v1/projects/sirodoht-32/zones/europe-west3-a/instanceGroupManagers/gke-sirodoht-32-fep8e29-pool-94e97802-grp
  management: {}
  maxPodsConstraint:
    maxPodsPerNode: '110'
  name: pool
  podIpv4CidrSize: 24
  selfLink: https://container.googleapis.com/v1/projects/sirodoht-32/zones/europe-west3-a/clusters/sirodoht-32-fec8e2914780bf2c/nodePools/pool
  status: RUNNING
  version: 1.11.8-gke.6
selfLink: https://container.googleapis.com/v1/projects/sirodoht-32/zones/europe-west3-a/clusters/sirodoht-32-fec8e2914780bf2c
servicesIpv4Cidr: 10.170.0.0/20
status: RUNNING
subnetwork: subnet-bb2c9eb79b29a825
zone: europe-west3-a

* - There is an upgrade available for your cluster(s).

To upgrade nodes to the latest available version, run
  $ gcloud container clusters upgrade sirodoht-32-fec8e2914780bf2c

1 个答案:

答案 0 :(得分:0)

私有IP仅可由同一虚拟私有云(VPC)上的其他资源访问。请遵循以下instructions来在与您的Cloud SQL实例相同的VPC上设置GKE集群。

有关在Cloud SQL上使用私有IP的环境要求的详细信息,请参阅this页。