provider-dummy is a minimal Crossplane Provider
that is meant to be used as an experimentation bed while developing Crossplane
providers. It includes a simple server implementation to
be used as its external API.
server-dummy exposes a single /robots endpoint to interact with robots. It
stores the data in memory and does not persist it. See example curl commands
to run by running go run cmd/server/main.go.
There are three ways you can use this provider:
- Embedded: By default, the server is started as a background process when the provider image is run. You can use that embedded server by pointing the provider to talk to its localhost.
- Local: Deploying the provider to a Crossplane-installed cluster and running the server in the same cluster or a publicly accessible cluster.
- No-op: Deploying the provider to a Crossplane control plane in no-op mode and then deploying the controller and server to a different cluster that may or may not be publicly accessible.
The server is started as a background process when the provider image is run so the only configuration we need is to point the provider to use that server.
cat <<EOF | kubectl apply -f -
apiVersion: dummy.upbound.io/v1alpha1
kind: ProviderConfig
metadata:
name: default
spec:
endpoint: http://127.0.0.1:9090
EOFIn cases where the provider needs to make API calls to endpoints that are not available to your control plane, you can deploy the provider in no-op mode and deploy its controller separately to a cluster that can reach the external API.
For every versioned release of the provider, there is a corresponding no-op
package published with -noop suffix. For example, you can install the no-op
variant of v0.3.0 by using v0.3.0-noop image tag.
See this end to end guide for more details.
In this setup, both the fully operational provider and the server are deployed to the same Crossplane-installed cluster.
You can install the provider in your cluster by running the following command:
cat <<EOF | kubectl apply -f -
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-dummy
spec:
package: xpkg.upbound.io/upbound/provider-dummy:v0.3.0
EOFDeploy the server to crossplane-system namespace:
kubectl -n crossplane-system apply -f cluster/server-deployment.yamlConfigure the provider to talk to the server:
cat <<EOF | kubectl apply -f -
apiVersion: dummy.upbound.io/v1alpha1
kind: ProviderConfig
metadata:
name: default
spec:
endpoint: http://server-dummy.default.svc.cluster.local
EOFThe provider image already includes the server and it's built just like any other
Crossplane provider that uses upbound/build submodule. To build the provider,
run the following:
make buildIf you'd like to build & push a separate image of the server (useful for no-op and local modes), you can use the following command:
cd cmd/server
docker build -t upbound/server-dummy:latest .# This will build two images: provider-dummy and server-dummy.
make buildkind create cluster --wait 5m# This will deploy server-dummy and port-forward its service to localhost:9090.
# And start the provider-dummy controller locally to connect to the server.
make dev# Create your first Robot!
kubectl apply -f examples/iam/robots.yamlkubectl get robots- Create a new release branch from
mainbranch with minor version, i.e.release-0.3, using the Github UI. - Run
Tagaction in the release branch with the full version, i.e.v0.3.0. - Run
CIaction in the release branch to build and push the images. - Create another release branch called
release-0.3-noopbut this time forked from the earlier release branch, i.e.release-0.3->release-0.3-noop. - Check out
release-0.3-noopand disable the provider by default by making theapp.Flag("do-nothing", "Do nothing.").Default("false") ...line toapp.Flag("do-nothing", "Do nothing.").Default("true") .... - Push the new commit only to
release-0.3-noopbranch. - Run
Tagaction in the noop release branch with the full version, i.e.v0.3.0-noop. - Run
CIaction in the noop release branch to build and push the noop images.
Done!