Skip to content

Commit

Permalink
support regional compute target TCP proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
gemmahou committed Oct 14, 2024
1 parent 45d29a9 commit b7fb15e
Show file tree
Hide file tree
Showing 12 changed files with 119 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,19 @@ spec:
description:
description: Immutable. An optional description of this resource.
type: string
location:
description: 'Location represents the geographical location of the
ComputeTargetTCPProxy. Specify a region name or "global" for global
resources. Reference: GCP definition of regions/zones (https://cloud.google.com/compute/docs/regions-zones/)'
type: string
proxyBind:
description: |-
Immutable. This field only applies when the forwarding rule that references
this target proxy has a loadBalancingScheme set to INTERNAL_SELF_MANAGED.
type: boolean
proxyHeader:
description: |-
Specifies the type of proxy header to append before sending data to
Immutable. Specifies the type of proxy header to append before sending data to
the backend. Default value: "NONE" Possible values: ["NONE", "PROXY_V1"].
type: string
resourceID:
Expand All @@ -106,6 +111,7 @@ spec:
type: string
required:
- backendServiceRef
- location
type: object
status:
properties:
Expand Down
24 changes: 24 additions & 0 deletions config/servicemappings/compute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1776,6 +1776,29 @@ spec:
containers:
- type: project
tfField: project
- name: google_compute_region_target_tcp_proxy
kind: ComputeTargetTCPProxy
metadataMapping:
name: name
resourceID:
targetField: name
locationality: regional
idTemplate: "projects/{{project}}/regions/{{region}}/targetTcpProxies/{{name}}"
idTemplateCanBeUsedToMatchResourceName: true
resourceAvailableInAssetInventory: true
resourceReferences:
- key: backendServiceRef
description: |-
A reference to the ComputeBackendService resource.
tfField: backend_service
gvk:
kind: ComputeBackendService
version: v1beta1
group: compute.cnrm.cloud.google.com
targetField: self_link
containers:
- type: project
tfField: project
- name: google_compute_region_url_map
kind: ComputeURLMap
metadataMapping:
Expand Down Expand Up @@ -2679,6 +2702,7 @@ spec:
name: name
resourceID:
targetField: name
locationality: global
idTemplate: "projects/{{project}}/global/targetTcpProxies/{{name}}"
idTemplateCanBeUsedToMatchResourceName: true
resourceAvailableInAssetInventory: true
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/test/resourcefixture/contexts/compute_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ func init() {
ResourceKind: "ComputeTargetTCPProxy",
}

resourceContextMap["regionalcomputetargettcpproxy"] = ResourceContext{
ResourceKind: "ComputeTargetTCPProxy",
SkipUpdate: true, // No UPDATE/PATCH method supported in API.
}

resourceContextMap["globalcomputeforwardingrule"] = ResourceContext{
ResourceKind: "ComputeForwardingRule",
SkipUpdate: true, // The only field which supports update is targetRef, which currently cannot be used for testing updates because of b/147506185
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ metadata:
spec:
backendServiceRef:
name: computebackendservice-${uniqueId}
location: global
proxyHeader: PROXY_V1
resourceID: computetargettcpproxy-${uniqueId}
status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ spec:
backendServiceRef:
name: computebackendservice-${uniqueId}
proxyHeader: NONE
location: global
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,4 @@ spec:
backendServiceRef:
name: computebackendservice-${uniqueId}
proxyHeader: PROXY_V1
location: global
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: compute.cnrm.cloud.google.com/v1beta1
kind: ComputeTargetTCPProxy
metadata:
annotations:
cnrm.cloud.google.com/project-id: ${projectId}
name: computetargettcpproxy-${uniqueId}
spec:
backendServiceRef:
name: computebackendservice-${uniqueId}
proxyHeader: NONE
location: europe-west4
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: compute.cnrm.cloud.google.com/v1beta1
kind: ComputeHealthCheck
metadata:
name: computehealthcheck-${uniqueId}
spec:
checkIntervalSec: 10
tcpHealthCheck:
port: 443
location: europe-west4
---
apiVersion: compute.cnrm.cloud.google.com/v1beta1
kind: ComputeBackendService
metadata:
name: computebackendservice-${uniqueId}
spec:
healthChecks:
- healthCheckRef:
name: computehealthcheck-${uniqueId}
location: europe-west4
protocol: TCP
# Default loadBalancingScheme for regional backend service is INTERNAL
# Set to INTERNAL_MANAGED when being referenced by Regional Target TCP Proxy
# googleapi error: Regional Target TCP Proxy cannot be used with BackendServices with schema INTERNAL
loadBalancingScheme: INTERNAL_MANAGED

Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ backendServiceRef:
name: string
namespace: string
description: string
location: string
proxyBind: boolean
proxyHeader: string
resourceID: string
Expand Down Expand Up @@ -144,6 +145,16 @@ resourceID: string
<p>{% verbatim %}Immutable. An optional description of this resource.{% endverbatim %}</p>
</td>
</tr>
<tr>
<td>
<p><code>location</code></p>
<p><i>Required</i></p>
</td>
<td>
<p><code class="apitype">string</code></p>
<p>{% verbatim %}Location represents the geographical location of the ComputeTargetTCPProxy. Specify a region name or "global" for global resources. Reference: GCP definition of regions/zones (https://cloud.google.com/compute/docs/regions-zones/){% endverbatim %}</p>
</td>
</tr>
<tr>
<td>
<p><code>proxyBind</code></p>
Expand All @@ -162,7 +173,7 @@ this target proxy has a loadBalancingScheme set to INTERNAL_SELF_MANAGED.{% endv
</td>
<td>
<p><code class="apitype">string</code></p>
<p>{% verbatim %}Specifies the type of proxy header to append before sending data to
<p>{% verbatim %}Immutable. Specifies the type of proxy header to append before sending data to
the backend. Default value: "NONE" Possible values: ["NONE", "PROXY_V1"].{% endverbatim %}</p>
</td>
</tr>
Expand Down

0 comments on commit b7fb15e

Please sign in to comment.