Skip to content

Commit f178f37

Browse files
committed
Fix the development workflow which was failing in make dev/build.
Removed rules_k8s bazel dependency as it is deprecated and not supported with rules_oci.
1 parent ab1f129 commit f178f37

File tree

7 files changed

+41
-63
lines changed

7 files changed

+41
-63
lines changed

BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ oci_push(
3232
image = "//cmd/cockroach-operator:index",
3333
remote_tags = ":tags",
3434
repository = "${DOCKER_REGISTRY}/${DOCKER_IMAGE_REPOSITORY}",
35+
visibility = ["//visibility:public"],
3536
)
3637

3738
filegroup(

WORKSPACE

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -129,42 +129,6 @@ load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
129129

130130
rules_pkg_dependencies()
131131

132-
################################
133-
# Load rules_k8s and configure #
134-
################################
135-
http_archive(
136-
name = "io_bazel_rules_k8s",
137-
sha256 = "ce5b9bc0926681e2e7f2147b49096f143e6cbc783e71bc1d4f36ca76b00e6f4a",
138-
strip_prefix = "rules_k8s-0.7",
139-
urls = ["https://github.com/bazelbuild/rules_k8s/archive/refs/tags/v0.7.tar.gz"],
140-
)
141-
142-
load("@io_bazel_rules_k8s//k8s:k8s.bzl", "k8s_repositories")
143-
144-
k8s_repositories()
145-
146-
load("@io_bazel_rules_k8s//k8s:k8s.bzl", "k8s_defaults")
147-
148-
#############################################################
149-
# Setting up the defaults for rules k8s. The varible values
150-
# are replaced by hack/build/print-workspace-status.sh
151-
# Using environment variables that are prefixed with the word
152-
# 'STAMP_' causes the rules_k8s files to rebuild when the
153-
# --stamp and evn values change.
154-
#############################################################
155-
k8s_defaults(
156-
# This becomes the name of the @repository and the rule
157-
# you will import in your BUILD files.
158-
name = "k8s_deploy",
159-
# This is the name of the cluster as it appears in:
160-
# kubectl config view --minify -o=jsonpath='{.contexts[0].context.cluster}'
161-
# You are able to override the default cluster by setting the env variable K8S_CLUSTER
162-
cluster = "{STABLE_CLUSTER}",
163-
# You are able to override the default registry by setting the env variable DEV_REGISTRY
164-
image_chroot = "{STABLE_IMAGE_REGISTRY}",
165-
kind = "deployment",
166-
)
167-
168132
###################################################
169133
# Load kubernetes repo-infra for tools like kazel #
170134
###################################################

config/crd/BUILD.bazel

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("@k8s_deploy//:defaults.bzl", "k8s_deploy")
1615
load("//hack/build:kustomize.bzl", "kustomization")
1716

1817
kustomization(
1918
name = "manifest",
2019
srcs = [":all-srcs"],
2120
)
2221

23-
k8s_deploy(
24-
name = "crd",
25-
template = ":manifest",
22+
# Use a shell script to apply the manifest via kubectl
23+
sh_binary(
24+
name = "apply_k8s_crd",
25+
srcs = ["//config/default:apply_k8s_script"],
26+
args = ["$(location :manifest)"],
27+
data = [":manifest"],
2628
visibility = ["//visibility:public"],
2729
)
2830

config/default/BUILD.bazel

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
load("@k8s_deploy//:defaults.bzl", "k8s_deploy")
15-
load("@io_bazel_rules_k8s//k8s:objects.bzl", "k8s_objects")
1614
load("//hack/build:kustomize.bzl", "kustomization")
1715

1816
# Builds the whole enchilada including the crds, rbac sa(s)/roles/bindings, manager
@@ -28,21 +26,18 @@ kustomization(
2826
],
2927
)
3028

31-
k8s_deploy(
32-
name = "image",
33-
images = {
34-
# when running locally, use the image from the local codebase
35-
"cockroach-operator:$(APP_VERSION)": "//cmd/cockroach-operator:operator_image",
36-
},
37-
resolver_args = ["--allow_unused_images"],
38-
template = ":manifest",
29+
filegroup(
30+
name = "apply_k8s_script",
31+
srcs = ["apply_k8s.sh"], # List the shell script here
32+
visibility = ["//visibility:public"], # Make it accessible to other packages
3933
)
4034

41-
k8s_objects(
42-
name = "install",
43-
objects = [
44-
":image",
45-
],
35+
# Use a shell script to apply the manifest via kubectl
36+
sh_binary(
37+
name = "apply_k8s_app",
38+
srcs = ["apply_k8s.sh"],
39+
args = ["$(location :manifest)"],
40+
data = [":manifest"],
4641
visibility = ["//visibility:public"],
4742
)
4843

config/default/apply_k8s.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
MANIFEST="$1"
5+
6+
if [ -z "$MANIFEST" ]; then
7+
echo "Manifest file not provided."
8+
exit 1
9+
fi
10+
11+
kubectl apply -f "$MANIFEST"

config/webhook/BUILD.bazel

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
load("@k8s_deploy//:defaults.bzl", "k8s_deploy")
1615
load("//hack/build:kustomize.bzl", "kustomization")
1716

1817
kustomization(
1918
name = "manifest",
2019
srcs = [":all-srcs"],
2120
)
2221

23-
k8s_deploy(
24-
name = "webhook",
25-
template = ":manifest",
22+
# Use a shell script to apply the manifest via kubectl
23+
sh_binary(
24+
name = "apply_k8s_webhook",
25+
srcs = ["//config/default:apply_k8s_script"],
26+
args = ["$(location :manifest)"],
27+
data = [":manifest"],
2628
visibility = ["//visibility:public"],
2729
)
2830

hack/dev.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,15 @@ install_operator() {
4949
# ${REGISTRY_NAME} must be mapped to localhost or 127.0.0.1 to push the image to the k3d registry.
5050
bazel run //hack/crdbversions:crdbversions -- -operator-image ${DEV_REGISTRY}/cockroach-operator -operator-version ${APP_VERSION} -crdb-versions $(PWD)/crdb-versions.yaml -repo-root $(PWD)
5151
K8S_CLUSTER="k3d-${CLUSTER_NAME}" \
52-
DEV_REGISTRY="${DEV_REGISTRY}" \
52+
DOCKER_REGISTRY="${DEV_REGISTRY}" \
53+
DOCKER_IMAGE_REPOSITORY="cockroach-operator" \
54+
APP_VERSION="${APP_VERSION}" \
5355
bazel run \
5456
--stamp \
55-
--platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 \
56-
--define APP_VERSION=${APP_VERSION} \
57-
//config/default:install.apply
57+
//:push_operator_image
58+
bazel run \
59+
--stamp \
60+
//config/default:apply_k8s_app
5861
}
5962

6063
wait_for_ready() {

0 commit comments

Comments
 (0)