Skip to content

Commit

Permalink
fixed not yet existing operator path (#1016)
Browse files Browse the repository at this point in the history
* fixed not yet existing operator path

* use pr action instead of shell

* fixed docs for vmagent

* fixed tag name for config-reloader

* remove certified operator repo as not supported atm

* fixed typo

---------

Co-authored-by: Nikolay <[email protected]>
  • Loading branch information
AndrewChubatiuk and f41gh7 authored Jul 4, 2024
1 parent 0c311bb commit b6ed072
Show file tree
Hide file tree
Showing 8 changed files with 322 additions and 339 deletions.
39 changes: 20 additions & 19 deletions .github/workflows/crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ jobs:
repository: VictoriaMetrics/operator
ref: master
token: ${{ secrets.VM_BOT_GH_TOKEN }}
path: "__vm-operator-repo"
path: __vm-operator-repo

- name: Check out VM code
uses: actions/checkout@v4
with:
repository: VictoriaMetrics/helm-charts
ref: master
token: ${{ secrets.VM_BOT_GH_TOKEN }}
path: "__vm-charts-repo"
path: __vm-charts-repo

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
Expand All @@ -34,24 +34,25 @@ jobs:
passphrase: ${{ secrets.VM_BOT_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
workdir: "__vm-charts-repo"
workdir: __vm-charts-repo

- name: Update crd yaml in chart repo
run: |
cp config/crd/overlay/crd.yaml ../__vm-charts-repo/charts/victoria-metrics-operator/crd.yaml
cp config/crd/overlay/crd.yaml ../__vm-charts-repo/charts/victoria-metrics-k8s-stack/charts/crds/crds/crd.yaml
working-directory: "__vm-operator-repo"
cp ../__vm-operator-repo/config/crd/overlay/crd.yaml charts/victoria-metrics-operator/crd.yaml
cp ../__vm-operator-repo/config/crd/overlay/crd.yaml charts/victoria-metrics-k8s-stack/charts/crds/crds/crd.yaml
echo "BUILDTIME=$(date +%s)" >> $GITHUB_OUTPUT
echo "SHORT_SHA=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_OUTPUT
working-directory: __vm-charts-repo

- name: Commit and push changes
run: |
export VM_GIT_BRANCH_NAME="operator-crds-update-$(date +%s)"
export VM_GIT_COMMIT_SHA="$(git rev-parse --short $GITHUB_SHA)"
git checkout -b "${VM_GIT_BRANCH_NAME}"
git add charts/victoria-metrics-operator/crd.yaml
git add charts/victoria-metrics-k8s-stack/charts/crds/crds/crd.yaml
git commit -S -m "Automatic sync crd resources from ${GITHUB_REPOSITORY}@${VM_GIT_COMMIT_SHA}"
git push origin ${VM_GIT_BRANCH_NAME}
gh pr create -f
working-directory: "__vm-charts-repo"
env:
GITHUB_TOKEN: ${{ secrets.VM_BOT_GH_TOKEN }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
add-paths: charts
commit-message: Automatic update operator crds from ${{ github.repository }}@${{ steps.update.outputs.SHORT_SHA }}
signoff: true
author: Github Actions <[email protected]>
path: __vm-charts-repo
branch: operator-crd-update-${{ steps.update.outputs.BUILDTIME }}
token: ${{ secrets.VM_BOT_GH_TOKEN }}
delete-branch: true
title: Automatic update operator crds from ${{ github.repository }}@${{ steps.update.outputs.SHORT_SHA }}
58 changes: 22 additions & 36 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ jobs:
repository: VictoriaMetrics/operator
ref: master
token: ${{ secrets.VM_BOT_GH_TOKEN }}
path: "__vm-operator-repo"
path: __vm-operator-repo

- name: Check out VM code
uses: actions/checkout@v4
with:
repository: VictoriaMetrics/VictoriaMetrics
ref: master
token: ${{ secrets.VM_BOT_GH_TOKEN }}
path: "__vm-docs-repo"
path: __vm-docs-repo

- name: Setup Go
uses: actions/setup-go@v5
Expand All @@ -41,41 +41,27 @@ jobs:
passphrase: ${{ secrets.VM_BOT_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
workdir: "__vm-docs-repo"

- name: Generate vars and api doc
run: |
make docs
working-directory: "__vm-operator-repo"
workdir: __vm-docs-repo

- name: Update operator docs in VM repo
id: update
run: |
# Markdown files
for md in $(find docs -name '*.md'); do
newmd=$(echo $md | sed -e 's/^docs\//&operator\//g')
mkdir -p ../__vm-docs-repo/$(dirname $newmd)
cat $md > ../__vm-docs-repo/$newmd
done
# Pictures
for png in $(find docs -name '*.png'); do
newpng=$(echo $png | sed -e 's/^docs\//&operator\//g')
mkdir -p ../__vm-docs-repo/$(dirname $newpng)
\cp -f $png ../__vm-docs-repo/$newpng
done
# Autogenerated files
cat ./docs/vars.md > ../__vm-docs-repo/docs/operator/vars.md
cat ./docs/api.md > ../__vm-docs-repo/docs/operator/api.md
working-directory: "__vm-operator-repo"
make docs
# Sync markdown files and pictures
rsync -zarv --include="*/" --include="*.png" --include="*.md" --exclude="*" docs/ ../__vm-docs-repo/docs/operator/
echo "BUILDTIME=$(date +%s)" >> $GITHUB_OUTPUT
echo "SHORT_SHA=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_OUTPUT
working-directory: __vm-operator-repo

- name: Commit and push changes
run: |
export VM_GIT_BRANCH_NAME="operator-docs-update-$(date +%s)"
export VM_GIT_COMMIT_SHA="$(git rev-parse --short $GITHUB_SHA)"
git checkout -b "${VM_GIT_BRANCH_NAME}"
git add docs/operator
git commit -S -m "Automatic update operator docs from ${GITHUB_REPOSITORY}@${VM_GIT_COMMIT_SHA}"
git push origin ${VM_GIT_BRANCH_NAME}
gh pr create -f
working-directory: "__vm-docs-repo"
env:
GITHUB_TOKEN: ${{ secrets.VM_BOT_GH_TOKEN }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
add-paths: docs/operator
commit-message: Automatic update operator docs from ${{ github.repository }}@${{ steps.update.outputs.SHORT_SHA }}
signoff: true
author: Github Actions <[email protected]>
path: __vm-docs-repo
branch: operator-docs-update-${{ steps.update.outputs.BUILDTIME }}
token: ${{ secrets.VM_BOT_GH_TOKEN }}
delete-branch: true
title: Automatic update operator docs from ${{ github.repository }}@${{ steps.update.outputs.SHORT_SHA }}
35 changes: 17 additions & 18 deletions .github/workflows/operatorhub.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
upstream: k8s-operatorhub/community-operators
- fork: VictoriaMetrics/openshift-community-operators-prod
upstream: redhat-openshift-ecosystem/community-operators-prod
- fork: VictoriaMetrics/openshift-certified-operators
upstream: redhat-openshift-ecosystem/certified-operators
steps:
- name: Check out OperatorHub operators repo fork
uses: actions/checkout@v4
Expand Down Expand Up @@ -52,21 +50,22 @@ jobs:
run: |
VERSION=$(ls bundle | head -1)
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
mkdir -p __k8s-operatorhub-repo/operators/victoriametrics-operator
mv bundle/* __k8s-operatorhub-repo/operators/victoriametrics-operator/
# temporary disable. Uncomment after changes to operatorhub ci procedure.
# - name: Create Pull Request
# uses: peter-evans/create-pull-request@v6
# with:
# add-paths: operators/victoriametrics-operator
# signoff: true
# author: Github Actions <[email protected]>
# path: __k8s-operatorhub-repo
# push-to-fork: ${{ matrix.repo.fork }}
# branch: vm-operator-release-${{ steps.update.outputs.VERSION }}
# token: ${{ secrets.VM_BOT_GH_TOKEN }}
# delete-branch: true
# title: "victoriametrics-operator: update operator ${{ steps.update.outputs.VERSION }}"
# body: |
# Added OLM package for [VictoriaMetrics operator ${{ steps.update.outputs.VERSION }}"](https://github.com/VictoriaMetrics/operator/releases/tag/v${{ steps.update.outputs.VERSION }})
# > Auto-generated by `Github Actions Bot`
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
add-paths: operators/victoriametrics-operator
commit-message: victoriametrics-operator: ${{ steps.update.outputs.VERSION }}
signoff: true
author: Github Actions <[email protected]>
path: __k8s-operatorhub-repo
push-to-fork: ${{ matrix.repo.fork }}
branch: vm-operator-release-${{ steps.update.outputs.VERSION }}
token: ${{ secrets.VM_BOT_GH_TOKEN }}
delete-branch: true
title: victoriametrics-operator: (${{ steps.update.outputs.VERSION }})
body: |
Added OLM package for [VictoriaMetrics operator ${{ steps.update.outputs.VERSION }}"](https://github.com/VictoriaMetrics/operator/releases/tag/v${{ steps.update.outputs.VERSION }})
> Auto-generated by `Github Actions Bot`
25 changes: 13 additions & 12 deletions .github/workflows/sandbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
repository: VictoriaMetrics/ops
ref: main
token: ${{ secrets.VM_BOT_GH_TOKEN }}
path: "__vm-ops-repo"
path: __vm-ops-repo

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
Expand All @@ -27,30 +27,31 @@ jobs:
passphrase: ${{ secrets.VM_BOT_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
workdir: "__vm-ops-repo"
workdir: __vm-ops-repo

- name: Update operator version on sandbox
id: update
run: |
export VM_GIT_COMMIT_SHA="$(git rev-parse --short $GITHUB_SHA)"
export VM_SANDBOX_OPERATOR_PATH="gcp-test/sandbox/manifests/applications/vm-operator.yaml"
yq -i 'with(.spec.source.helm.values; . = (. | from_yaml | .image.tag = strenv(VM_GIT_COMMIT_SHA) | to_yaml))' $VM_SANDBOX_OPERATOR_PATH
git add $VM_SANDBOX_OPERATOR_PATH
git commit -S -m "Automatic update operator version on sandbox from ${GITHUB_REPOSITORY}@${VM_GIT_COMMIT_SHA}"
export SHORT_SHA=$(git rev-parse --short $GITHUB_SHA)
export OPERATOR_PATH=gcp-test/sandbox/manifests/applications/vm-operator.yaml
yq -i '.spec.source.helm.valuesObject.image.tag = strenv(SHORT_SHA)' $OPERATOR_PATH
echo "IMAGE_TAG=$VM_GIT_COMMIT_SHA" >> $GITHUB_OUTPUT
working-directory: "__vm-ops-repo"
env:
GITHUB_TOKEN: ${{ secrets.VM_BOT_GH_TOKEN }}
echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT
echo "OPERATOR_PATH=$OPERATOR_PATH" >> $GITHUB_OUTPUT
working-directory: __vm-ops-repo

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
add-paths: ${{ steps.update.outputs.OPERATOR_PATH }}
commit-message: Automatic update operator version on sandbox from ${{ github.repository }}@${{ steps.update.outputs.SHORT_SHA }}
signoff: true
author: Github Actions <[email protected]>
path: __vm-ops-repo
branch: sandbox-operator-release-automation
token: ${{ secrets.VM_BOT_GH_TOKEN }}
delete-branch: true
title: "sandbox: update operator ${{ steps.update.outputs.IMAGE_TAG }}"
title: sandbox: update operator ${{ steps.update.outputs.IMAGE_TAG }}
body: |
Deploy [${{ steps.update.outputs.IMAGE_TAG }}"](https://github.com/VictoriaMetrics/operator/commit/${{ steps.update.outputs.IMAGE_TAG }}) to sandbox
> Auto-generated by `Github Actions Bot`
2 changes: 0 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ARG REPO
ARG ROOT

# Build the manager binary
Expand All @@ -18,7 +17,6 @@ RUN go mod download
COPY cmd/ cmd/
COPY api/ api/
COPY internal/ internal/
ARG REPO
ARG ROOT

# Build
Expand Down
27 changes: 11 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# Image URL to use all building/pushing image targets
REGISTRY ?= docker.io
REPO ?= operator
REPO = operator
ROOT ?= ./cmd
ORG ?= victoriametrics
TAG ?= v0.46.0
VERSION ?= $(TAG:v%=%)
NAMESPACE ?= vm
BUILDINFO_TAG ?= $(shell echo $$(git describe --long --all | tr '/' '-')$$( \
TAG ?= $(shell echo $$(git describe --long --all | tr '/' '-')$$( \
git diff-index --quiet HEAD -- || echo '-dirty-'$$(git diff-index -u HEAD | openssl sha1 | cut -d' ' -f2 | cut -c 1-8)))
VERSION ?= $(if $(findstring $(TAG),$(TAG:v%=%)),0.0.1,$(TAG:v%=%))
NAMESPACE ?= vm
OVERLAY ?= config/default

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
Expand Down Expand Up @@ -139,17 +138,15 @@ run: manifests generate fmt vet ## Run a controller from your host.
.PHONY: docker-build
docker-build: ## Build docker image with the manager.
$(CONTAINER_TOOL) build \
--build-arg REPO=$(REPO) \
--build-arg ROOT=$(ROOT) \
${DOCKER_BUILD_ARGS} \
-t $(REGISTRY)/$(ORG)/$(REPO):$(TAG) \
-t $(REGISTRY)/$(ORG)/$(REPO):$(BUILDINFO_TAG) .
-t $(REGISTRY)/$(ORG)/$(REPO):$(TAG) .

build-operator:
REPO=operator ROOT=./cmd $(MAKE) build
ROOT=./cmd $(MAKE) build

build-config-reloader:
REPO=config-reloader ROOT=./cmd/config-reloader $(MAKE) build
ROOT=./cmd/config-reloader $(MAKE) build

.PHONY: docker-push
docker-push: ## Push docker image with the manager.
Expand All @@ -171,18 +168,16 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
- $(CONTAINER_TOOL) buildx build \
--push \
--platform=$(PLATFORMS) \
--build-arg REPO=$(REPO) \
--build-arg ROOT=$(ROOT) \
${DOCKER_BUILD_ARGS} \
--tag $(REGISTRY)/$(ORG)/$(REPO):$(TAG) \
--tag $(REGISTRY)/$(ORG)/$(REPO):$(BUILDINFO_TAG) \
-f Dockerfile.cross .
- $(CONTAINER_TOOL) buildx rm vm-builder
rm Dockerfile.cross

publish:
REPO=operator ROOT=./cmd $(MAKE) docker-buildx
REPO=config-reloader ROOT=./cmd/config-reloader $(MAKE) docker-buildx
ROOT=./cmd $(MAKE) docker-buildx
TAG=config-reloader-$(TAG) ROOT=./cmd/config-reloader $(MAKE) docker-buildx

.PHONY: build-installer
build-installer: manifests generate kustomize ## Generate a consolidated YAML with CRDs and deployment.
Expand Down Expand Up @@ -230,10 +225,10 @@ load-kind: docker-build kind
else \
$(KUBECTL) cluster-info --context kind-kind; \
fi; \
$(KIND) load docker-image $(REGISTRY)/$(ORG)/$(REPO):$(BUILDINFO_TAG)
$(KIND) load docker-image $(REGISTRY)/$(ORG)/$(REPO):$(TAG)

deploy-kind: load-kind
TAG=$(BUILDINFO_TAG) $(MAKE) deploy
$(MAKE) deploy

undeploy-kind: load-kind
OVERLAY=config/kind $(MAKE) undeploy
Expand Down
Loading

0 comments on commit b6ed072

Please sign in to comment.