Skip to content

Commit 57708bd

Browse files
authored
Fix inventory file and upgrade documentation (mongodb#1596)
1 parent 31acaf7 commit 57708bd

7 files changed

+53
-34
lines changed

Diff for: Makefile

+7-8
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ NAMESPACE := $(shell jq -r .namespace < $(MONGODB_COMMUNITY_CONFIG))
99
UPGRADE_HOOK_IMG := $(shell jq -r .version_upgrade_hook_image < $(MONGODB_COMMUNITY_CONFIG))
1010
READINESS_PROBE_IMG := $(shell jq -r .readiness_probe_image < $(MONGODB_COMMUNITY_CONFIG))
1111
REGISTRY := $(shell jq -r .repo_url < $(MONGODB_COMMUNITY_CONFIG))
12-
AGENT_IMAGE_NAME := $(shell jq -r .agent_image_ubi < $(MONGODB_COMMUNITY_CONFIG))
13-
12+
AGENT_IMAGE_NAME := $(shell jq -r .agent_image < $(MONGODB_COMMUNITY_CONFIG))
1413
HELM_CHART ?= ./helm-charts/charts/community-operator
1514

1615
STRING_SET_VALUES := --set namespace=$(NAMESPACE),versionUpgradeHook.name=$(UPGRADE_HOOK_IMG),readinessProbe.name=$(READINESS_PROBE_IMG),registry.operator=$(REPO_URL),operator.operatorImageName=$(OPERATOR_IMAGE),operator.version=latest,registry.agent=$(REGISTRY),registry.versionUpgradeHook=$(REGISTRY),registry.readinessProbe=$(REGISTRY),registry.operator=$(REGISTRY),versionUpgradeHook.version=latest,readinessProbe.version=latest,agent.version=latest,agent.name=$(AGENT_IMAGE_NAME)
@@ -134,7 +133,7 @@ install-rbac:
134133
$(HELM) template $(STRING_SET_VALUES) -s templates/operator_roles.yaml $(HELM_CHART) | kubectl apply -f -
135134

136135
uninstall-crd:
137-
kubectl delete crd mongodbcommunity.mongodbcommunity.mongodb.com
136+
kubectl delete crd --ignore-not-found mongodbcommunity.mongodbcommunity.mongodb.com
138137

139138
uninstall-chart:
140139
$(HELM) uninstall $(RELEASE_NAME_HELM) -n $(NAMESPACE)
@@ -193,19 +192,19 @@ generate-env-file: ## generates a local-test.env for local testing
193192
##@ Image
194193

195194
operator-image: ## Build and push the operator image
196-
python pipeline.py --image-name operator
195+
python pipeline.py --image-name operator $(IMG_BUILD_ARGS)
197196

198197
e2e-image: ## Build and push e2e test image
199-
python pipeline.py --image-name e2e
198+
python pipeline.py --image-name e2e $(IMG_BUILD_ARGS)
200199

201200
agent-image: ## Build and push agent image
202-
python pipeline.py --image-name agent
201+
python pipeline.py --image-name agent $(IMG_BUILD_ARGS)
203202

204203
readiness-probe-image: ## Build and push readiness probe image
205-
python pipeline.py --image-name readiness-probe
204+
python pipeline.py --image-name readiness-probe $(IMG_BUILD_ARGS)
206205

207206
version-upgrade-post-start-hook-image: ## Build and push version upgrade post start hook image
208-
python pipeline.py --image-name version-upgrade-hook
207+
python pipeline.py --image-name version-upgrade-hook $(IMG_BUILD_ARGS)
209208

210209
all-images: operator-image e2e-image agent-image readiness-probe-image version-upgrade-post-start-hook-image ## create all required images
211210

Diff for: docs/build_operator_locally.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ git submodule update --init
4040
```
4141

4242

43-
5. Build and deploy the operator:
43+
5. Build and deploy the operator. Also add `IMG_BUILD_ARGS=--insecure` as described [here](contributing.md#deploying-the-operator) if necessary:
4444

4545
```sh
4646
# builds all required images and then deploys the operator

Diff for: docs/contributing.md

+15-6
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ to be able to run properly. Create a json file with the following content:
5858
"repo_url": "localhost:5000",
5959
"operator_image": "mongodb-kubernetes-operator",
6060
"e2e_image": "community-operator-e2e",
61-
"version_upgrade_hook_image": "community-operator-version-upgrade-post-start-hook",
61+
"version_upgrade_hook_image": "mongodb-kubernetes-operator-version-upgrade-post-start-hook",
6262
"agent_image": "mongodb-agent-ubi-dev",
63-
"readiness_probe_image": "mongodb-kubernetes-readiness",
63+
"readiness_probe_image": "mongodb-kubernetes-readinessprobe",
6464
"s3_bucket": ""
6565
}
6666
```
@@ -132,6 +132,14 @@ make operator-image deploy
132132

133133
This will build and deploy the operator to namespace specified in your configuration file.
134134

135+
If you are using a local docker registry you should run the following command.
136+
The additional `IMG_BUILD_ARGS=--insecure` variable will add the `--insecure` flag to the command creating the manifests.
137+
This is necessary if your local registry is not secure. Read more about the flag on the [documentatio](https://docs.docker.com/reference/cli/docker/manifest/#working-with-insecure-registries)
138+
139+
```sh
140+
IMG_BUILD_ARGS=--insecure make operator-image deploy
141+
```
142+
135143

136144
#### See the operator deployment
137145
```sh
@@ -149,7 +157,7 @@ To remove the operator and any created resources you can run
149157
make undeploy
150158
```
151159

152-
Alternatively, you can run the operator locally with
160+
Alternatively, you can run the operator locally. Make sure you follow the steps outlined in [run-operator-locally.md](run-operator-locally.md)
153161

154162
```sh
155163
make run
@@ -168,7 +176,8 @@ make test
168176
### E2E Tests
169177

170178
If this is the first time running E2E tests, you will need to ensure that you have built and pushed
171-
all images required by the E2E tests. You can do this by running.
179+
all images required by the E2E tests. You can do this by running the following command,
180+
or with the additional `IMG_BUILD_ARGS=--insecure` described above.
172181

173182
```sh
174183
make all-images
@@ -180,7 +189,7 @@ For subsequent tests you can use
180189
make e2e-k8s test=<test-name>
181190
```
182191

183-
This will only re-build the e2e test image.
192+
This will only re-build the e2e test image. Add `IMG_BUILD_ARGS=--insecure` if necessary
184193

185194
We have built a simple mechanism to run E2E tests on your cluster using a runner
186195
that deploys a series of Kubernetes objects, runs them, and awaits for their
@@ -199,7 +208,7 @@ replica_set_scale
199208
...
200209
```
201210

202-
The tests should run individually using the runner like this:
211+
The tests should run individually using the runner like this, or additionally with `IMG_BUILD_ARGS=--insecure`:
203212

204213
```sh
205214
make e2e-k8s test=replica_set

Diff for: docs/run-operator-locally.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,23 @@ Being able to run and build the binary locally can help with faster feedback-cyc
1818
- Run e2e tests locally
1919

2020
## Running The Operator locally
21-
1. Use the dedicated make target which exports the needed environment variables and builds & runs the operator binary
22-
23-
```sh
24-
make run
25-
```
21+
1. Use the dedicated make target which exports the needed environment variables and builds & runs the operator binary.
22+
23+
Before doing that you need to add 2 more fields to the `config.json` file found in [contributing.md](contributing.md), because the python script looks for them in the file:
24+
- `mdb_local_operator`: needs to be set to `true`, to allow for the operator to be run locally
25+
- `kubeconfig`: needs to be set to the path of the `kubeconfig` configuration file, for example `$HOME/.kube/config`
26+
27+
Then you can run the command:
28+
29+
```sh
30+
make run
31+
```
2632

2733
2. For debugging one can use the following make target, which uses [dlv](https://github.com/go-delve/delve):
2834

29-
```sh
30-
make debug
31-
```
35+
```sh
36+
make debug
37+
```
3238

3339
## Running e2e tests with the local operator
3440
- Our [e2e tests](../test/e2e), contains sub-steps that will install the following helm-chart: [operator.yaml](../helm-charts/charts/community-operator/templates/operator.yaml)

Diff for: inventory.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ images:
99
vars:
1010
context: .
1111
template_context: scripts/dev/templates/agent
12-
# Default values but overwritten in pipeline.py
13-
agent_distro: rhel7_x86_64
14-
tools_distro: rhel70-x86_64
1512

1613
inputs:
1714
- release_version
@@ -83,8 +80,8 @@ images:
8380
buildargs:
8481
agent_version: $(inputs.params.release_version)
8582
tools_version: $(inputs.params.tools_version)
86-
agent_distro: rhel7_x86_64
87-
tools_distro: rhel70-x86_64
83+
agent_distro: $(inputs.params.agent_distro)
84+
tools_distro: $(inputs.params.tools_distro)
8885

8986
labels:
9087
quay.expires-after: Never

Diff for: pipeline.py

+13-5
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def build_and_push_image(
8787
architectures: Set[str],
8888
release: bool,
8989
sign: bool,
90+
insecure: bool = False,
9091
) -> None:
9192
if sign:
9293
mongodb_artifactory_login()
@@ -119,16 +120,18 @@ def build_and_push_image(
119120
else:
120121
raise Exception("Dev image must be specified")
121122

122-
push_manifest(config, architectures, image_to_push)
123+
push_manifest(config, architectures, image_to_push, insecure)
123124

124125
if config.gh_run_id:
125-
push_manifest(config, architectures, image_to_push, config.gh_run_id)
126+
push_manifest(config, architectures, image_to_push, insecure, config.gh_run_id)
126127

127128
if release:
128129
registry = args["registry"] + "/" + args["image"]
129130
context_tag = args["release_version"] + "-context"
130-
push_manifest(config, architectures, args["image"], args["release_version"])
131-
push_manifest(config, architectures, args["image"], context_tag)
131+
push_manifest(
132+
config, architectures, args["image"], insecure, args["release_version"]
133+
)
134+
push_manifest(config, architectures, args["image"], insecure, context_tag)
132135
if sign:
133136
sign_and_verify(registry, args["release_version"])
134137
sign_and_verify(registry, context_tag)
@@ -149,6 +152,7 @@ def push_manifest(
149152
config: DevConfig,
150153
architectures: Set[str],
151154
image_name: str,
155+
insecure: bool = False,
152156
image_tag: str = "latest",
153157
) -> None:
154158
logger.info(f"Pushing manifest for {image_tag}")
@@ -164,6 +168,9 @@ def push_manifest(
164168
final_manifest,
165169
]
166170

171+
if insecure:
172+
create_args.append("--insecure")
173+
167174
for arch in architectures:
168175
create_args.extend(["--amend", final_manifest + "-" + arch])
169176

@@ -220,6 +227,7 @@ def _parse_args() -> argparse.Namespace:
220227
)
221228
parser.add_argument("--tag", type=str)
222229
parser.add_argument("--sign", action="store_true", default=False)
230+
parser.add_argument("--insecure", action="store_true", default=False)
223231
return parser.parse_args()
224232

225233

@@ -277,7 +285,7 @@ def main() -> int:
277285
image_args = build_image_args(config, image_name)
278286

279287
build_and_push_image(
280-
image_name, config, image_args, arch_set, args.release, args.sign
288+
image_name, config, image_args, arch_set, args.release, args.sign, args.insecure
281289
)
282290
return 0
283291

Diff for: scripts/dev/setup_kind_cluster.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ EOF
9797

9898
if [[ "${export_kubeconfig}" == "1" ]]; then
9999
kind export kubeconfig --name "${cluster_name}"
100-
fi
100+
fi

0 commit comments

Comments
 (0)