Skip to content

Commit

Permalink
Merge pull request #2 from mondragonfx/master
Browse files Browse the repository at this point in the history
Generate additional Vultr resources
  • Loading branch information
happytreees authored Sep 27, 2023
2 parents a0945c2 + 9c8ece1 commit 48a6884
Show file tree
Hide file tree
Showing 83 changed files with 12,258 additions and 333 deletions.
3 changes: 0 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,10 @@ linters:
- govet
- gocyclo
- gocritic
- interfacer
- goconst
- goimports
- gofmt # We enable this as well as goimports for its simplify mode.
- prealloc
- golint
- unconvert
- misspell
- nakedret
Expand All @@ -134,7 +132,6 @@ issues:
- errcheck
- dupl
- gosec
- scopelint
- unparam

# Ease some gocritic warnings on test files.
Expand Down
96 changes: 96 additions & 0 deletions INSTALL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Building and Installing the Crossplane Vultr Provider

`provider-vultr` is composed of a golang project and can be built directly with standard `golang` tools. We currently support two different platforms for building:

* Linux: most modern distros should work although most testing has been done on Ubuntu
* Mac: macOS 10.6+ is supported

## Build Requirements

An Intel-based machine (recommend 2+ cores, 2+ GB of memory and 128GB of SSD). Inside your build environment (Docker for Mac or a VM), 6+ GB memory is also recommended.

The following tools are need on the host:

* curl
* docker (1.12+) or Docker for Mac (17+)
* git
* make
* golang
* rsync (if you're using the build container on mac)
* helm (v2.8.2+)
* kubebuilder (v1.0.4+)

## Build
You can build the Crossplane Vultr Provider for the host platform by simply running the command below.
Building in parallel with the `-j` option is recommended.

```console
make -j4
```

The first time `make` is run, the build submodule will be synced and
updated. After initial setup, it can be updated by running `make submodules`.

Run `make help` for more options.

## Building inside the cross container

Official Crossplane builds are done inside a build container. This ensures that we get a consistent build, test and release environment. To run the build inside the cross container run:

```console
build/run make -j4
```

The first run of `build/run` will build the container itself and could take a few minutes to complete, but subsequent builds should go much faster.

## Install Crossplane in Your Cluster
Once your Cluster is up and running, you'll need to install Crossplane.

We recommend using Helm to install Crossplane. You can find the [official documentation here](https://crossplane.io/docs/v1.5/getting-started/install-configure.html#install-crossplane). These are the commands:

```console
kubectl create namespace crossplane-system

helm repo add crossplane-stable https://charts.crossplane.io/stable
helm repo update

helm install crossplane --namespace crossplane-system crossplane-stable/crossplane
```

## Getting started

Next install this Vultr Crossplane provider:
```bash
# clone this repo
git clone [email protected]:vultr/crossplane-provider-vultr.git
cd provider-vultr

# install the crds
kubectl apply -f package/crds
```

Run the provider:
```bash
make run
```

Configure the provider:
```bash
# change the examples/secret.yaml to use your VULTR_API_KEY
kubectl apply -f examples/providerconfig/secret.yaml
kubectl apply -f examples/providerconfig/providerconfig.yaml
```


## Provision Vultr Resources

Go to the [examples-generated](./examples-generated) directory in this repo, find the Vultr product you'd like to deploy, make any needed changes to the yaml file, and then create the resource.

For example, if you'd like to spin up a VKE Cluster, run the command

```console
kubectl apply -f examples-generated/vultr/kubernetes.yaml
# wait a bit
kubectl get managed
```
and check your Vultr account to see if the resource has been created.
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ export TERRAFORM_VERSION ?= 1.3.3

export TERRAFORM_PROVIDER_SOURCE ?= vultr/vultr
export TERRAFORM_PROVIDER_REPO ?= https://github.com/vultr/terraform-provider-vultr
export TERRAFORM_PROVIDER_VERSION ?= 2.15.0
export TERRAFORM_PROVIDER_VERSION ?= 2.15.1
export TERRAFORM_PROVIDER_DOWNLOAD_NAME ?= terraform-provider-vultr
export TERRAFORM_NATIVE_PROVIDER_BINARY ?= terraform-provider-vultr_2.15.0
export TERRAFORM_NATIVE_PROVIDER_BINARY ?= terraform-provider-vultr_2.15.1
export TERRAFORM_DOCS_PATH ?= website/docs/r

PLATFORMS ?= linux_amd64 linux_arm64
Expand Down Expand Up @@ -39,7 +39,7 @@ NPROCS ?= 1
GO_TEST_PARALLEL := $(shell echo $$(( $(NPROCS) / 2 )))

GO_REQUIRED_VERSION ?= 1.20
GOLANGCILINT_VERSION ?= 1.50.0
GOLANGCILINT_VERSION ?= 1.54.2
GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/provider $(GO_PROJECT)/cmd/generator
GO_LDFLAGS += -X $(GO_PROJECT)/internal/version.Version=$(VERSION)
GO_SUBDIRS += cmd internal apis
Expand All @@ -49,9 +49,9 @@ GO_SUBDIRS += cmd internal apis
# Setup Kubernetes tools

KIND_VERSION = v0.15.0
UP_VERSION = v0.14.0
UP_VERSION = v0.18.0
UP_CHANNEL = stable
UPTEST_VERSION = v0.2.1
UPTEST_VERSION = v0.5.0
-include build/makelib/k8s_tools.mk

# ====================================================================================
Expand Down Expand Up @@ -198,4 +198,4 @@ crossplane.help:

help-special: crossplane.help

.PHONY: crossplane.help help-special
.PHONY: crossplane.help help-special
90 changes: 51 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,68 @@ is built using [Upjet](https://github.com/upbound/upjet) code
generation tools and exposes XRM-conformant managed resources for the
Vultr API.

## Getting Started
## Overview

Install the provider by using the following command after changing the image tag
to the [latest release](https://marketplace.upbound.io/providers/crossplane-contrib/provider-vultr):
```
up ctp provider install crossplane-contrib/provider-vultr:v0.1.0
```
This `provider-vultr` repository is the Crossplane infrastructure provider for
[vultr](https://vultr.com/). The provider that is built from
the source code in this repository can be installed into a Crossplane control
plane and adds the following new functionality:

Alternatively, you can use declarative installation:
```
cat <<EOF | kubectl apply -f -
apiVersion: pkg.crossplane.io/v1
kind: Provider
metadata:
name: provider-vultr
spec:
package: crossplane-contrib/provider-vultr:v0.1.0
EOF
```
* Custom Resource Definitions (CRDs) that model vultr infrastructure and managed
services (e.g. [Vultr Kubernetes Engine](https://www.vultr.com/kubernetes/), [Vultr Loadbalancers](https://www.vultr.com/products/load-balancers/),
etc.)
* Controllers to provision these resources in vultr based on the users desired
state captured in CRDs they create
* Implementations of Crossplane's portable resource abstractions, enabling vultr
resources to fulfill a user's general need for cloud services

Notice that in this example Provider resource is referencing ControllerConfig with debug enabled.
## Getting Started and Documentation

You can see the API reference [here](https://doc.crds.dev/github.com/crossplane-contrib/provider-vultr).
For getting started guides, installation, deployment, and administration, see
our [Documentation](https://crossplane.io/docs/latest).

## Developing
## Contributing

Run code-generation pipeline:
```console
go run cmd/generator/main.go "$PWD"
```
provider-vultr is a community driven project and we welcome contributions. See
the Crossplane
[Contributing](https://github.com/crossplane/crossplane/blob/master/CONTRIBUTING.md)
guidelines to get started.

Run against a Kubernetes cluster:
## Report a Bug

```console
make run
```
For filing bugs, suggesting improvements, or requesting new features, please
open an [issue](https://github.com/vultr/crossplane-provider-vultr/issues).

Build, push, and install:
## Contact

```console
make all
```
Please use the following to reach members of the community:

Build binary:
- Slack: Join our [slack channel](https://slack.crossplane.io)
- Forums:
[crossplane-dev](https://groups.google.com/forum/#!forum/crossplane-dev)
- Twitter: [@crossplane_io](https://twitter.com/crossplane_io)
- Email: [[email protected]](mailto:[email protected])

```console
make build
```
## Roadmap

## Report a Bug
provider-vultr goals and milestones are currently tracked in the Crossplane
repository. More information can be found in
[ROADMAP.md](https://github.com/crossplane/crossplane/blob/master/ROADMAP.md).

## Governance and Owners

provider-vultr is run according to the same
[Governance](https://github.com/crossplane/crossplane/blob/master/GOVERNANCE.md)
and [Ownership](https://github.com/crossplane/crossplane/blob/master/OWNERS.md)
structure as the core Crossplane project.

## Code of Conduct

provider-vultr adheres to the same [Code of
Conduct](https://github.com/crossplane/crossplane/blob/master/CODE_OF_CONDUCT.md)
as the core Crossplane project.

## Licensing

provider-vultr is under the Apache 2.0 license.

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 48a6884

Please sign in to comment.