Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add load-pkg to the makefile and add the development guide link to README #361

Merged
merged 6 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,53 @@ go.cachedir:
go.mod.cachedir:
@go env GOMODCACHE

.PHONY: cobertura reviewable submodules fallthrough go.mod.cachedir go.cachedir run crds.clean $(TERRAFORM_PROVIDER_SCHEMA)
DEP_CONSTRAINT ?= >= 0.0.0
ifeq (-,$(findstring -,$(VERSION)))
DEP_CONSTRAINT = >= 0.0.0-0
endif
# Define SUBPACKAGES variable and set its value from PROVIDERS
SUBPACKAGES := $(PROVIDERS)
# Define XPKG_REG_ORGS variable and set its value from REPO
XPKG_REG_ORGS := $(REPO)
load-pkg: $(UP) build.all
turkenf marked this conversation as resolved.
Show resolved Hide resolved
turkenf marked this conversation as resolved.
Show resolved Hide resolved
@$(INFO) Loading the family providers into the Docker daemon: $(SUBPACKAGES)
@for p in $(PLATFORMS); do \
mkdir -p "$(XPKG_OUTPUT_DIR)/$$p"; \
done
@$(UP) xpkg batch --smaller-providers $$(echo -n "$(SUBPACKAGES) config" | tr ' ' ',') \
--family-base-image $(BUILD_REGISTRY)/$(PROJECT_NAME) \
--platform $(BATCH_PLATFORMS) \
--provider-name $(PROJECT_NAME) \
--family-package-url-format $(XPKG_REG_ORGS)/%s:$(VERSION) \
--package-repo-override monolith=$(PROJECT_NAME) --package-repo-override config=provider-family-$(PROVIDER_NAME) \
--provider-bin-root $(OUTPUT_DIR)/bin \
--output-dir $(XPKG_OUTPUT_DIR) \
--store-packages $$(echo -n "$(SUBPACKAGES) config" | tr ' ' ',') \
--build-only=true \
--examples-root $(ROOT_DIR)/examples \
--examples-group-override monolith=* --examples-group-override config=providerconfig \
--auth-ext $(ROOT_DIR)/package/auth.yaml \
--crd-root $(ROOT_DIR)/package/crds \
--crd-group-override monolith=* --crd-group-override config=$(PROVIDER_NAME) \
--package-metadata-template $(ROOT_DIR)/package/crossplane.yaml.tmpl \
--template-var XpkgRegOrg=$(XPKG_REG_ORGS) --template-var DepConstraint="$(DEP_CONSTRAINT)" --template-var ProviderName=$(PROVIDER_NAME) \
--push-retry 10 || $(FAIL)

@for p in $(PLATFORMS); do \
docker tag $$(docker load -qi $(XPKG_OUTPUT_DIR)/$$p/$(PROJECT_NAME)-config-$(VERSION).xpkg | awk -F: '{print $$3}') $(XPKG_REG_ORGS)/provider-family-$(PROVIDER_NAME)-$${p#"linux_"}:$(VERSION); \
echo Loaded the provider package "provider-family-$(PROVIDER_NAME)-$${p#"linux_"}:$(VERSION)" into the Docker daemon; \
for s in $(SUBPACKAGES); do \
if [ "$$s" = "config" ]; then \
continue; \
fi; \
docker tag $$(docker load -qi $(XPKG_OUTPUT_DIR)/$$p/$(PROJECT_NAME)-$$s-$(VERSION).xpkg | awk -F: '{print $$3}') $(XPKG_REG_ORGS)/$(PROJECT_NAME)-$$s-$${p#"linux_"}:$(VERSION); \
turkenf marked this conversation as resolved.
Show resolved Hide resolved
echo Loaded the provider package "$(PROJECT_NAME)-$$s-$${p#"linux_"}:$(VERSION)" into the Docker daemon; \
done \
done

@$(OK) Loaded the family providers into the Docker daemon: $(SUBPACKAGES)

.PHONY: cobertura reviewable submodules fallthrough go.mod.cachedir go.cachedir run crds.clean $(TERRAFORM_PROVIDER_SCHEMA) load-pkg

build.init: kustomize-crds

Expand Down
24 changes: 21 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ SPDX-License-Identifier: CC-BY-4.0

</div>

`provider-gcp` is a [Crossplane](https://crossplane.io/) provider that
Provider GCP is a [Crossplane](https://crossplane.io/) provider that
is built using [Upjet](https://github.com/crossplane/upjet) code
generation tools and exposes XRM-conformant managed resources for the
GCP API.
Expand All @@ -41,14 +41,32 @@ If you'd like to learn how to use Upjet, see [Usage Guide](https://github.com/cr

Follow the guide [here](https://github.com/crossplane/upjet/blob/v0.10.0/docs/add-new-resource-short.md).

### Local Development

1. Check out the provider repo, crossplane-contrib/provider-upjet-gcp, and go to the project
directory on your local machine.

2. Do the necessary changes locally and please make sure you have comitted all of them.

3. Run the `make load-pkg` command for family providers as follows.

If you want to build any of the family resource providers (e.g., `provider-gcp-cloudplatform`, `provider-gcp-container`), you can do:

```shell
make load-pkg PROVIDERS="cloudplatform container" REPO="index.docker.io/<your-dockerhub-org>"
```
*Note: Installable images for the family config provider will be created by default.*

For more information, follow the guide [here](https://marketplace.upbound.io/providers/upbound/provider-family-gcp/latest/docs/development).

## Report a Bug

For filing bugs, suggesting improvements, or requesting new features, please
open an [issue](https://github.com/crossplane-contrib/provider-upjet-gcp/issues).
open an [issue](https://github.com/crossplane-contrib/provider-upjet-gcp/issues/new/choose).

## Contact

[#upbound-provider-gcp](https://crossplane.slack.com/archives/C05E7EVM459) channel in
[#upjet-provider-gcp](https://crossplane.slack.com/archives/C05E7EVM459) channel in
[Crossplane Slack](https://slack.crossplane.io)

## Licensing
Expand Down
108 changes: 108 additions & 0 deletions docs/family/Development.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
title: Development
weight: 3
---

# Building the Official Provider Family Images Locally

1. Check out the provider repo, crossplane-contrib/provider-upjet-gcp, and go to the project
directory on your local machine.

2. Do the necessary changes locally and please make sure you have comitted all of them.

3. Run the `make load-pkg` command for family providers as follows.

If you want to build any of the family resource providers (e.g., `provider-gcp-cloudplatform`, `provider-gcp-container`), you can do:

```shell
make load-pkg PROVIDERS="cloudplatform container" REPO="index.docker.io/<your-dockerhub-org>"
```
*Note: Installable images for the family config provider will be created by default.*

After the command is completed, you will see the installable images for `provider-gcp-cloudplatform`, `provider-gcp-container`
and family config provider `provider-family-gcp`:

```shell
> docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
turkenf/provider-family-gcp-amd64 v1.1.0-rc.0.42.g42cf069b9 baac1f7e697d 6 minutes ago 179MB
turkenf/provider-gcp-cloudplatform-amd64 v1.1.0-rc.0.42.g42cf069b9 fe2106877bf9 6 minutes ago 181MB
turkenf/provider-gcp-container-amd64 v1.1.0-rc.0.42.g42cf069b9 94f8d11c2709 6 minutes ago 181MB
turkenf/provider-gcp-cloudplatform-arm64 v1.1.0-rc.0.42.g42cf069b9 edbf18e9d01f 6 minutes ago 176MB
turkenf/provider-gcp-container-arm64 v1.1.0-rc.0.42.g42cf069b9 0d3ab205ef66 6 minutes ago 176MB
turkenf/provider-family-gcp-arm64 v1.1.0-rc.0.42.g42cf069b9 a6ef52d83555 6 minutes ago 175MB
```

## Running Providers with Locally Built Images

One way to install locally built images is pushing them to Dockerhub and installing from there. For example, if you want to
install the `cloudplatform` package on a arm64 arch:

1. Push provider images to Dockerhub:

```shell
# push the images to your dockerhub org
docker push <your-dockerhub-org>/provider-family-gcp-arm64:v1.1.0-rc.0.42.g42cf069b9
docker push <your-dockerhub-org>/provider-gcp-cloudplatform-arm64:v1.1.0-rc.0.42.g42cf069b9
```

2. Install the provider packages by setting `skipDependencyResolution: true` with the following yaml:

```yaml
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: upbound-provider-gcp-config
spec:
package: index.docker.io/turkenf/provider-family-gcp-arm64:v1.1.0-rc.0.42.g42cf069b9
skipDependencyResolution: true
---
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: upbound-provider-gcp-cloudplatform
spec:
package: index.docker.io/turkenf/provider-gcp-cloudplatform-arm64:v1.1.0-rc.0.42.g42cf069b9
skipDependencyResolution: true
```
3. Verify that providers are installed and healthy:
```shell
> kubectl get providers.pkg.crossplane.io
NAME INSTALLED HEALTHY PACKAGE AGE
upbound-provider-gcp-cloudplatform True True index.docker.io/turkenf/provider-gcp-cloudplatform-arm64:v1.1.0-rc.0.42.g42cf069b9 115s
upbound-provider-gcp-config True True index.docker.io/turkenf/provider-family-gcp-arm64:v1.1.0-rc.0.42.g42cf069b9 115s
```

*Note: If you don't want to set `skipDependencyResolution: true`, please follow the steps below:*

- Tag the family config provider image as provider-family-gcp

```shell
# get rid of the arch to resolve package dependencies
docker tag <your-dockerhub-org>/provider-family-gcp-arm64:v1.1.0-rc.0.42.g42cf069b9 <your-dockerhub-org>/provider-family-gcp:v1.1.0-rc.0.42.g42cf069b9
# push the images to your dockerhub org
docker push <your-dockerhub-org>/provider-family-gcp:v1.1.0-rc.0.42.g42cf069b9
docker push <your-dockerhub-org>/provider-gcp-cloudplatform-arm64:v1.1.0-rc.0.42.g42cf069b9
```

- Install the provider package:

```yaml
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: upbound-provider-gcp-cloudplatform
spec:
package: index.docker.io/turkenf/provider-gcp-cloudplatform-arm64:v1.1.0-rc.0.42.g42cf069b9
```
- Verify that providers are installed and healthy:
```shell
> kubectl get providers.pkg.crossplane.io
NAME INSTALLED HEALTHY PACKAGE AGE
turkenf-provider-family-gcp True True index.docker.io/turkenf/provider-family-gcp:v1.1.0-rc.0.42.g42cf069b9 73s
upbound-provider-gcp-cloudplatform True True index.docker.io/turkenf/provider-gcp-cloudplatform-arm64:v1.1.0-rc.0.42.g42cf069b9 2m1s
```
Loading