Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
porridge authored Nov 27, 2023
2 parents e97b4eb + 0b89adc commit 97a6c16
Show file tree
Hide file tree
Showing 50 changed files with 830 additions and 786 deletions.
53 changes: 0 additions & 53 deletions .circleci/config.yml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/e2e.yml

This file was deleted.

14 changes: 7 additions & 7 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ name: "Integration tests"

on:
push:
branches: [ main ]
branches:
- main
- releases/*
pull_request:
branches: [ main ]
branches:
- main
- releases/*

jobs:
integration-tests:
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-go@v2.1.4
with:
go-version: 1.18
go-version: 1.21
- uses: actions/checkout@v2.4.0
- name: "Install etcd"
run: ./hack/install-etcd.sh
- name: "Install kube-apiserver"
run: ./hack/install-kube-apiserver.sh
- name: "Run integration tests"
run: make integration-test INTEGRATION_OUTPUT_JUNIT="true"
10 changes: 7 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ name: "Lint code"

on:
push:
branches: [ main ]
branches:
- main
- releases/*
pull_request:
branches: [ main ]
branches:
- main
- releases/*

jobs:
lint:
runs-on: ubuntu-20.04
steps:
- uses: actions/setup-go@v2.1.4
with:
go-version: 1.18
go-version: 1.21
- uses: actions/checkout@v2.4.0
- name: "Lint the code"
run: make lint
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@ name: "Unit tests"

on:
push:
branches: [ main ]
branches:
- main
- releases/*
pull_request:
branches: [ main ]
branches:
- main
- releases/*

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v2.1.4
with:
go-version: 1.18
go-version: 1.21
- uses: actions/checkout@v2.4.0
- name: "Run unit tests"
run: make test
79 changes: 27 additions & 52 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ You can find the full text of the DCO here: https://developercertificate.org/

- Git
- Go `1.18` or later. Note that some [Makefile](Makefile) targets assume that your `$GOBIN` is in your `$PATH`.
- [Kubebuilder](https://book.kubebuilder.io/quick-start.html#installation) version 2 or later - note that it is only needed for the `kube-apiserver` and `etcd` binaries, so no need to install *its* dependencies (such as `kustomize`).
- A Kubernetes Cluster running version `1.19` or later (e.g., [kind](https://kind.sigs.k8s.io/) or [Minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/))
- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)

Expand Down Expand Up @@ -67,57 +66,6 @@ For the build to work you need proper version of `controller-gen` to be installe

After the correct controller-gen version is installed. All future builds will work. The only time this work-around is necessary is if/when the controller-tools version is updated. [The fix](https://go-review.googlesource.com/c/sys/+/274573/) has been merged into Go and should be resolved with go 1.18.1.


#### Kubebuilder Envtest

The pre-requisite for kubebuilder is for the [envtest](https://book.kubebuilder.io/reference/envtest.html). It is used for the integration-tests, testing against kube-apiserver and etcd. This has been complicated with Apple Silicon and process hanging etc. The installation has changed a lot since the start of this project and is a common issue getting started. The current use of `envtest` is to have `KUBEBUILDER_ASSETS` env variable set to the location of etcd and kube-apiserver. For help regarding this, we found Makefile which can help.

```Makefile
.PHONY: all clean

OS := $(shell uname)

ifeq ($(OS),Linux)
kernel := linux
tar_wildcards := --wildcards
endif
ifeq ($(OS),Darwin)
kernel := darwin
tar_wildcards :=
endif

all: etcd kubectl kube-apiserver

clean:
rm -f etcd
rm -f kubectl
rm -f kube-apiserver

etcd:
ifeq ($(OS),Linux)
curl -Ls https://github.com/etcd-io/etcd/releases/download/v3.5.0/etcd-v3.5.0-$(kernel)-amd64.tar.gz \
| tar zxv --strip-components=1 $(tar_wildcards) "*/etcd"
endif
ifeq ($(OS), Darwin)
curl -LO https://github.com/etcd-io/etcd/releases/download/v3.4.16/etcd-v3.4.16-darwin-amd64.zip
unzip etcd-v3.4.16-darwin-amd64.zip
cp etcd-v3.4.16-darwin-amd64/etcd .
rm etcd-v3.4.16-darwin-amd64.zip
rm -r etcd-v3.4.16-darwin-amd64
endif

kubectl:
curl -LO "https://dl.k8s.io/release/$(shell curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
chmod +x kubectl

kube-apiserver:
curl -L https://storage.googleapis.com/kubebuilder-tools/kubebuilder-tools-1.19.2-$(kernel)-amd64.tar.gz \
| tar zxv --strip-components=2 $(tar_wildcards) "*/kube-apiserver"

```

Full M1 Apple Silicon support doesn't fully exist yet, and certainly not for older binaries. This solution leverages Rosetta2.

### Build Instructions

- Get the KUTTL repo: `git clone https://github.com/kudobuilder/kuttl.git`
Expand All @@ -126,6 +74,33 @@ Full M1 Apple Silicon support doesn't fully exist yet, and certainly not for old

After running this command, CLI will be available in `bin/kubectl-kuttl` and you can invoke the command for example like this `bin/kubectl-kuttl version` (no need to install it as `kubectl` plugin).

### Debugging in VSCode

Click Run > Add Configuration... to open the `launch.json` file. Add below configuration objects to specify the necessary sample tests and assertions in the `args[]`.

```json
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "KUTTL Debug",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceFolder}/cmd/kubectl-kuttl/main.go",
"args": [
"test",
"sample",
"--config=${workspaceFolder}/cmd/kubectl-kuttl/<sample_tests_dir_to_run_with_kuttl>"
]
}
]
}
```

### Testing

Use `make all` to run all available tests.
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# artifacts by default will land in the root of the mount point.

# kuttl builder
FROM golang:1.18 as builder
FROM golang:1.21 as builder

WORKDIR /go/src/kuttl
COPY . .
Expand All @@ -32,8 +32,8 @@ LABEL org.opencontainers.image.source="https://github.com/kudobuilder/kuttl"
RUN microdnf install vim tar gzip
RUN echo 'alias vi=vim' >> ~/.bashrc

# kube 1.18
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.18.0/bin/linux/amd64/kubectl
# kube 1.26
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.26.0/bin/linux/amd64/kubectl
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin/kubectl

Expand Down
26 changes: 19 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ BUILD_DATE_PATH := github.com/kudobuilder/kuttl/pkg/version.buildDate
DATE_FMT := "%Y-%m-%dT%H:%M:%SZ"
BUILD_DATE := $(shell date -u -d "@$SOURCE_DATE_EPOCH" "+${DATE_FMT}" 2>/dev/null || date -u -r "${SOURCE_DATE_EPOCH}" "+${DATE_FMT}" 2>/dev/null || date -u "+${DATE_FMT}")
LDFLAGS := -X ${GIT_VERSION_PATH}=${GIT_VERSION} -X ${GIT_COMMIT_PATH}=${GIT_COMMIT} -X ${BUILD_DATE_PATH}=${BUILD_DATE}
GOLANGCI_LINT_VER = "1.50.1"
GOLANGCI_LINT_VER = "1.54.2"
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION ?= 1.25.0

export GO111MODULE=on

Expand Down Expand Up @@ -133,10 +135,20 @@ endif

.PHONY: integration-test
# Run integration tests
integration-test: ## Runs integration tests
./hack/run-integration-tests.sh
integration-test: envtest ## Runs integration tests
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" ./hack/run-integration-tests.sh

# Run e2e tests
.PHONY: e2e-test
e2e-test: cli
./hack/run-e2e-tests.sh
##@ Build Dependencies

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
ENVTEST ?= $(LOCALBIN)/setup-envtest

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

<img src="https://kuttl.dev/images/kuttl-horizontal-logo.png" width="256">

[![CircleCI](https://circleci.com/gh/kudobuilder/kuttl.svg?style=svg)](https://circleci.com/gh/kudobuilder/kuttl)
[![lint](https://github.com/kudobuilder/kuttl/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/kudobuilder/kuttl/actions)
[![unit test](https://github.com/kudobuilder/kuttl/actions/workflows/unittest.yml/badge.svg?branch=main)](https://github.com/kudobuilder/kuttl/actions)
[![integration-test](https://github.com/kudobuilder/kuttl/actions/workflows/integration-test.yml/badge.svg?branch=main)](https://github.com/kudobuilder/kuttl/actions)
[![e2e](https://github.com/kudobuilder/kuttl/actions/workflows/e2e.yml/badge.svg?branch=main)](https://github.com/kudobuilder/kuttl/actions)

KUbernetes Test TooL (KUTTL) provides a declarative approach to test Kubernetes Operators.

Expand Down
3 changes: 0 additions & 3 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ This process will create a `dist` folder with all the build artifacts. The chang

The docker release is accomplished by `make docker-release`. Details on what is required are provided in [Docker.md](DOCKER.md).

### Cutting a Release Branch

As outlined above, when it is necessary to create a new release branch, it is necessary to update the [circle-ci config](https://github.com/kudobuilder/kuttl/blob/main/.circle-ci/config.yml#L13) to test merges against the correct branch. It is necessary replace all references to `main` with the appropriate release branch.

### Cutting a Patch Release

Expand Down
2 changes: 1 addition & 1 deletion crds/testsuite-json-schema.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ properties:
default: false
kindConfig:
description: Path to the KIND configuration file to use.
type: boolean
type: string
kindContext:
description: KIND context to use.
type: string
Expand Down
2 changes: 1 addition & 1 deletion crds/testsuite_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
default: false
kindConfig:
description: Path to the KIND configuration file to use.
type: boolean
type: string
kindContext:
description: KIND context to use.
type: string
Expand Down
Loading

0 comments on commit 97a6c16

Please sign in to comment.