Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin' into improve-unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lubedacht committed Jun 17, 2024
2 parents ecce5de + 0cfa945 commit 6a4116d
Show file tree
Hide file tree
Showing 35 changed files with 7,317 additions and 88 deletions.
7 changes: 5 additions & 2 deletions .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ Release vX.X.X
## Checklist

- [ ] Update metadata & clusterctl-settings.
- [ ] Update version in e2e config.
- [ ] Update docs (compatibility table; usage etc).
- [ ] Create tag.
- [ ] Create release branch `release-X.Y`
- [ ] Create tag `vX.Y.Z`.
- [ ] Update the created draft release to include things like breaking changes or important notes.
- [ ] Publish the release.
- [ ] Update the draft release notes with generated release notes from `sigs.k8s.io/kubebuilder-release-tools/notes`
- [ ] Publish the release.
31 changes: 31 additions & 0 deletions .github/workflows/conformance-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Conformance end-to-end tests
on:
schedule:
- cron: "0 5 * * 1"
workflow_dispatch: {}
jobs:
conformance-e2e:
runs-on: ubuntu-latest
environment: e2e
env:
IONOS_TOKEN: ${{ secrets.IONOS_TOKEN }}
IONOSCLOUD_MACHINE_IMAGE_ID: ${{ vars.IONOSCLOUD_MACHINE_IMAGE_ID }}
CONTROL_PLANE_ENDPOINT_LOCATION: ${{ vars.CONTROL_PLANE_ENDPOINT_LOCATION }}
steps:
- uses: actions/checkout@v4

- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Run e2e tests
run: make GINKGO_LABEL="Conformance" test-e2e

- name : Upload artifacts
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: logs
path: _artifacts
retention-days: 7
64 changes: 64 additions & 0 deletions .github/workflows/e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: End-to-end tests
on:
pull_request_target:
types: ["opened", "synchronize", "reopened", "labeled", "unlabeled" ]
branches: [ "main" ]
paths:
- "**.go"
- "**.ya?ml"
- "**.sh"
- "Dockerfile"
- "Makefile"
push:
branches:
- main
paths:
- "**.go"
- "**.ya?ml"
- "**.sh"
- "Dockerfile"
- "Makefile"
jobs:
e2e:
if: ${{ ! contains( github.event.pull_request.labels.*.name, 'skip e2e') }}
runs-on: ubuntu-latest
environment: e2e
env:
IONOS_TOKEN: ${{ secrets.IONOS_TOKEN }}
IONOSCLOUD_MACHINE_IMAGE_ID: ${{ vars.IONOSCLOUD_MACHINE_IMAGE_ID }}
CONTROL_PLANE_ENDPOINT_LOCATION: ${{ vars.CONTROL_PLANE_ENDPOINT_LOCATION }}
steps:
- name: Check out branch ${{ github.ref }}
if: ${{ github.event_name == 'push' }}
uses: actions/checkout@v4

- name: Check out PR ${{ github.event.pull_request.number }}
if: ${{ github.event_name == 'pull_request_target' }}
uses: actions/checkout@v4
with:
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}

- name: Setup Go environment
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Run e2e tests
id: tests
run: make test-e2e

- name: Upload artifacts
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: logs
path: _artifacts
retention-days: 7

- name: Remove cancelled run leftovers
if: cancelled()
env:
DATACENTER_ID: ${{ steps.tests.outputs.DATACENTER_ID }}
IP_BLOCK_ID: ${{ steps.tests.outputs.IP_BLOCK_ID }}
run: make remove-cancelled-e2e-leftovers
7 changes: 1 addition & 6 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@ on:
- main
pull_request:

# don't waste resources and time on outdated commits
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true

jobs:
verify:
runs-on: ubuntu-latest
Expand All @@ -21,4 +16,4 @@ jobs:
with:
go-version-file: go.mod
- name: Run verifications
run: make verify
run: make verify
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,8 @@ cluster.yaml
# release
out/

#testing stuff
clusterctl-settings.json
# e2e tests
_artifacts/

# crs
templates/crs/cni/calico.yaml
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,11 @@ linters-settings:
# Controller Runtime
- pkg: sigs.k8s.io/controller-runtime
alias: ctrl
# Cluster API
- pkg: sigs.k8s.io/cluster-api/api/v1beta1
alias: clusterv1
- pkg: "sigs.k8s.io/cluster-api/test/e2e"
alias: capie2e
# Own module
- pkg: github.com/ionos-cloud/cluster-api-provider-ionoscloud/api/v1alpha1
alias: infrav1
Expand Down
70 changes: 68 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

# Image URL to use all building/pushing image targets
IMG ?= controller:latest
IMG ?= controller:dev
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.28.0
ENVTEST_K8S_VERSION = 1.29.5

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
Expand Down Expand Up @@ -249,3 +249,69 @@ release-manifests: $(KUSTOMIZE) ## Create kustomized release manifest in $RELEAS
release-templates: ## Generate release templates
@mkdir -p $(RELEASE_DIR)
cp templates/cluster-template*.yaml $(RELEASE_DIR)/


##@ CRS
## --------------------------------------
## CRS
## --------------------------------------

CALICO_VERSION ?= v3.26.3

.PHONY: crs-calico
crs-calico: ## Generates crs manifests for Calico.
curl -o templates/crs/cni/calico.yaml https://raw.githubusercontent.com/projectcalico/calico/$(CALICO_VERSION)/manifests/calico.yaml

##@ End-to-End Tests

# Directories.
#
# Full directory of where the Makefile resides
ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
TEST_DIR := test
ARTIFACTS ?= ${ROOT_DIR}/_artifacts


E2E_CONF_FILE ?= $(ROOT_DIR)/$(TEST_DIR)/e2e/config/ionoscloud.yaml
SKIP_RESOURCE_CLEANUP ?= false
USE_EXISTING_CLUSTER ?= false

GINKGO_POLL_PROGRESS_AFTER ?= 10m
GINKGO_POLL_PROGRESS_INTERVAL ?= 1m
GINKGO_NODES ?= 1
GINKGO_FOCUS ?=
GINKGO_TIMEOUT ?= 2h
GINKGO_NOCOLOR ?= false
GINKGO_LABEL ?= "!Conformance"

GINKGO_SKIP ?=
# To set multiple ginkgo skip flags, if any
ifneq ($(strip $(GINKGO_SKIP)),)
_SKIP_ARGS := $(foreach arg,$(strip $(GINKGO_SKIP)),-skip="$(arg)")
endif

.PHONY: docker-build-e2e
docker-build-e2e: ## Build docker image with the manager.
$(CONTAINER_TOOL) build -t ghcr.io/ionos-cloud/cluster-api-provider-ionoscloud:e2e .

.PHONY: test-e2e
test-e2e: docker-build-e2e ## Run the end-to-end tests
CGO_ENABLED=1 go run github.com/onsi/ginkgo/v2/ginkgo -v --trace \
-poll-progress-after=$(GINKGO_POLL_PROGRESS_AFTER) \
-poll-progress-interval=$(GINKGO_POLL_PROGRESS_INTERVAL) --tags=e2e --focus="$(GINKGO_FOCUS)" --fail-fast \
$(_SKIP_ARGS) --nodes=$(GINKGO_NODES) --label-filter=$(GINKGO_LABEL) --timeout=$(GINKGO_TIMEOUT) --no-color=$(GINKGO_NOCOLOR) \
--output-dir="$(ARTIFACTS)" --junit-report="junit.e2e_suite.1.xml" $(GINKGO_ARGS) $(ROOT_DIR)/$(TEST_DIR)/e2e -- \
-e2e.artifacts-folder="$(ARTIFACTS)" -e2e.config="$(E2E_CONF_FILE)" \
-e2e.skip-resource-cleanup=$(SKIP_RESOURCE_CLEANUP) -e2e.use-existing-cluster=$(USE_EXISTING_CLUSTER)

.PHONY: ionosctl
ionosctl: $(LOCALBIN) ## Download the latest release of ionosctl and add to the bin folder
@if [ ! -f $(LOCALBIN)/ionosctl ]; then \
LATEST_RELEASE_TAG=$$(curl -sI https://github.com/ionos-cloud/ionosctl/releases/latest | grep -Fi Location | sed -E 's/.*\/tag\/v(.*)/\1/' | tr -d '\r'); \
IONOSCTL_DOWNLOAD_URL="https://github.com/ionos-cloud/ionosctl/releases/download/v$${LATEST_RELEASE_TAG}/ionosctl-$${LATEST_RELEASE_TAG}-linux-amd64.tar.gz"; \
curl -sL $$IONOSCTL_DOWNLOAD_URL | tar xz -C $(LOCALBIN) ionosctl; \
fi

.PHONY: remove-cancelled-e2e-leftovers
remove-cancelled-e2e-leftovers: $(ionosctl) ## Remove any leftover resources from cancelled e2e tests
$(ROOT_DIR)/hack/scripts/cancelled-workflow.sh
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,15 @@ If you need help with CAPIC, please visit the [#cluster-api-ionoscloud][slack] c

## Compatibility

### Cluster API Versions (TODO)
### Cluster API Versions

### Kubernetes Versions (TODO)
This provider's versions are compatible with the following versions of Cluster API:

| | Cluster API v1beta1 (v1.7) |
|------------------------|:--------------------------:|
| CAPIC v1alpha1 (v0.2) ||

### Kubernetes Versions

The IONOS Cloud provider is able to install and manage the [versions of Kubernetes supported by the Cluster API (CAPI) project](https://cluster-api.sigs.k8s.io/reference/versions.html#supported-kubernetes-versions).

Expand Down
7 changes: 7 additions & 0 deletions clusterctl-settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "infrastructure-ionoscloud",
"config": {
"componentsFile": "infrastructure-components.yaml",
"nextVersion": "v0.2.0"
}
}
60 changes: 58 additions & 2 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,16 @@ KUBECONFIG=ionos-quickstart.kubeconfig kubectl get nodes

### Installing a CNI

<!-- TODO(gfariasalves): Add instructions about installing a CNI or available flavours -->
You may use our provided flavors for generating cluster with CNI, please refer to the [Cluster templates](#cluster-templates) section.

### Installing a Cloud Controller Manager
Or if your cluster does not have a CNI, you can install one manually. For example, to install Calico:

```sh
make crs-calico
kubectl apply -f templates/crs/cni/calico.yaml
```

### Installing the Cloud Controller Manager

We provide a helm chart for the Cloud Controller Manager for IONOS Cloud.
Refer to its [README](https://github.com/ionos-cloud/cloud-provider-ionoscloud/tree/main/charts/ionoscloud-cloud-controller-manager/README.md)
Expand All @@ -141,6 +148,55 @@ for detailed installation instructions.
kubectl delete cluster ionos-quickstart
```

## Cluster templates

We provide various templates for creating clusters. Some of these templates provide you with a CNI already.

For templates using `CNIs` you're required to create `ConfigMaps` to make `ClusterResourceSets` available.

To enable `ClusterResourceSets` feature,
you need to set the following environment variable before doing `clusterctl init`:

```bash
# This enables the ClusterResourceSet feature that we are using to deploy CNI
export EXP_CLUSTER_RESOURCE_SET="true"
```

We provide the following templates:

| Flavor | Template File | CRS File |
|----------------|----------------------------------------|-------------------------------|
| calico | templates/cluster-template-calico.yaml | templates/crs/cni/calico.yaml |
| default | templates/cluster-template.yaml | - |


#### Flavor with Calico CNI
Before this cluster can be deployed, `calico` needs to be configured. As a first step we
need to generate a manifest. Simply use our Makefile:

```
make crs-calico
```
Now install the ConfigMap into your k8s:

```
kubectl create cm calico --from-file=data=templates/crs/cni/calico.yaml
```

Now, you can create a cluster using the calico flavor:

```bash
$ clusterctl generate cluster dev-calico \
--infrastructure ionoscloud \
--kubernetes-version v1.28.6 \
--control-plane-machine-count 1 \
--worker-machine-count 3 \
--flavor calico > cluster.yaml
$ kubectl apply -f cluster.yaml
```

### Custom Templates

If you need anything specific that requires a more complex setup, we recommend to use custom templates:
Expand Down
Loading

0 comments on commit 6a4116d

Please sign in to comment.