-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from VictoriaMetrics/olm-integration-e2e-test
added api markers for OLM integration
- Loading branch information
Showing
107 changed files
with
25,715 additions
and
4,010 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,13 +5,11 @@ on: | |
push: | ||
branches: | ||
- '*' | ||
tags: [] | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
name: Build | ||
runs-on: ubuntu-latest | ||
name: test and build | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Inject slug/short variables | ||
uses: rlespinasse/[email protected] | ||
|
@@ -27,24 +25,46 @@ jobs: | |
go get golang.org/x/lint/golint | ||
go get github.com/kisielk/errcheck | ||
go get github.com/golangci/golangci-lint/cmd/[email protected] | ||
curl -L -o operator-sdk "https://github.com/operator-framework/operator-sdk/releases/download/v0.18.1/operator-sdk-v0.18.1-x86_64-linux-gnu" | ||
chmod +x operator-sdk | ||
sudo mv operator-sdk /bin/ | ||
- name: setup KIND for e2e tests | ||
uses: engineerd/[email protected] | ||
with: | ||
version: "v0.7.0" | ||
image: kindest/node:v1.16.4 | ||
- name: Code checkout | ||
uses: actions/checkout@master | ||
- name: build binary | ||
env: | ||
GO111MODULE: on | ||
TAG: ${{ env.GITHUB_REF_SLUG }} | ||
run: | | ||
export PATH=$PATH:$(go env GOPATH)/bin # temporary fix. See https://github.com/actions/setup-go/issues/14 | ||
make lint | ||
make test | ||
make build-app | ||
- name: run e2e tests | ||
run: | | ||
kubectl cluster-info | ||
kubectl get pods -n kube-system | ||
echo "current-context:" $(kubectl config current-context) | ||
echo "environment-kubeconfig:" ${KUBECONFIG} | ||
make e2e-local | ||
- name: build docker | ||
- name: build docker image and push | ||
uses: docker/build-push-action@v1 | ||
with: | ||
username: ${{secrets.REPO_USER}} | ||
password: ${{secrets.REPO_KEY}} | ||
registry: "quay.io" | ||
repository: f41gh7/vm-operator | ||
repository: victoriametrics/operator | ||
tag_with_ref: true | ||
dockerfile: cmd/manager/Dockerfile | ||
|
||
- name: run e2e with docker | ||
env: | ||
E2E_IMAGE: ${{ env.GITHUB_REF_SLUG }} | ||
run: | | ||
kubectl cluster-info | ||
kubectl get pods -n kube-system | ||
make e2e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,10 +6,11 @@ on: | |
jobs: | ||
release: | ||
name: Release on GitHub | ||
runs-on: ubuntu-latest | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- name: Inject slug/short variables | ||
uses: rlespinasse/[email protected] | ||
|
||
- name: Setup Go | ||
uses: actions/setup-go@master | ||
with: | ||
|
@@ -22,6 +23,15 @@ jobs: | |
go get -u golang.org/x/lint/golint | ||
go get -u github.com/kisielk/errcheck | ||
go get github.com/golangci/golangci-lint/cmd/[email protected] | ||
curl -L -o operator-sdk "https://github.com/operator-framework/operator-sdk/releases/download/v0.18.1/operator-sdk-v0.18.1-x86_64-linux-gnu" | ||
chmod +x operator-sdk | ||
sudo mv operator-sdk /bin/ | ||
- name: setup KIND for e2e tests | ||
uses: engineerd/[email protected] | ||
with: | ||
version: "v0.7.0" | ||
image: kindest/node:v1.16.4 | ||
|
||
- name: Check out code | ||
uses: actions/checkout@v2 | ||
|
@@ -34,6 +44,13 @@ jobs: | |
make test | ||
make build-app | ||
sh scripts/bundle.sh | ||
- name: run e2e tests local | ||
run: | | ||
kubectl cluster-info | ||
kubectl get pods -n kube-system | ||
echo "current-context:" $(kubectl config current-context) | ||
echo "environment-kubeconfig:" ${KUBECONFIG} | ||
make e2e-local | ||
- name: build docker | ||
uses: docker/build-push-action@v1 | ||
|
@@ -44,6 +61,13 @@ jobs: | |
repository: victoriametrics/operator | ||
dockerfile: cmd/manager/Dockerfile | ||
|
||
- name: run e2e with docker | ||
env: | ||
E2E_IMAGE: ${{ env.GITHUB_REF_SLUG }} | ||
run: | | ||
kubectl cluster-info | ||
kubectl get pods -n kube-system | ||
make e2e | ||
- name: Upload Release Asset | ||
id: upload-release-asset | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
|
||
## Required programs | ||
|
||
for developing you need: | ||
- golang 1.13+ | ||
- operator-sdk 1.18.1 | ||
- docker | ||
- minikube or kind for e2e tests | ||
- golangci-lint | ||
- operator-courier | ||
|
||
|
||
|
||
## local build and run | ||
|
||
Use `make build` - it will generate new crds and build binary | ||
|
||
|
||
for running locally you need minikube and run two commands: | ||
```bash | ||
kubectl apply -f deploy/crds | ||
make run | ||
``` | ||
or you can run it from IDE with ```cmd/manager/main.go``` | ||
|
||
## publish changes | ||
|
||
before creating merge request, ensure that tests passed locally: | ||
```bash | ||
make build # it will update crds | ||
make lint # linting project | ||
make test #unit tests | ||
make e2e-local #e2e tests with minikube | ||
``` | ||
|
||
## create olm package | ||
|
||
Choose version and generate or update corresponding csv file | ||
```bash | ||
CSV_VERSION=0.0.2 make olm | ||
``` | ||
|
||
it will generate files at directory: `deploy/olm-catalog/victoria-metrics-operator/0.0.3/` | ||
|
||
update file: `deploy/olm-catalog/victoria-metrics-operator/0.0.3/victoria-metrics-operator.v0.0.3.clusterserviceversion.yaml` | ||
|
||
with fields from file:`deploy/olm-catalog/templates/csv-additional-fields-template.yaml` | ||
|
||
replace operator version - specify release instead of latest | ||
|
||
commit changes | ||
|
||
publish olm package to quay.io with | ||
|
||
```bash | ||
make olm-publish | ||
``` | ||
|
||
### integration with operator-hub | ||
|
||
Clone repo locally: git clone https://github.com/operator-framework/community-operators.git | ||
|
||
copy content to operator-hub repo and run tests | ||
you can specify version (OP_VER) and channel OP_CHANNEL | ||
```bash | ||
cp -R deploy/olm-catalog/victoria-metrics-operator/ PATH_TO_OPERATOR_REPO/upstream-community-operators/ | ||
cd PATH_TO_OPERATOR_REPO | ||
#run tests | ||
make operator.verify OP_PATH=upstream-community-operators/victoria-metrics-operator VERBOSE=1 | ||
make operator.test OP_PATH=upstream-community-operators/victoria-metrics-operator/ VERBOSE=1 | ||
|
||
``` | ||
|
||
Now you can submit merge request with changes to operator-hub repo | ||
|
||
|
||
troubleshooting: [url](https://github.com/operator-framework/community-operators/blob/master/docs/using-scripts.md#troubleshooting) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
# Go parameters | ||
GOCMD=GO111MODULE=on go | ||
VERSION=$($CI_BUILD_TAG) | ||
TAG="master" | ||
VERSION=$(TAG) | ||
BUILD=`date +%FT%T%z` | ||
LDFLAGS=-ldflags "-w -s -X main.Version=${VERSION} -X main.BuildData=${BUILD}" | ||
GOBUILD=CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOCMD) build -trimpath ${LDFLAGS} | ||
|
@@ -13,33 +14,68 @@ REPO=github.com/VictoriaMetrics/operator | |
MAIN_DIR=$(REPO)/cmd/manager/ | ||
DOC_GEN_DIR=$(REPO)/cmd/doc-gen/ | ||
OPERATOR_BIN=operator-sdk | ||
DOCKER_REPO=quay.io/f41gh7/vm-operator | ||
TAG="master" | ||
DOCKER_REPO=victoriametrics/operator | ||
E2E_IMAGE ?= latest | ||
|
||
CSV_VERSION ?= 0.0.1 | ||
QUAY_TOKEN=$(REPO_TOKEN) | ||
TEST_ARGS=$(GOCMD) test -covermode=atomic -coverprofile=coverage.txt -v | ||
APIS_BASE_PATH=pkg/apis/victoriametrics/v1beta1 | ||
GOPATHDIR ?= ~/go | ||
|
||
.PHONY: build | ||
|
||
all: build | ||
|
||
gen-client: | ||
client-gen --go-header-file $(GOPATHDIR)/pkg/mod/k8s.io/[email protected]/hack/boilerplate.go.txt \ | ||
--input-base=""\ | ||
--input=$(REPO)/pkg/apis/victoriametrics/v1beta1 \ | ||
--clientset-name "versioned" \ | ||
--output-package=$(REPO)/pkg/client \ | ||
--output-base "" | ||
cp -R $(REPO)/pkg/client ./pkg | ||
|
||
install-golint: | ||
which golint || GO111MODULE=off go get -u golang.org/x/lint/golint | ||
|
||
install-develop-tools: install-golint | ||
which operator-courier || pip install operator-courier | ||
|
||
report: | ||
$(GOCMD) tool cover -html=coverage.txt | ||
|
||
gen: | ||
$(OPERATOR_BIN) generate crds | ||
$(OPERATOR_BIN) generate crds --crd-version=v1beta1 | ||
$(OPERATOR_BIN) generate k8s | ||
|
||
olm: | ||
$(OPERATOR_BIN) generate csv --operator-name=victoria-metrics-operator \ | ||
--csv-version $(CSV_VERSION)\ | ||
--apis-dir=pkg/apis/victoriametrics/ \ | ||
--make-manifests=false \ | ||
--update-crds | ||
|
||
olm-verify: | ||
operator-courier verify deploy/olm-catalog/victoria-metrics-operator/ | ||
|
||
|
||
build-app: fmt | ||
$(GOBUILD) -o $(BINARY_NAME) -v $(MAIN_DIR) | ||
|
||
|
||
doc: | ||
$(GOBUILD) -o doc-print $(DOC_GEN_DIR) | ||
./doc-print api pkg/apis/victoriametrics/v1beta1/alertmanager_types.go pkg/apis/victoriametrics/v1beta1/vmagent_types.go pkg/apis/victoriametrics/v1beta1/additional.go pkg/apis/victoriametrics/v1beta1/vmalert_types.go pkg/apis/victoriametrics/v1beta1/vmsingle_types.go pkg/apis/monitoring/v1/prometheusrule_types.go pkg/apis/monitoring/v1/servicemonitor_types.go > docs/api.MD | ||
./doc-print api \ | ||
$(APIS_BASE_PATH)/alertmanager_types.go \ | ||
$(APIS_BASE_PATH)/vmagent_types.go \ | ||
$(APIS_BASE_PATH)/additional.go \ | ||
$(APIS_BASE_PATH)/vmalert_types.go \ | ||
$(APIS_BASE_PATH)/vmsingle_types.go \ | ||
$(APIS_BASE_PATH)/vmrule_types.go \ | ||
$(APIS_BASE_PATH)/vmservicescrape_types.go \ | ||
$(APIS_BASE_PATH)/vmpodscrape_types.go \ | ||
$(APIS_BASE_PATH)/vmprometheusconvertor_types.go \ | ||
> docs/api.MD | ||
|
||
|
||
fmt: | ||
|
@@ -57,22 +93,24 @@ test: | |
$(TEST_ARGS) $(REPO)/pkg/... | ||
$(GOCMD) tool cover -func coverage.txt | grep total | ||
|
||
.PHONY:e2e | ||
.PHONY:e2e-local | ||
e2e-local: | ||
operator-sdk test local ./e2e/ --up-local --operator-namespace="default" --verbose --image=$(DOCKER_REPO):$(E2E_IMAGE) | ||
$(OPERATOR_BIN) test local ./e2e/ --up-local --operator-namespace="default" --verbose | ||
|
||
.PHONY:e2e | ||
e2e: | ||
operator-sdk test local ./e2e/ --operator-namespace="default" --verbose --image=$(DOCKER_REPO):$(E2E_IMAGE) | ||
$(OPERATOR_BIN) test local ./e2e/ --operator-namespace="default" --verbose --image=$(DOCKER_REPO):$(E2E_IMAGE) | ||
|
||
lint: | ||
golangci-lint run --exclude '(SA1019):' -E typecheck -E gosimple --timeout 5m | ||
golint ./pkg | ||
golangci-lint run --exclude '(SA1019):' -E typecheck -E gosimple --timeout 5m --skip-dirs 'pkg/client' | ||
golint ./pkg/ | ||
|
||
.PHONY:clean | ||
clean: | ||
$(GOCLEAN) | ||
rm -f $(BINARY_NAME) | ||
rm -f $(BINARY_UNIX) | ||
|
||
.PHONY: run | ||
run: build | ||
WATCH_NAMESPACE="" OPERATOR_NAME=vms ./$(BINARY_NAME) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.