Skip to content

Commit 5a883fc

Browse files
authored
chore: Fix the build.sh script to succeed in a linux dev environment (#729)
Updated the build command so it succeeds with a local build, and does not try to push the image to a remote repo. Updated terraform scripts to avoid unnecessary reconfiguration during e2e tests.
1 parent d22abf4 commit 5a883fc

File tree

7 files changed

+38
-14
lines changed

7 files changed

+38
-14
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,5 @@ config/rbac/role.yaml
4343
internal/api/v1/zz_generated.deepcopy.go
4444
installer/install.sh
4545
installer/cloud-sql-proxy-operator.yaml
46+
.tools
47+
.envrc

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ generate: ctrl_generate ctrl_manifests generate_crd_docs go_lint tf_lint instal
9090
build: generate build_push_docker ## Builds and pushes the docker image to tag defined in envvar IMG
9191
@echo "TIME: $(shell date) end make build"
9292

93+
.PHONY: build_docker_local
94+
build_docker_local: generate build_docker ## Builds the docker image but does not push
95+
@echo "TIME: $(shell date) end make build"
96+
9397
.PHONY: test
9498
test: generate go_test go_test_k8s_1_28 ## Run tests (but not internal/teste2e)
9599
@echo "TIME: $(shell date) end make test"
@@ -151,6 +155,15 @@ build_push_docker: # Build docker image with the operator. set IMG env var befor
151155
test -d 'bin' || mkdir -p bin
152156
echo "$(IMG)" > bin/last-pushed-image-url.txt
153157

158+
.PHONY: build_docker
159+
build_docker: # Build docker image with the operator. set IMG env var before running: `IMG=example.com/img:1.0 make build`
160+
docker buildx build --platform "linux/amd64" \
161+
--build-arg GO_LD_FLAGS="$(VERSION_LDFLAGS)" \
162+
-f "Dockerfile-operator" \
163+
"$(PWD)"
164+
test -d 'bin' || mkdir -p bin
165+
echo "$(IMG)" > bin/last-pushed-image-url.txt
166+
154167
.PHONY: go_lint
155168
go_lint: golangci-lint # Run go lint tools, fail if unchecked errors
156169
# Implements golang CI based on settings described here:

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ function clean() {
2929
make clean
3030
}
3131

32-
## build - Builds the project without running tests.
32+
## build - Builds the project without running tests or pushing the container image
3333
function build() {
34-
make build
34+
make build_docker_local
3535
}
3636

3737
## test - Runs local unit tests.

config/manager/kustomization.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
resources:
15-
- manager.yaml
15+
- manager.yaml
1616
generatorOptions:
1717
disableNameSuffixHash: true
1818
configMapGenerator:
19-
- files:
20-
- controller_manager_config.yaml
21-
name: manager-config
19+
- files:
20+
- controller_manager_config.yaml
21+
name: manager-config
2222
apiVersion: kustomize.config.k8s.io/v1beta1
2323
kind: Kustomization
2424
images:
25-
- name: controller
26-
newName: cloud-sql-proxy-operator
27-
newTag: latest
25+
- name: controller
26+
newName: us-central1-docker.pkg.dev/hessjc-csql-operator-04/testhessjc/cloud-sql-auth-proxy-operator
27+
newTag: f2eb19b2d91f77a5c4c800a64902bbff720c8bd6-dirty-20260122T2138

docs/api.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ _Appears in:_
5858
| `maxSigtermDelay` _integer_ | MaxSigtermDelay is the maximum number of seconds to wait for connections to<br />close after receiving a TERM signal. This sets the proxy container's<br />CLI argument `--max-sigterm-delay` and<br />configures `terminationGracePeriodSeconds` on the workload's PodSpec. | | Minimum: 0 <br />Optional: \{\} <br /> |
5959
| `minSigtermDelay` _integer_ | MinSigtermDelay is the minimum number of seconds to wait for connections to<br />close after receiving a TERM signal. This sets the proxy container's<br />CLI argument `--min-sigterm-delay` | | Minimum: 0 <br />Optional: \{\} <br /> |
6060
| `sqlAdminAPIEndpoint` _string_ | SQLAdminAPIEndpoint is a debugging parameter that when specified will<br />change the Google Cloud api endpoint used by the proxy. | | Optional: \{\} <br /> |
61-
| `image` _string_ | Image is the URL to the proxy image. Optional, by default the operator<br />will use the latest Cloud SQL Auth Proxy version as of the release of the<br />operator.<br /><br />The operator ensures that all workloads configured with the default proxy<br />image are upgraded automatically to use to the latest released proxy image.<br /><br />When the customer upgrades the operator, the operator upgrades all<br />workloads using the default proxy image to the latest proxy image. The<br />change to the proxy container image is applied in accordance with<br />the RolloutStrategy. | | Optional: \{\} <br /> |
61+
| `image` _string_ | Image is the URL to the proxy image. Optional, by default the operator<br />will use the latest Cloud SQL Auth Proxy version as of the release of the<br />operator.<br />The operator ensures that all workloads configured with the default proxy<br />image are upgraded automatically to use to the latest released proxy image.<br />When the customer upgrades the operator, the operator upgrades all<br />workloads using the default proxy image to the latest proxy image. The<br />change to the proxy container image is applied in accordance with<br />the RolloutStrategy. | | Optional: \{\} <br /> |
6262
| `rolloutStrategy` _string_ | RolloutStrategy indicates the strategy to use when rolling out changes to<br />the workloads affected by the results. When this is set to<br />`Workload`, changes to this resource will be automatically applied<br />to a running Deployment, StatefulSet, DaemonSet, or ReplicaSet in<br />accordance with the Strategy set on that workload. When this is set to<br />`None`, the operator will take no action to roll out changes to affected<br />workloads. `Workload` will be used by default if no value is set.<br />See: https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy | Workload | Enum: [Workload None] <br />Optional: \{\} <br /> |
6363
| `refreshStrategy` _string_ | RefreshStrategy indicates which refresh strategy the proxy should use.<br />When this is set to `lazy`, the proxy will use a lazy refresh strategy,<br />and will be configured to run with the --lazy-refresh flag. When this<br />omitted or set to `background`, the proxy will use the default background<br />refresh strategy.<br />See: https://github.com/GoogleCloudPlatform/cloud-sql-proxy/?tab=readme-ov-file#configuring-a-lazy-refresh | background | Enum: [lazy background] <br />Optional: \{\} <br /> |
6464
| `quiet` _boolean_ | Quiet configures the proxy's --quiet flag to limit the amount of<br />logging generated by the proxy container. | | |
@@ -130,25 +130,21 @@ _Appears in:_
130130
InstanceSpec describes the configuration for how the proxy should expose
131131
a Cloud SQL database instance to a workload.
132132

133-
134133
In the minimum recommended configuration, the operator will choose
135134
a non-conflicting TCP port and set environment
136135
variables MY_DB_SERVER_PORT MY_DB_SERVER_HOST with the value of the TCP port
137136
and hostname. The application can read these values to connect to the database
138137
through the proxy. For example:
139138

140-
141139
`{
142140
"connectionString":"my-project:us-central1:my-db-server",
143141
"portEnvName":"MY_DB_SERVER_PORT"
144142
"hostEnvName":"MY_DB_SERVER_HOST"
145143
}`
146144

147-
148145
If you want to assign a specific port number for a database, set the `port`
149146
field. For example:
150147

151-
152148
`{ "connectionString":"my-project:us-central1:my-db-server", "port":5000 }`
153149

154150

infra/resources/gke_cluster.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ resource "google_container_cluster" "primary" {
4343
remove_default_node_pool = true
4444
resource_labels = local.standard_labels
4545

46+
lifecycle {
47+
ignore_changes = [min_master_version]
48+
}
4649
}
4750

4851
resource "google_container_node_pool" "primary_preemptible_nodes" {
@@ -78,6 +81,9 @@ resource "google_container_node_pool" "primary_preemptible_nodes" {
7881
"https://www.googleapis.com/auth/sqlservice.admin",
7982
]
8083
}
84+
lifecycle {
85+
ignore_changes = [version]
86+
}
8187
}
8288

8389

infra/resources/private_gke_cluster.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ resource "google_container_cluster" "private" {
4141
services_secondary_range_name = google_compute_subnetwork.private_k8s_network.secondary_ip_range.0.range_name
4242
cluster_secondary_range_name = google_compute_subnetwork.private_k8s_network.secondary_ip_range.1.range_name
4343
}
44+
45+
lifecycle {
46+
ignore_changes = [min_master_version]
47+
}
4448
}
4549

4650
resource "google_container_node_pool" "private_preemptible_nodes" {
@@ -82,6 +86,9 @@ resource "google_container_node_pool" "private_preemptible_nodes" {
8286
"https://www.googleapis.com/auth/sqlservice.admin",
8387
]
8488
}
89+
lifecycle {
90+
ignore_changes = [version]
91+
}
8592
}
8693

8794

0 commit comments

Comments
 (0)